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;
58 const
short ADCBin = 4096;
60 const
float LightFactor[NPMT2] = {1., 1., 0.95, 0.92, 1., 1., 1., 1., 0.9, 0.96, 0.95, 1., 0.95, 0.97, 1., 1.,
61 0.33, 0.298, 0.25, 0.26, 0.22, 0.4, 0.24, 0.26,
62 1.2, 0.9, 1., 0.6, 1., 1., 1.2, 1.2, 1.25, 0.4, 1., 1., 0.95, 0.95, 0.94, 0.95,
63 0., 0.243, 0., 0.2, 0.24, 0.18, 0.19, 0.2};
65 const float TileResolution[NPMT2] = {0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
66 0.6, 0.6, 0.4, 0.5, 0.5, 0.6, 0.4, 0.5,
67 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.5, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
68 0., 0.5, 0., 0.5, 0.6, 0.6, 0.4, 0.65};
70 const float pC_per_ADCBins[NPMT2] = {0.03, 0.03, 0.033, 0.033, 0.03, 0.03, 0.022, 0.03, 0.021, 0.022, 0.024, 0.03, 0.024, 0.024, 0.025, 0.027,
71 0.0226, 0.028, 0.021, 0.023, 0.014, 0.0125, 0.012, 0.0125,
72 0.031, 0.03, 0.03, 0.018, 0.03, 0.03, 0.023, 0.024, 0.028, 0.005, 0.03, 0.03, 0.028, 0.023, 0.022, 0.028,
73 0., 0.027, 0., 0.06, 0.013, 0.014, 0.0129, 0.02};
75 const int shift_ADC0[NPMT2] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, -15, 0, -15, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, -60, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, -10, -7, -15, -10};
82 bool IsSmall(
short iPMT)
85 if ( 0<=iPMT && iPMT<NPMTsmall1)
return 1;
86 if ( NPMT1<=iPMT && iPMT<NPMT1+NPMTsmall1)
return 1;
101 BbcTOF():Times(vector<float>(NPMT2)){};
108 if (Times[ipmt]==0 || Times[ipmt]>time) {Times[ipmt]=time;}
115 if (Times[ipmt]!=0.){ tof = Times[ipmt]+BbcRndm.Gaus(0.,BbcTimingRMS); }
121 float T = this->
GetTOF(ipmt);
123 if (T<TDC0) {
return 0;}
124 short N = (short)((T-TDC0)/s_perTDCbin);
125 if (N>=NTDCbins) {
return NTDCbins-1;}
142 BbcDE():dE(vector<float>(NPMT2)){};
144 void AddDE(uint16_t ipmt,
float de)
146 de *= LightFactor[ipmt];
152 float PoissonMean = dE[ipmt]/dE_1MIP*NPhotoelectrons_1MIP;
153 short NPhotoelectrons = BbcRndm.Poisson(PoissonMean);
154 float Q = pC_per_Photoelectron*
155 (1+BbcRndm.Gaus(0.,TileResolution[ipmt]))*NPhotoelectrons;
161 float A = this->
GetDE(ipmt);
162 short N = (short)(A/pC_per_ADCBins[ipmt] + shift_ADC0[ipmt]);
163 if (N>=ADCBin) {
return ADCBin-1;}
228 for (
short iew=1; iew<=2; iew++)
232 short EWshift = (2-iew)*NPMT1;
240 Geant2PMT[EW+113] = EWshift+1;
242 Geant2PMT[EW+123] = EWshift+2;
244 Geant2PMT[EW+133] = EWshift+3;
246 Geant2PMT[EW+143] = EWshift+4;
248 Geant2PMT[EW+153] = EWshift+5;
250 Geant2PMT[EW+163] = EWshift+6;
252 Geant2PMT[EW+111] = EWshift+7;
254 Geant2PMT[EW+112] = EWshift+8;
256 Geant2PMT[EW+121] = EWshift+7;
258 Geant2PMT[EW+122] = EWshift+9;
260 Geant2PMT[EW+131] = EWshift+10;
262 Geant2PMT[EW+132] = EWshift+11;
264 Geant2PMT[EW+141] = EWshift+12;
266 Geant2PMT[EW+142] = EWshift+13;
268 Geant2PMT[EW+151] = EWshift+12;
270 Geant2PMT[EW+152] = EWshift+14;
272 Geant2PMT[EW+161] = EWshift+15;
274 Geant2PMT[EW+162] = EWshift+16;
277 Geant2PMT[EW+213] = EWshift+17;
279 Geant2PMT[EW+223] = EWshift+18;
281 Geant2PMT[EW+233] = EWshift+18;
283 Geant2PMT[EW+243] = EWshift+19;
285 Geant2PMT[EW+253] = EWshift+20;
287 Geant2PMT[EW+263] = EWshift+20;
289 Geant2PMT[EW+211] = EWshift+21;
291 Geant2PMT[EW+212] = EWshift+21;
293 Geant2PMT[EW+221] = EWshift+21;
295 Geant2PMT[EW+222] = EWshift+22;
297 Geant2PMT[EW+231] = EWshift+22;
299 Geant2PMT[EW+232] = EWshift+22;
301 Geant2PMT[EW+241] = EWshift+23;
303 Geant2PMT[EW+242] = EWshift+23;
305 Geant2PMT[EW+251] = EWshift+23;
307 Geant2PMT[EW+252] = EWshift+24;
309 Geant2PMT[EW+261] = EWshift+24;
311 Geant2PMT[EW+262] = EWshift+24;
316 QaFile =
new TFile(
"StBbcSimQa.root",
"recreate");
317 QaBbcPmtdE =
new TH1F(
"QaBbcPmtdE",
"BBC PMT",NPMT2,-0.5,NPMT2-0.5);
318 QaBbcPmtTime =
new TH1F(
"QaBbcPmtTime",
"BBC PMT",NPMT2,-0.5,NPMT2-0.5);
320 new TH1F(
"QaBbcEastVid",
"BBC PMT with East VID",256,-0.5,255.5);
322 new TH1F(
"QaBbcWestVid",
"BBC PMT with West VID",256,-0.5,255.5);
324 new TH1F(
"QaBbcEastPmt",
"BBC PMT with East #", 256,-0.5,255.5);
326 new TH1F(
"QaBbcWestPmt",
"BBC PMT with West #", 256,-0.5,255.5);
328 typedef map<short,short>::const_iterator CI;
330 for (CI I=Geant2PMT.begin(); I!=Geant2PMT.end(); ++I)
332 PMT2Geant[(*I).second] = (*I).first;
336 return StMaker::Init();
348 St_g2t_ctf_hit* g2t_bbc_hit = (St_g2t_ctf_hit*)ds->
Find(
"g2t_bbc_hit");
352 short nBBChits = g2t_bbc_hit->GetNRows();
355 g2t_ctf_hit_st *bbc_hit = g2t_bbc_hit->GetTable();
356 for (
short iBBChit=0; iBBChit<nBBChits; iBBChit++)
358 float De = bbc_hit[iBBChit].de;
359 float TOF = bbc_hit[iBBChit].tof;
360 short Vid = bbc_hit[iBBChit].volume_id;
362 short PMTid = Geant2PMT[Vid];
364 LOG_ERROR <<
"Cannot find a PMTid in Geant2PMT for Vid = " << Vid << endm;
368 DEdata.AddDE(PMTid,De);
369 TOFdata.
AddTOF(PMTid,TOF);
374 Warning(
"Make",
" NoStTriggerDetectorCollection, Make the new one\n");
376 event->setTriggerDetectorCollection(myTrig);
381 for (uint16_t iPMT = 0; iPMT<NPMT2; iPMT++)
383 short ADC = DEdata.
GetADC(iPMT);
386 short Vid = PMT2Geant[iPMT+1];
388 if (Vid<2000) {QaBbcWestVid->Fill(ADC);}
389 if (Vid>2000) {QaBbcEastVid->Fill(ADC);}
390 if (iPMT<NPMT1) {QaBbcEastPmt->Fill(ADC);}
391 if (NPMT1<=iPMT && iPMT<NPMT2) {QaBbcWestPmt->Fill(ADC);}
392 QaBbcPmtTime->Fill(iPMT,TOFdata.
GetTOF(iPMT));
393 QaBbcPmtdE->Fill(iPMT,DEdata.
GetDE(iPMT));
395 myBbc.setAdc(iPMT, ADC);
398 short TDC = TOFdata.
GetTDC(iPMT);
399 myBbc.setTdc(iPMT, TDC);
406 (
"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