8 #include "StBbcSimulationMaker.h"
9 #include "g2t/St_g2t_bbc_Module.h"
10 #include "TDataSetIter.h"
14 #include "StTriggerDetectorCollection.h"
15 #include "StBbcTriggerDetector.h"
16 #include "StMessMgr.h"
18 TRandom BbcRndm = TRandom(0);
22 const
float BbcTimingRMS = 900.E-12;
29 const uint16_t NPMTsmall1 = 16;
30 const uint16_t NPMTlarge1 = 8;
31 const uint16_t NPMT1 = NPMTsmall1+NPMTlarge1;
32 const uint16_t NPMT2 = 2*NPMT1;
33 const
float dE1MIPper_gcm2 = 1.95E-3;
34 const
float PolystereneDensity = 1.032;
35 const
float TyleThickness = 1.;
36 const
float dE_1MIP = dE1MIPper_gcm2*PolystereneDensity*TyleThickness;
37 const
float NPhotoelectrons_1MIP = 15.;
38 const
float pC_per_Photoelectron = 0.3;
39 const
short NADCbins = 256;
40 const
short NTDCbins = 256;
41 const
float pC_perADCbin = 0.25;
44 const
float ADC0 = 0.;
45 const
float s_perTDCbin = .1E-9;
46 const
float TDC0 = 0.;
47 const
float OuterFactor = 0.8;
51 const
float SinglePhotoElectronResolution = 0.3;
57 bool IsSmall(
short iPMT)
60 if ( 0<=iPMT && iPMT<NPMTsmall1)
return 1;
61 if ( NPMT1<=iPMT && iPMT<NPMT1+NPMTsmall1)
return 1;
76 BbcTOF():Times(vector<float>(NPMT2)){};
78 void AddTOF(uint16_t ipmt,
float time)
83 if (Times[ipmt]==0 || Times[ipmt]>time) {Times[ipmt]=time;}
90 if (Times[ipmt]!=0.){ tof = Times[ipmt]+BbcRndm.Gaus(0.,BbcTimingRMS); }
96 float T = this->
GetTOF(ipmt);
98 if (T<TDC0) {
return 0;}
99 short N = (short)((T-TDC0)/s_perTDCbin);
100 if (N>=NTDCbins) {
return NTDCbins-1;}
117 BbcDE():dE(vector<float>(NPMT2)){};
119 void AddDE(uint16_t ipmt,
float de)
121 if (!IsSmall(ipmt)) {de *= OuterFactor;}
128 float PoissonMean = dE[ipmt]/dE_1MIP*NPhotoelectrons_1MIP;
129 short NPhotoelectrons = BbcRndm.Poisson(PoissonMean);
130 float Q = pC_per_Photoelectron*
131 (1+BbcRndm.Gaus(0.,SinglePhotoElectronResolution))*
138 float A = this->
GetDE(ipmt);
139 if (A<ADC0) {
return 0;}
140 short N = (short)((A-ADC0)/pC_perADCbin);
141 if (N>=NADCbins) {
return NADCbins-1;}
205 for (
short iew=1; iew<=2; iew++)
209 short EWshift = (2-iew)*NPMT1;
217 Geant2PMT[EW+113] = EWshift+1;
219 Geant2PMT[EW+123] = EWshift+2;
221 Geant2PMT[EW+133] = EWshift+3;
223 Geant2PMT[EW+143] = EWshift+4;
225 Geant2PMT[EW+153] = EWshift+5;
227 Geant2PMT[EW+163] = EWshift+6;
229 Geant2PMT[EW+111] = EWshift+7;
231 Geant2PMT[EW+112] = EWshift+8;
233 Geant2PMT[EW+121] = EWshift+7;
235 Geant2PMT[EW+122] = EWshift+9;
237 Geant2PMT[EW+131] = EWshift+10;
239 Geant2PMT[EW+132] = EWshift+11;
241 Geant2PMT[EW+141] = EWshift+12;
243 Geant2PMT[EW+142] = EWshift+13;
245 Geant2PMT[EW+151] = EWshift+12;
247 Geant2PMT[EW+152] = EWshift+14;
249 Geant2PMT[EW+161] = EWshift+15;
251 Geant2PMT[EW+162] = EWshift+16;
254 Geant2PMT[EW+213] = EWshift+17;
256 Geant2PMT[EW+223] = EWshift+18;
258 Geant2PMT[EW+233] = EWshift+18;
260 Geant2PMT[EW+243] = EWshift+19;
262 Geant2PMT[EW+253] = EWshift+20;
264 Geant2PMT[EW+263] = EWshift+20;
266 Geant2PMT[EW+211] = EWshift+21;
268 Geant2PMT[EW+212] = EWshift+21;
270 Geant2PMT[EW+221] = EWshift+21;
272 Geant2PMT[EW+222] = EWshift+22;
274 Geant2PMT[EW+231] = EWshift+22;
276 Geant2PMT[EW+232] = EWshift+22;
278 Geant2PMT[EW+241] = EWshift+23;
280 Geant2PMT[EW+242] = EWshift+23;
282 Geant2PMT[EW+251] = EWshift+23;
284 Geant2PMT[EW+252] = EWshift+24;
286 Geant2PMT[EW+261] = EWshift+24;
288 Geant2PMT[EW+262] = EWshift+24;
293 QaFile =
new TFile(
"StBbcSimQa.root",
"recreate");
294 QaBbcPmtdE =
new TH1F(
"QaBbcPmtdE",
"BBC PMT",NPMT2,-0.5,NPMT2-0.5);
295 QaBbcPmtTime =
new TH1F(
"QaBbcPmtTime",
"BBC PMT",NPMT2,-0.5,NPMT2-0.5);
297 new TH1F(
"QaBbcEastVid",
"BBC PMT with East VID",256,-0.5,255.5);
299 new TH1F(
"QaBbcWestVid",
"BBC PMT with West VID",256,-0.5,255.5);
301 new TH1F(
"QaBbcEastPmt",
"BBC PMT with East #", 256,-0.5,255.5);
303 new TH1F(
"QaBbcWestPmt",
"BBC PMT with West #", 256,-0.5,255.5);
305 typedef map<short,short>::const_iterator CI;
307 for (CI I=Geant2PMT.begin(); I!=Geant2PMT.end(); ++I)
309 PMT2Geant[(*I).second] = (*I).first;
313 return StMaker::Init();
325 St_g2t_ctf_hit* g2t_bbc_hit = (St_g2t_ctf_hit*)ds->
Find(
"g2t_bbc_hit");
329 short nBBChits = g2t_bbc_hit->GetNRows();
332 g2t_ctf_hit_st *bbc_hit = g2t_bbc_hit->GetTable();
333 for (
short iBBChit=0; iBBChit<nBBChits; iBBChit++)
335 float De = bbc_hit[iBBChit].de;
336 float TOF = bbc_hit[iBBChit].tof;
337 short Vid = bbc_hit[iBBChit].volume_id;
339 short PMTid = Geant2PMT[Vid];
341 LOG_ERROR <<
"Cannot find a PMTid in Geant2PMT for Vid = " << Vid << endm;
345 DEdata.AddDE(PMTid,De);
346 TOFdata.
AddTOF(PMTid,TOF);
351 Warning(
"Make",
" NoStTriggerDetectorCollection, Make the new one\n");
353 event->setTriggerDetectorCollection(myTrig);
358 for (uint16_t iPMT = 0; iPMT<NPMT2; iPMT++)
360 short ADC = DEdata.
GetADC(iPMT);
363 short Vid = PMT2Geant[iPMT+1];
365 if (Vid<2000) {QaBbcWestVid->Fill(ADC);}
366 if (Vid>2000) {QaBbcEastVid->Fill(ADC);}
367 if (iPMT<NPMT1) {QaBbcEastPmt->Fill(ADC);}
368 if (NPMT1<=iPMT && iPMT<NPMT2) {QaBbcWestPmt->Fill(ADC);}
369 QaBbcPmtTime->Fill(iPMT,TOFdata.
GetTOF(iPMT));
370 QaBbcPmtdE->Fill(iPMT,DEdata.
GetDE(iPMT));
372 myBbc.setAdc(iPMT, ADC);
375 short TDC = TOFdata.
GetTDC(iPMT);
376 myBbc.setTdc(iPMT, TDC);
383 (
"MLK StBbcSimulationMaker::Make() could not inst g2t_bbc_hit\n");
virtual Int_t Init()
Init - is a first method the top level StChain calls to initialize all its makers.
void AddTOF(uint16_t ipmt, float time)
short GetTDC(uint16_t ipmt)
virtual ~StBbcSimulationMaker()
This is BbcSimulation destructor.
StBbcSimulationMaker(const char *name="BbcSimulation")
BbcSimulation constructor.
short GetADC(uint16_t ipmt)
float GetTOF(uint16_t ipmt)
float GetDE(uint16_t ipmt)
virtual TDataSet * Find(const char *path) const