19 #include "StMtdSimMaker.h"
24 #include "SystemOfUnits.h"
25 #include "phys_constants.h"
26 #include "StThreeVectorD.hh"
28 #include "RanluxEngine.h"
29 #include "RandGauss.h"
36 #include "tables/St_g2t_mtd_hit_Table.h"
37 #include "tables/St_g2t_track_Table.h"
38 #include "tables/St_mtdGeant2BacklegIDMap_Table.h"
39 #include "StMcTrack.hh"
41 #include "StEventTypes.h"
46 Int_t geant2backlegIDMap[30];
98 mNumberOfPhotoelectrons(0),
108 memset(mModuleChannel,0,5*24*
sizeof(Int_t));
112 mHistFile=
"mtdsim.root";
118 StMtdSimMaker::~StMtdSimMaker() {
124 Int_t StMtdSimMaker::Init() {
126 return StMaker::Init();
130 void StMtdSimMaker::Reset() {
133 if (mWriteStEvent)
delete mMtdCollection;
140 LOG_INFO <<
"Retrieving geant2backlegID table from database ..." << endm;
141 TDataSet *dataset = GetDataBase(
"Geometry/mtd/mtdGeant2BacklegIDMap");
142 St_mtdGeant2BacklegIDMap *mtdGeant2BacklegIDMap =
static_cast<St_mtdGeant2BacklegIDMap*
>(dataset->
Find(
"mtdGeant2BacklegIDMap"));
143 if ( !mtdGeant2BacklegIDMap ){
144 LOG_ERROR <<
"No mtdTrayToTdigMap table found in database" << endm;
147 mtdGeant2BacklegIDMap_st *mGeant2BLTable =
static_cast<mtdGeant2BacklegIDMap_st*
>(mtdGeant2BacklegIDMap->GetTable());
148 for ( Int_t i = 0; i < 30; i++ ){
149 geant2backlegIDMap[i] = 0;
150 geant2backlegIDMap[i] = (Int_t)mGeant2BLTable->geant2backlegID[i];
156 for (
int module=0; module<5; module++){
157 for (
int cell=0; cell<24; cell ++){
158 mModuleChannel[module][cell] = ++channel;
166 Int_t StMtdSimMaker::FinishRun(Int_t runnumber) {
174 LOG_INFO <<
"StMtdSimMaker::Finish writing mtdsim.root ...";
175 TFile theFile(
mHistFile.c_str(),
"RECREATE",
"mtdsim");
189 mGeantData = GetInputDS(
"geant");
191 mGeantData = GetInputDS(
"geantBranch");
194 LOG_WARN <<
" No GEANT data loaded. Exit! " << endm;
197 LOG_INFO <<
" Found GEANT data -- loading MTD hits... " << endm;
200 St_g2t_mtd_hit* g2t_mtd_hits =
dynamic_cast<St_g2t_mtd_hit*
>(mGeantData->
Find(
"g2t_mtd_hit"));
202 LOG_WARN <<
" No MTD hits in GEANT" << endm;
205 mNMtdHits = g2t_mtd_hits->GetNRows();
207 LOG_WARN <<
" No MTD hits in GEANT" << endm;
210 LOG_INFO <<
" Found MTD hits: " << mNMtdHits << endm;
213 mMtdHitsFromGeant = g2t_mtd_hits->GetTable();
225 Int_t ires = volume_id/100;
226 backlegTemp = ires/10;
227 ibackleg = geant2backlegIDMap[backlegTemp - 1];
230 if ( ibackleg >= 12 && ibackleg <= 20 ) imodule = imodule + 1;
235 if ( imodule > 3 ) icell = 11 - icell;
238 if(ibackleg<0 || ibackleg>kNBackleg)
return -3;
239 if(imodule <0 || imodule >kNModule )
return -2;
240 if(icell <0 || icell >= kNCell )
return -1;
242 return icell + 100*(imodule+100*ibackleg);
249 std::map<int,StMtdHit*> myMap;
250 std::map<int,StMtdHit*>::const_iterator myIter;
252 for (
int ihit=0;ihit<mNMtdHits;ihit++) {
253 g2t_mtd_hit_st &ghit = mMtdHitsFromGeant[ihit];
254 if(ghit.s_track<=0.0 || ghit.de <=0.0)
continue;
263 Int_t icell, imodule, ibackleg;
264 int cellId =
CalcCellId(ghit.volume_id, ghit.x[1],ibackleg,imodule,icell);
266 LOG_DEBUG <<
"Volume ID: "<< ghit.volume_id <<
" Cell ID: " << cellId << endm;
267 LOG_DEBUG <<
" icell: " << icell <<
" imodule: " << imodule <<
" ibackleg: " << ibackleg <<
" ghit.tof: " << ghit.tof << endm;
268 LOG_DEBUG <<
" track: " << ghit.track_p << endm;
270 if (cellId<0)
continue;
272 if (!sthit) { sthit =
new StMtdHit;}
273 else {
if (sthit->tof()>ghit.tof)
continue; }
277 Double_t
tof= ghit.tof/nanosecond + ranGauss.shoot()*(99.e-12)/nanosecond;
278 Double_t de = ghit.de * wt;
283 double leadingW = ghit.tof/nanosecond - ghit.x[2]*vel;
284 double leadingE = ghit.tof/nanosecond + ghit.x[2]*vel;
285 double trailingW = leadingW + 15;
286 double trailingE = leadingE + 15;
288 int channel1 = mModuleChannel[imodule - 1][icell];
289 int channel2 = channel1 + 12;
291 LOG_INFO <<
"First hit for this cell, assigning channel 1: " << channel1 <<
" channel 2: " << channel2 << endm;
306 sthit->setBackleg(ibackleg);
307 sthit->setModule(imodule);
308 sthit->setCell(icell);
309 sthit->setLeadingEdgeTime(pair<double,double>(leadingW, leadingE));
310 sthit->setTrailingEdgeTime(pair<double,double>(trailingW, trailingE));
311 sthit->setAssociatedTrack(NULL);
312 sthit->setIdTruth(ghit.track_p, 100);
314 LOG_INFO <<
"sthit " << sthit->tof() <<
" tof:" << tof << endm;
320 mMtdCollection =
mEvent->mtdCollection();
324 mEvent->setMtdCollection(mMtdCollection);
326 nRealHits = mMtdCollection->mtdHits().size();
331 for (myIter=myMap.begin(); myIter!=myMap.end(); ++myIter) {
332 mMtdCollection->addHit((*myIter).second);
336 LOG_INFO <<
"... " << nMcHits <<
" MC hits stored in StEvent with " << nRealHits <<
" real hits! " << endm;
346 mBetaHist=
new TH1F(
"mBetaHist",
"mBetaHist", 100, -2, 2);
347 mPathLHist=
new TH1F(
"mPathLHist",
"mPathLHist", 100, -2, 500);
348 mTofHist=
new TH1F(
"mTofHist",
"mTofHist", 1000, -10, 10000);
349 mRecMass=
new TH1F(
"mRecMass",
"mRecMass", 1000, -2, 4);
351 mCellGeant =
new TH2F(
"CellGeant",
"CellGeant",192,0.,192.,120,1.,120.);
352 mNCellGeant =
new TH2F(
"NCellGeant",
"NCellGeant",192,0.,192.,120,1.,120.);
353 mDeGeant =
new TH1F(
"DeGeant",
"DeGeant",1000,0.,10.);
354 mTofGeant =
new TH1F(
"TofGeant",
"TofGeant",1000,0.,20.);
356 mCellSeen =
new TH2F(
"CellSeen",
"CellSeen",192,0.,192.,120,1.,120.);
357 mNCellSeen =
new TH2F(
"NCellSeen",
"NCellSeen",192,0.,192.,120,1.,120.);
358 mDeSeen =
new TH1F(
"DeSeen",
"DeSeen",1000,0.,10.);
359 mT0Seen =
new TH1F(
"T0Seen",
"T0Seen",1000,0.,20.);
360 mTofSeen =
new TH1F(
"TofSeen",
"TofSeen",1000,0.,20.);
362 mTofResSeen =
new TH1F(
"TofResSeen",
"TofResSeen",1001,-500.,500.);
364 mCellReco =
new TH2F(
"CellReco",
"CellReco",192,0.,192.,120,1.,120.);
365 mNCellReco =
new TH2F(
"NCellReco",
"NCellReco",192,0.,192.,120,1.,120.);
366 mADCReco =
new TH1F(
"ADCReco",
"ADCReco",4096,0.,4096.);
367 mTDCReco =
new TH1F(
"TDCReco",
"TDCReco",4096,0.,4096.);
368 mT0Reco =
new TH1F(
"T0Reco",
"T0Reco",1000,0.,20.);
369 mTofResReco =
new TH1F(
"TofResReco",
"TofResReco",1000,-300.,300.);
370 mTACorr =
new TH2F(
"TACorr",
"TACorr",512,0.,4096.,512,0.,4096.);
372 mModHist =
new TH1F(
"ModuleHist",
"ModuleHist",201,-100,100);
373 QABacklegChannel =
new TH2I(
"QABacklegChannel",
"QABacklegChannel", 30, 1., 30., 120, 1., 120.);
379 Int_t StMtdSimMaker::writeHistograms()
405 mTofResReco->Write();
TH2I * QABacklegChannel
T-A Slewing Correlation.
TH2F * mNCellSeen
Vpd tubeId after DetectorResponse.
TH1F * mRecMass
total time of flight of partilce
string mHistFile
switch to enable Maker to write out simulated hits to StEvent
TH1F * mPathLHist
speed of particles hitting tof
TH1F * mDeGeant
of vpd tubes of geant hit
TH1F * mDeSeen
of vpd tubes after DetectorResponse
TH1F * mT0Seen
deposited-energy after DetectorResponse
TH1F * mTofGeant
deposited-energy in geant hit
TH2F * mTACorr
vpd time resolution after recon
TH1F * mTDCReco
of vpd tubes after recon
Int_t CalcCellId(Int_t volume_id, Float_t ylocal, Int_t &ibackleg, Int_t &imodule, Int_t &icell)
This will calculate the cell ID as well as decode the module # and backleg # to store in an MTD Colle...
TH2F * mNCellReco
Vpd tubeId after recon.
TH2F * mCellSeen
tof in geant hit
TH2F * mCellReco
vpd time resolution after DetectorResponse
static const float kMtdPadWidth
Pad Width: 38mm padwidth + 6mm innerspacing.
StEvent * mEvent
geant table
TH1F * mTofResSeen
smeared-tof after DetectorResponse
TH1F * mT0Reco
ADC recon – empty.
TH1F * mADCReco
TDC recon.
Int_t FastCellResponse()
This will define the maps to store the StMtdHits and will call the necessary functions to obtain the ...
TH1F * mTofHist
speed of particles hitting tof
TH2F * mNCellGeant
Vpd tubeId of geant hit.
TH2F * mCellGeant
reconstructed mass of particle
TH1F * mModHist
T-A Slewing Correlation.
virtual TDataSet * Find(const char *path) const