BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofDigitizerEcV3.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2//// BOOST --- BESIII Object_Oriented Simulation Tool //
3////---------------------------------------------------------------------------//
4////Description: Utilize Geant4 full simulation results
5////Author: liuy
6////Created: Oct, 2008
7////Modified:Dec, 2008
8////Comment:
9////---------------------------------------------------------------------------//
10////$Id: BesTofDigitizerEcV3.cc
11
12#include "BesTofDigitizerEcV3.hh"
13#include "BesTofHit.hh"
14#include "G4DigiManager.hh"
15#include "G4RunManager.hh"
16#include "Randomize.hh"
17#include "G4Poisson.hh"
18#include "BesTofDigi.hh"
19#include "BesTofGeoParameter.hh"
20#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/Bootstrap.h"
22#include "GaudiKernel/IDataProviderSvc.h"
23#include "G4Svc/IG4Svc.h"
24#include "G4Svc/G4Svc.h"
25#include "TH1F.h"
26#include "TNtuple.h"
27#include "TFile.h"
28#include "TMath.h"
29#include <unistd.h> // Check the file
30
32{
33 ReadData(); //Get some basic data (not Hit data, but information about smearing from electronics,... )
34 m_timeBinSize = 0.005;
35
36
37
38
39 // Simulation/G4Svc/G4Svc-00-01-47/src/G4Svc.cpp
40 //Get the basic parameters from the event: Starttime, Beamposition,...
41
42 //retrieve G4Svc
43 ISvcLocator* svcLocator = Gaudi::svcLocator();
44 IG4Svc* tmpSvc;
45 StatusCode sc = svcLocator->service("G4Svc", tmpSvc);
46 if(!sc.isSuccess())
47 {
48 std::cout << " Could not initialize Realization Service in BesTofDigitizerBrV2" << std::endl;
49 }
50 else
51 {
52 m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc);
53 }
54
55 //retrieve RealizationSvc
56 IRealizationSvc *tmpReal;
57 StatusCode scReal = svcLocator->service("RealizationSvc",tmpReal);
58 if (!scReal.isSuccess())
59 {
60 std::cout << " Could not initialize Realization Service in BesTofDigitizerEcV3" << std::endl;
61 }
62 else
63 {
64 m_RealizationSvc = dynamic_cast<RealizationSvc*>(tmpReal);
65 }
66
67
68
69 for(int i=0;i<50;i++)
70 {
71 for(int j=0;j<10;j++)
72 {
73 for(int k=0;k<10;k++)
74 {
75 for(int m=0;m<num1;m++) // num1 bin number in histogram is 400 at the moment
76 {
77 //G4cout << "time:" << propTime[i][j][k][m] << "; prob:" << prob[i][j][k][m] << "; eff:" << eff[i][j][k] << G4endl;
78 propTime[i][j][k][m] = 0;
79 prob[i][j][k][m] = 0;
80 eff[i][j][k] = 0;
81 }
82 }
83 }
84 }
85
87 G4cout << "ETofSim: Reading nTuples of is completed." << G4endl;
88}
89
91{
93
94 m_ecR1 = tofPara->GetEcR1();
95 m_tau1Ec = tofPara->GetTau1Ec();
96 m_tau2Ec = tofPara->GetTau2Ec();
97 m_tau3Ec = tofPara->GetTau3Ec();
98 m_tauRatioEc = tofPara->GetTauRatioEc();
99 m_refIndexEc = tofPara->GetRefIndexEc();
100 m_phNConstEc = tofPara->GetPhNConstEc();
101 m_Cpe2pmtEc = tofPara->GetCpe2pmtEc();
102 m_rAngleEc = tofPara->GetRAngleEc();
103 m_QEEc = tofPara->GetQEEc();
104 m_CEEc = tofPara->GetCEEc();
105 m_peCorFacEc = tofPara->GetPeCorFacEc();
106 m_attenEc = tofPara->GetAttenEc();
107
108 m_ttsMeanEc = tofPara->GetTTSmeanEc();
109 m_ttsSigmaEc = tofPara->GetTTSsigmaEc();
110 m_PMTgainEc = tofPara->GetPMTgainEc();
111 m_CeEc = tofPara->GetCeEc();
112 m_riseTimeEc = tofPara->GetRiseTimeEc();
113 m_LLthreshEc = tofPara->GetLLthreshEc();
114 m_HLthreshEc = tofPara->GetHLthreshEc();
115 m_preGainEc = tofPara->GetPreGainEc();
116 m_noiseSigmaEc = tofPara->GetNoiseSigmaEc();
117
118 //G4cout << "m_LLthreshEc:" << m_LLthreshEc << "; m_HLthreshEc:" << m_HLthreshEc << G4endl;
119
120}
121
122//I do not know what the following function read!
124{
125 int rBin,phiBin,zBin;
126 const int nR = 43;
127 const int nPhi = 6;
128 const int nZ = 6;
129 float efficiency0,x[400],y[400];
130
131
132 G4String dataPath = getenv("TOFSIMROOT");
133 if(!dataPath)
134 {
135 G4Exception("Boss environment is not set!");
136 }
137
138 char treePath[200];
139 G4int runId = m_RealizationSvc->getRunId();
140 if(runId>=-80000 && runId<=-9484)
141 {
142 // After TOF HV adjustment, endcap attenL was set to 5000mm.
143 sprintf(treePath,"%s/dat/effTree_1600mm.root",dataPath.c_str());
144 }
145 else
146 {
147 //Before TOF HV adjustment, endcap attenL was set to 1600mm.
148 sprintf(treePath,"%s/dat/effTree_1600mm.root",dataPath.c_str());
149 }
150
151 TFile *f = new TFile(treePath, "read");
152 TTree *t = (TTree*)f->Get("effTree");
153
154 t->SetBranchAddress("rBin", &rBin);
155 t->SetBranchAddress("phiBin", &phiBin);
156 t->SetBranchAddress("zBin", &zBin);
157 t->SetBranchAddress("efficiency0", &efficiency0);
158 t->SetBranchAddress("x", x);
159 t->SetBranchAddress("y", y);
160
161 int r,phi,z;
162 for (Int_t i = 0; i < nR*nPhi*nZ; i++){
163 t->GetEntry(i);
164 r = rBin;
165 phi = phiBin;
166 z = zBin;
167 eff[r][phi][z] = efficiency0;
168 for (Int_t j = 0; j < 400; j++){
169 propTime[r][phi][z][j] = x[j];
170 prob[r][phi][z][j] = y[j];
171 //cout << "\n" << propTime[r][phi][z][j] << " " << prob[r][phi][z][j] << endl;
172 }
173 }
174
175}
176
178{;}
179
181{
182 m_beamTime = m_G4Svc->GetBeamTime() * ns;
184
185 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
186
187 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
188 m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID));
189
190 if (m_G4Svc->TofRootFlag())
191 {
192 m_eTotal = 0;
193 m_nDigi = 0;
194 m_partIdMPV = -9;
195 m_scinNbMPV = -9;
196 m_edepMPV = 0;
197 m_nDigiOut = 0;
198 }
199
200 if (m_THC)
201 {
202 //for each digi, compute TDC and ADC
203 G4int partId, scinNb, nHits;
204 G4double edep;
205 BesTofHit* hit;
206 partId=scint->GetPartId();
207 scinNb=scint->GetScinNb();
208 edep = scint->GetEdep();
209 nHits=scint->GetHitIndexes()->size();
210
211 TofPmtInit();
212
213 //fill tof Ntuple
214 if (m_G4Svc->TofRootFlag())
215 {
216 if (edep>m_edepMPV)
217 {
218 m_partIdMPV = partId;
219 m_scinNbMPV = scinNb;
220 m_edepMPV = edep;
221 }
222 m_eTotal += edep;
223 m_nDigi ++;
224
225 m_partId = partId;
226 m_scinNb = scinNb;
227 m_edep = edep;
228 m_nHits = nHits;
229 }
230
231 if (edep>0.01)
232 {
233 for (G4int j=0;j<nHits;j++)
234 {
235 hit= (*m_THC)[( *(scint->GetHitIndexes()) )[j]];
236 TofPmtAccum(hit);
237 }
238
239 if (m_G4Svc->TofRootFlag())
240 {
241 m_time1st0=m_t1st[0];
242 m_time1st1=m_t1st[1];
243 m_timelast0=m_tLast[0];
244 m_timelast1=m_tLast[1];
245 m_totalPhot0=m_totalPhot[0];
246 m_totalPhot1=m_totalPhot[1];
247 }
248
249 //get final tdc and adc
250 TofPmtRspns(partId,scinNb);
251
252 G4double temp0 = m_ADC[0]+m_TDC[0];
253 G4double temp1 = m_ADC[1]+m_TDC[1];
254 //const double MAX_ADC = 8191*0.3; // channel set up to 8192 will lead to overflow.
255 if ( (partId!=1) && temp0>0. )
256 {
257 BesTofDigi* digi = new BesTofDigi;
259 digi->SetPartId(partId);
260 digi->SetScinNb(scinNb);
261 digi->SetForwADC( m_ADC[0]) ;
262 digi->SetBackADC( m_ADC[1]) ;
263 if (m_TDC[0]>0.)
264 m_TDC[0] = m_TDC[0]+m_beamTime;
265 digi->SetForwTDC( m_TDC[0]) ;
266 digi->SetBackTDC( m_TDC[1]) ;
267
268 //G4cout << "BesTofDigitizerEcV3: ForwTDC | BackTDC " << m_TDC[0] << " | " << m_TDC[1] << G4endl;
269 //G4cout<<"endcap\nadc0:"<<m_ADC[0]<<"; adc1:"<<m_ADC[1]<<"; tdc0:"<<m_TDC[0]<<"; tdc1:"<<m_TDC[1]<<G4endl;
270 m_besTofDigitsCollection->insert(digi);
271 if (m_G4Svc->TofRootFlag() )
272 m_nDigiOut++;
273 }
274 if (m_G4Svc->TofRootFlag() )
275 m_tupleTof1->write();
276 //cout << "m_tupleTof1->write()" << endl;
277 }
278
279 }
280 if (m_G4Svc->TofRootFlag())
281 m_tupleTof2->write();
282 //cout << "m_tupleTof2->write()" << endl;
283
284}
285
287{
288 m_ADC[0] = -999.;
289 m_ADC[1] = -999.;
290 m_TDC[0] = -999.;
291 m_TDC[1] = -999.;
292 m_trackIndex = -999;
293 m_globalTime = 9999;
294
295 m_t1st[0]=100;
296 m_t1st[1]=100;
297 m_tLast[0]=0.;
298 m_tLast[1]=0;
299 m_totalPhot[0]=0;
300 m_totalPhot[1]=0;
301 for (G4int i=0;i<2;i++)
302 for (G4int j=0;j<m_profBinNEcV3;j++)
303 m_nPhot[j][i]=0;
304
305 if (m_G4Svc->TofRootFlag())
306 {
307 m_partId = -9;
308 m_scinNb = -9;
309 m_edep = 0;
310 m_nHits = 0;
311 m_time1st0 = 100;
312 m_time1st1 = 100;
313 m_timelast0 = 0;
314 m_timelast1 = 0;
315 m_totalPhot0 = 0;
316 m_totalPhot1 = 0;
317 m_NphAllSteps = 0;
318 m_max0 = 0;
319 m_max1 = 0;
320 m_tdc0 = -999;
321 m_adc0 = -999;
322 m_tdc1 = -999;
323 m_adc1 = -999;
324 }
325
326}
327
329{
330 G4double cvelScint = c_light/m_refIndexEc;
331 //Get information of this step
332 G4ThreeVector pos = hit->GetPos();
333 G4int trackIndex = hit->GetTrackIndex();
334 G4int partId = hit->GetPartId();
335 G4double edep = hit->GetEdep();
336 G4double stepL = hit->GetStepL();
337 //G4String particleName = hit->GetPName();
338 G4double deltaT=hit->GetDeltaT();
339 G4double timeFlight=hit->GetTime()-m_beamTime;
340 if (timeFlight < m_globalTime)
341 {
342 m_globalTime = timeFlight;
343 m_trackIndex = trackIndex;
344 }
345
346 G4ThreeVector pDirection=hit->GetPDirection();
347 G4double nx=pDirection.x();
348 G4double ny=pDirection.y();
349 G4double nz=pDirection.z();
350
351
352 //number of photons generated in this step
353 G4int NphStep;
354 G4double nMean, nPhoton;
355 nMean = m_phNConstEc*BirksLaw(hit);
356
357 if(nMean>10)
358 {
359 G4double resolutionScale=1.;
360 G4double sigma=resolutionScale*sqrt(nMean);
361 nPhoton=G4int(G4RandGauss::shoot(nMean,sigma)+0.5);
362 }
363 else
364 nPhoton=G4int(G4Poisson(nMean));
365
366
367 NphStep=G4int(nPhoton*0.66*m_QEEc*m_CEEc);
368 //G4cout << "\nradius:" << radius << "; phi:" << phi << "; z:" << z << G4endl;
369 //G4cout << "\nrBin:" << rBin << ";phiBin:" << phiBin << ";zBin" << zBin << G4endl;
370
371 if (m_G4Svc->TofRootFlag())
372 m_NphAllSteps += G4int(nPhoton*0.66*m_QEEc*m_CEEc);
373
374 if (NphStep>0)
375 {
376 for (G4int i=0;i<NphStep;i++)
377 {
378 //uniform scintilation in each step
379 G4double ddS, ddT;
380 ddS=stepL*G4UniformRand();
381 ddT=deltaT*G4UniformRand();
382 G4ThreeVector emtPos;
383 emtPos.setX(pos.x() + nx*ddS);
384 emtPos.setY(pos.y() + ny*ddS);
385 emtPos.setZ(pos.z() + nz*ddS);
386
387 //retrieve the histogram info
388 G4double radius = sqrt(emtPos.x()*emtPos.x()+emtPos.y()*emtPos.y())-m_ecR1;
389 const G4double pie = 2.*asin(1.);
390 G4double phi;
391 if(emtPos.x()>0 && emtPos.y()>0)
392 phi = atan(emtPos.y()/emtPos.x());
393 else if(emtPos.x()==0 && emtPos.y()>0)
394 phi = pie/2.;
395 else if(emtPos.x()<0)
396 phi = atan(emtPos.y()/emtPos.x())+pie;
397 else if(emtPos.x()==0 && emtPos.y()<0)
398 phi = 1.5*pie;
399 else if(emtPos.x()>0 && emtPos.y()<0)
400 phi = 2.*pie+atan(emtPos.y()/emtPos.x());
401 phi = phi*180./pie; // in degrees
402 G4double z = fabs(emtPos.z());
403 // Warning: Should obtain absolute value of z to determine zBinNum
404
405 G4int rBin = G4int(radius/10.); // radius bin no.
406 G4double resPhi = phi-(G4int(phi/7.5)*7.5); // residual of phi in period of 7.5
407 G4int phiBin = G4int(resPhi/1.25);
408 G4int zBin = G4int((z-1332.)/8.);
409
410 //check scinillation light whether to hit the pmt or not
411 //forb=0/1 for forward(z>0, east) and backward(z<0, west)
412 G4int forb = 0;
413 G4double transpTime = 0;
414 G4double pathL = 0;
415 G4double efficiency1;
416 G4double efficiency2;
417 efficiency1 = G4RandGauss::shoot(0,0.004);
418 if(rBin>=0&&rBin<=nR && phiBin>=0&& phiBin<=nPhi && zBin>=0&&zBin<=nZ)
419 efficiency1 += eff[rBin][phiBin][zBin];
420 else
421 efficiency1 = 0;
422 //G4cout << "FATAL: The collection efficiency does NOT exist!" << G4endl;
423 if(m_attenEc==0)
424 {
425 G4cout <<" ERROR: Attenuation Length is null!" << G4endl;
426 break;
427 }
428 //efficiency2 = pow(efficiency1,(1600/m_attenEc));
429 if(G4UniformRand() <= efficiency1)
430 {
431 DirectPh(rBin, phiBin, zBin, transpTime);
432 //cout << "transpTime:" << transpTime << endl;
433 }
434
435 //check if photon can reach PMT or not, after attenuation
436 //G4double ran = G4UniformRand();
437 //pathL = transpTime*cvelScint;
438 //if (pathL>0 && exp(-pathL/m_attenEc) > ran) // Note: Do NOT double count attuation!
439 if(transpTime>0)
440 {
441 //propagation time in scintillator
442 G4double scinSwim = transpTime;
443 //scintillation timing
444 G4double scinTime = Scintillation(partId);
445
446 //PMT transit time
447 G4double transitTime = TransitTime();
448 //sum up all time components
449 G4double endTime = timeFlight + ddT + scinSwim + scinTime + transitTime;
450
451 if (m_G4Svc->TofRootFlag())
452 {
453 //m_forb = forb;
454 m_timeFlight = timeFlight+ddT;
455 m_ddT = ddT;
456 m_scinSwim = scinSwim;
457 m_scinTime = scinTime;
458 m_transitTime = transitTime;
459 m_endTime = endTime;
460 m_tupleTof3->write();
461 }
462
463 //store timing into binned buffer
464 AccuSignal(endTime, forb);
465
466 //update 1st and last timings here
467 if (m_t1st[forb]>endTime) m_t1st[forb] = endTime;
468 if (m_tLast[forb]<endTime) m_tLast[forb]= endTime;
469 //if(m_tLast[0]>100)
470 //std::cout<<"endTime: "<<endTime<<std::endl;
471 }
472 }
473 }
474}
475
477{
478 const G4double kappa = 0.015*cm/MeV;
479 const G4String brMaterial = "BC404";
480 G4double dE = hit->GetEdep();
481 //G4cout << "The edep is "<< dE << G4endl;
482 G4double dX = hit->GetStepL();
483 //G4Material* materiral = hit->GetMaterial();
484 G4double charge = hit->GetCharge();
485 G4double cor_dE = dE;
486 //if((materiral->GetName()==brMaterial) && charge!=0.&& dX!=0.)
487 if(charge!=0.&& dX!=0.)
488 {
489 cor_dE = dE/(1+kappa*dE/dX);
490 //if(dE>20)
491 //{
492 // G4cout << "\n dE > 20. Details are below:" << G4endl;
493 // G4cout << "dE/dx:" << dE/dX << G4endl;
494 // G4cout << "dE:" << dE << "; dX:" << dX << G4endl;
495 // G4cout << "It is BC404. cor_dE is " << cor_dE << G4endl;
496 // G4double ratio = cor_dE/dE;
497 // G4cout << "The ratio cor_dE/edep is "<< ratio << G4endl;
498 //}
499 //G4cout << "It is BC408. cor_dE is " << cor_dE << G4endl;
500 //G4double ratio = cor_dE/dE;
501 //G4cout << "The ratio cor_dE/edep is "<< ratio << G4endl;
502 }
503 return cor_dE;
504
505}
506
507void BesTofDigitizerEcV3::DirectPh(G4int rBin, G4int phiBin, G4int zBin, G4double& t)
508{
509 G4double ran = G4UniformRand();
510 G4double p = 0;
511 G4int nth = 1;
512 G4int key = 0;
513 t = 0;
514 while(1)
515 {
516 if(p>ran||nth==400)
517 {
518 key = nth;
519 //G4cout << "Value found!" << G4endl;
520 break;
521 }
522 p = p + prob[rBin][phiBin][zBin][nth];
523 nth++;
524 }
525 t = propTime[rBin][phiBin][zBin][key-1];
526}
527
529{
530 G4double tmp_tauRatio,tmp_tau1,tmp_tau2,tmp_tau3;
531 tmp_tauRatio = m_tauRatioEc;
532 tmp_tau1 = m_tau1Ec;
533 tmp_tau2 = m_tau2Ec;
534 tmp_tau3 = m_tau3Ec;
535
536 G4double UniformR = tmp_tauRatio/(1+tmp_tauRatio);
537 G4double EmissionTime;
538 if (G4UniformRand()>UniformR) {
539 while (1) {
540 EmissionTime = -tmp_tau2*log( G4UniformRand() );
541 if (G4UniformRand()-exp(EmissionTime/tmp_tau2-EmissionTime/tmp_tau1)>1.E-8)
542 break;
543 }
544 }
545 else EmissionTime = -tmp_tau3*log( G4UniformRand() );
546 return EmissionTime;
547}
548
550{
551 //get time transit spread
552 //G4cout << "TTS mean:" << m_ttsMeanEc << "; " << m_ttsSigmaEc << G4endl;
553 return G4RandGauss::shoot(m_ttsMeanEc,m_ttsSigmaEc);
554}
555
556void BesTofDigitizerEcV3::AccuSignal(G4double endTime, G4int forb)
557{
558 G4int ihst;
559 ihst=G4int(endTime/m_timeBinSize);
560 if (ihst>0 &&ihst<m_profBinNEcV3)
561 {
562 m_nPhot[ihst][forb]=m_nPhot[ihst][forb]+1;
563 m_totalPhot[forb]=m_totalPhot[forb]+1;
564 }
565}
566
567void BesTofDigitizerEcV3::TofPmtRspns(G4int partId, G4int scinNb)
568{
569 //to generate PMT signal shape for single photoelectron.
570 //only one time for a job.
571 static G4double snpe[m_snpeBinNEcV3];
572 static G4int istore_snpe=-1;
573
574 //Model: f(t)=Gain*mv_1pe* t**2 * exp-(t/tau)**2/normal-const
575 //normalization const =sqrt(pi)*tau*tau*tau/4.0
576 G4double tau = m_riseTimeEc;
577 G4double norma_const=sqrt(M_PI)*tau*tau*tau/4.0; //in unit of ns**3
578 G4double echarge=1.6e-7; //in unit of PC
579
580 //time profile of pmt signals for Back and Forward PMT.
581 G4double profPmt[m_profBinNEcV3][2];
582
583 G4double t;
584 G4int n1, n2, ii;
585 G4int phtn;
586
587 if (istore_snpe<0)
588 {
589 istore_snpe = 1;
590 for (G4int i=0;i<m_snpeBinNEcV3;i++)
591 {
592 t=(i+1)*m_timeBinSize;
593 snpe[i]=m_CeEc*t*t*exp(- (t/tau) * (t/tau) )/norma_const;
594 }
595 }
596 //for barrel and endcap tof: fb=2 or 1
597 G4int fb=1; // for endcap part
598
599 G4double tmpADC[2] = {0,0};
600
601 for (G4int j=0; j<fb; j++)
602 {
603 if (m_totalPhot[j] > 0)
604 {
605 n1=G4int(m_t1st[j]/m_timeBinSize);
606 n2=G4int(m_tLast[j]/m_timeBinSize);
607
608 for (G4int i=0;i<m_profBinNEcV3;i++)
609 profPmt[i][j]=0.0;
610
611 //generate PMT pulse
613 for (G4int i=n1;i<n2;i++)
614 {
615 phtn=m_nPhot[i][j];
616 if (phtn>0)
617 {
618 G4double Npoisson;
619 while(1) {
620 Npoisson=G4Poisson(10.0);
621 if(Npoisson>0) break;
622 }
623 G4double tmpPMTgain;
624 while(1) {
625 m_PMTgainEc = m_tofSimSvc->EndPMTGain();
626 tmpPMTgain=G4RandGauss::shoot(m_PMTgainEc,m_PMTgainEc/sqrt(Npoisson));
627 //tmpPMTgain = m_PMTgainEc;
628 if(tmpPMTgain>0) break;
629 }
630 tmpADC[j]+=phtn*tmpPMTgain;
631
632 for (G4int ihst=0; ihst<m_snpeBinNEcV3; ihst++)
633 {
634 ii=i+ihst;
635 if (ii<m_profBinNEcV3)
636 profPmt[ii][j] += tmpPMTgain*phtn*snpe[ihst];
637 else
638 break;
639 }
640 }
641 }
642
643 //add preamplifier and noise
644 for (int i=0;i<m_profBinNEcV3;i++)
645 {
646 if (profPmt[i][j]>0)
647 profPmt[i][j] = m_preGainEc*profPmt[i][j]+G4RandGauss::shoot(0,m_noiseSigmaEc);
648 }
649
650 //get pulse height
651 G4double max=0;
652 for (int i=n1;i<m_profBinNEcV3;i++)
653 {
654 if (profPmt[i][j]>max)
655 max=profPmt[i][j];
656 }
657 if (m_G4Svc->TofRootFlag())
658 {
659 if (j==0) m_max0=max;
660 else m_max1=max;
661 }
662
663
664 G4double tmp_HLthresh, tmp_LLthresh, ratio;
665
666// G4int runId = m_RealizationSvc->getRunId();
667// if(runId>=-80000 && runId<=-9484)
668// {
669// // After TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 5.E5
670// // High/Low Threshold for barrel: 500/125 mV
671// tmp_HLthresh = m_HLthreshEc;
672// tmp_LLthresh = m_LLthreshEc;
673// }
674// else
675// {
676// // Before TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 2.5E5
677// // High/Low Threshold for barrel: 600/150 mV
678// tmp_HLthresh = 800;
679// tmp_LLthresh = 200;
680// }
681
682 G4double adcFactor = 3.35;
683// double ratio;
684// if (runId>=-80000 && runId<=-9484)
685// {
686// ratio = 1.22*1354.4/1282.1;
687// }
688// else
689// {
690// ratio = 1.77*2028.8/1931.4;
691// }
692
693 tmp_HLthresh = m_tofSimSvc->EndHighThres();
694 tmp_LLthresh = m_tofSimSvc->EndLowThres();
695 ratio = m_tofSimSvc->EndConstant();
696
697 //get final tdc and adc
698 if (max>=tmp_HLthresh)
699 {
700 for (int i=0;i<m_profBinNEcV3;i++)
701 {
702 if ( profPmt[i][j] >= tmp_LLthresh )
703 {
704 m_TDC[j] = i*m_timeBinSize + G4RandGauss::shoot(0,0.025); // Adding Electronical Uncertainty of 25ps
705 G4double NoiseSigma;
706 G4int EndNoiseSwitch = int(m_tofSimSvc->EndNoiseSwitch());
707 //std::cout << " EndNoiseSwitch = " << EndNoiseSwitch << std::endl;
708 switch (EndNoiseSwitch) {
709 case 0:
710 NoiseSigma = 0.;
711 break;
712 case 1:
713 if (partId==0) { NoiseSigma = m_tofSimSvc->EndNoiseSmear(scinNb); }
714 if (partId==2) { NoiseSigma = 0.; }
715 break;
716 case 2:
717 if (partId==0) { NoiseSigma = m_tofSimSvc->EndNoiseSmear(scinNb); }
718 if (partId==2) { NoiseSigma = m_tofSimSvc->EndNoiseSmear(scinNb+48.); }
719 break;
720 }
721 //std::cout << "ID : " << scinNb + 48.*partId/2. << " Sigma : " << NoiseSigma << std::endl;
722 m_TDC[j] = m_TDC[j] + G4RandGauss::shoot(0,NoiseSigma); // Adding Endcap Noise Smear
723
724 //use the saturation curve
725
726 if( m_G4Svc->TofSaturationFlag())
727 {
728 double x = tmpADC[j]*m_preGainEc*echarge*ratio;
729 int id;
730 if (partId==0) { id = scinNb;}
731 if (partId==2) { id = scinNb+48;}
732
733 m_ADC[j] = m_tofQElecSvc->EQChannel(id,x);
734 }
735 else
736 m_ADC[j] = tmpADC[j]*m_preGainEc*echarge*adcFactor;
737
738 if (m_G4Svc->TofRootFlag())
739 {
740 if (j==0) {
741 m_tdc0 = m_TDC[0];
742 m_adc0 = m_ADC[0];
743 }
744 else {
745 m_tdc1 = m_TDC[1];
746 m_adc1 = m_ADC[1];
747 }
748 }
749 break;
750 }
751 }
752 }
753 }
754 }
755}
756
Double_t x[10]
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
G4THitsCollection< BesTofHit > BesTofHitsCollection
int n2
Definition: SD0Tag.cxx:55
int n1
Definition: SD0Tag.cxx:54
#define M_PI
Definition: TConstant.h:4
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42
void DirectPh(G4int, G4int, G4int, G4double &)
G4double Scintillation(G4int)
void AccuSignal(G4double, G4int)
void TofPmtRspns(G4int, G4int)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
void TofPmtAccum(BesTofHit *)
G4double BirksLaw(BesTofHit *hit)
static BesTofGeoParameter * GetInstance()
virtual const double EQChannel(int id, double q)=0
virtual const double EndConstant()=0
virtual const double EndPMTGain()=0
virtual const double EndNoiseSmear(unsigned int id)=0
virtual const double EndNoiseSwitch()=0
virtual const double EndLowThres()=0
virtual const double EndHighThres()=0
int t()
Definition: t.c:1
#define ns(x)
Definition: xmltok.c:1504