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