BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofDigitizerEcV2 Class Reference

#include <BesTofDigitizerEcV2.hh>

Inheritance diagram for BesTofDigitizerEcV2:

Public Member Functions

 BesTofDigitizerEcV2 ()
 ~BesTofDigitizerEcV2 ()
virtual void Digitize (ScintSingle *, BesTofDigitsCollection *)
void ReadData ()
void TofPmtInit ()
void TofPmtAccum (BesTofHit *)
void DirectPh (G4int, G4ThreeVector, G4double &, G4int &)
G4double Scintillation (G4int)
G4double TransitTime ()
void AccuSignal (G4double, G4int)
void TofPmtRspns (G4int)
 BesTofDigitizerEcV2 ()
 ~BesTofDigitizerEcV2 ()
virtual void Digitize (ScintSingle *, BesTofDigitsCollection *)
void ReadData ()
void TofPmtInit ()
void TofPmtAccum (BesTofHit *)
void DirectPh (G4int, G4ThreeVector, G4double &, G4int &)
G4double Scintillation (G4int)
G4double TransitTime ()
void AccuSignal (G4double, G4int)
void TofPmtRspns (G4int)
 BesTofDigitizerEcV2 ()
 ~BesTofDigitizerEcV2 ()
virtual void Digitize (ScintSingle *, BesTofDigitsCollection *)
void ReadData ()
void TofPmtInit ()
void TofPmtAccum (BesTofHit *)
void DirectPh (G4int, G4ThreeVector, G4double &, G4int &)
G4double Scintillation (G4int)
G4double TransitTime ()
void AccuSignal (G4double, G4int)
void TofPmtRspns (G4int)
Public Member Functions inherited from BesTofDigitizerV
 BesTofDigitizerV ()
 ~BesTofDigitizerV ()
void Initialize ()
 BesTofDigitizerV ()
 ~BesTofDigitizerV ()
void Initialize ()
 BesTofDigitizerV ()
 ~BesTofDigitizerV ()
void Initialize ()

Additional Inherited Members

Protected Attributes inherited from BesTofDigitizerV
BesTofDigitsCollectionm_besTofDigitsCollection
BesTofHitsCollectionm_THC
ITofCaliSvcm_tofCaliSvc
ITofSimSvcm_tofSimSvc
ITofQElecSvcm_tofQElecSvc
G4double m_ADC [2]
G4double m_TDC [2]
G4int m_trackIndex
G4double m_globalTime
Static Protected Attributes inherited from BesTofDigitizerV
static bool m_booked = false
static NTuple::Tuple * m_tupleTof1 = 0
static NTuple::Item< double > m_partId
static NTuple::Item< double > m_scinNb
static NTuple::Item< double > m_edep
static NTuple::Item< double > m_nHits
static NTuple::Item< double > m_time1st0
static NTuple::Item< double > m_time1st1
static NTuple::Item< double > m_timelast0
static NTuple::Item< double > m_timelast1
static NTuple::Item< double > m_totalPhot0
static NTuple::Item< double > m_totalPhot1
static NTuple::Item< double > m_NphAllSteps
static NTuple::Item< double > m_max0
static NTuple::Item< double > m_max1
static NTuple::Item< double > m_tdc0
static NTuple::Item< double > m_adc0
static NTuple::Item< double > m_tdc1
static NTuple::Item< double > m_adc1
static NTuple::Tuple * m_tupleTof2 = 0
static NTuple::Item< double > m_eTotal
static NTuple::Item< double > m_nDigi
static NTuple::Item< double > m_partIdMPV
static NTuple::Item< double > m_scinNbMPV
static NTuple::Item< double > m_edepMPV
static NTuple::Item< double > m_nDigiOut
static NTuple::Tuple * m_tupleTof3 = 0
static NTuple::Item< double > m_forb
static NTuple::Item< double > m_timeFlight
static NTuple::Item< double > m_ddT
static NTuple::Item< double > m_scinSwim
static NTuple::Item< double > m_scinTime
static NTuple::Item< double > m_transitTime
static NTuple::Item< double > m_endTime
static NTuple::Item< double > m_edepHit

Detailed Description

Constructor & Destructor Documentation

◆ BesTofDigitizerEcV2() [1/3]

BesTofDigitizerEcV2::BesTofDigitizerEcV2 ( )

Definition at line 28 of file BesTofDigitizerEcV2.cc.

28 {
29 ReadData();
30 m_timeBinSize = 0.005;
31
32 // retrieve G4Svc
33 ISvcLocator* svcLocator = Gaudi::svcLocator();
34 IG4Svc* tmpSvc;
35 StatusCode sc = svcLocator->service( "G4Svc", tmpSvc );
36 m_G4Svc = tmpSvc;
37}

◆ ~BesTofDigitizerEcV2() [1/3]

BesTofDigitizerEcV2::~BesTofDigitizerEcV2 ( )

Definition at line 67 of file BesTofDigitizerEcV2.cc.

67{ ; }

◆ BesTofDigitizerEcV2() [2/3]

BesTofDigitizerEcV2::BesTofDigitizerEcV2 ( )

◆ ~BesTofDigitizerEcV2() [2/3]

BesTofDigitizerEcV2::~BesTofDigitizerEcV2 ( )

◆ BesTofDigitizerEcV2() [3/3]

BesTofDigitizerEcV2::BesTofDigitizerEcV2 ( )

◆ ~BesTofDigitizerEcV2() [3/3]

BesTofDigitizerEcV2::~BesTofDigitizerEcV2 ( )

Member Function Documentation

◆ AccuSignal() [1/3]

void BesTofDigitizerEcV2::AccuSignal ( G4double endTime,
G4int forb )

Definition at line 288 of file BesTofDigitizerEcV2.cc.

288 {
289 G4int ihst;
290 ihst = G4int( endTime / m_timeBinSize );
291 if ( ihst > 0 && ihst < m_profBinNEcV2 )
292 {
293 m_nPhot[ihst][forb] = m_nPhot[ihst][forb] + 1;
294 m_totalPhot[forb] = m_totalPhot[forb] + 1;
295 }
296}

Referenced by TofPmtAccum().

◆ AccuSignal() [2/3]

void BesTofDigitizerEcV2::AccuSignal ( G4double ,
G4int  )

◆ AccuSignal() [3/3]

void BesTofDigitizerEcV2::AccuSignal ( G4double ,
G4int  )

◆ Digitize() [1/3]

void BesTofDigitizerEcV2::Digitize ( ScintSingle * scint,
BesTofDigitsCollection * DC )
virtual

Reimplemented from BesTofDigitizerV.

Definition at line 69 of file BesTofDigitizerEcV2.cc.

69 {
70 m_beamTime = m_G4Svc->GetBeamTime() * ns;
72
73 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
74
75 G4int THCID = digiManager->GetHitsCollectionID( "BesTofHitsCollection" );
76 m_THC = (BesTofHitsCollection*)( digiManager->GetHitsCollection( THCID ) );
77
78 if ( m_THC )
79 {
80 // for each digi, compute TDC and ADC
81 G4int partId, scinNb, nHits;
82 G4double edep;
83 BesTofHit* hit;
84 partId = scint->GetPartId();
85 scinNb = scint->GetScinNb();
86 edep = scint->GetEdep();
87 nHits = scint->GetHitIndexes()->size();
88
89 TofPmtInit();
90
91 if ( edep > 0.01 )
92 {
93 for ( G4int j = 0; j < nHits; j++ )
94 {
95 hit = ( *m_THC )[( *( scint->GetHitIndexes() ) )[j]];
96 TofPmtAccum( hit );
97 }
98
99 // get final tdc and adc
100 TofPmtRspns( partId );
101
102 G4double temp0 = m_ADC[0] + m_TDC[0];
103 G4double temp1 = m_ADC[1] + m_TDC[1];
104 if ( ( partId == 1 && temp0 > 0 && temp1 > 0 ) || ( ( partId != 1 ) && temp0 > 0 ) )
105 {
106 if ( m_ADC[0] > 1000 ) m_ADC[0] = 1000;
107 if ( m_ADC[1] > 1000 ) m_ADC[1] = 1000;
108 BesTofDigi* digi = new BesTofDigi;
110 digi->SetPartId( partId );
111 digi->SetScinNb( scinNb );
112 digi->SetForwADC( m_ADC[0] );
113 digi->SetBackADC( m_ADC[1] );
114 if ( m_TDC[0] != -999 ) m_TDC[0] = m_TDC[0] + m_beamTime;
115 if ( m_TDC[1] != -999 ) m_TDC[1] = m_TDC[1] + m_beamTime;
116 digi->SetForwTDC( m_TDC[0] );
117 digi->SetBackTDC( m_TDC[1] );
118 m_besTofDigitsCollection->insert( digi );
119 }
120 }
121 }
122}
G4THitsCollection< BesTofHit > BesTofHitsCollection
void TofPmtAccum(BesTofHit *)
#define ns(x)
Definition xmltok.c:1355

◆ Digitize() [2/3]

virtual void BesTofDigitizerEcV2::Digitize ( ScintSingle * ,
BesTofDigitsCollection *  )
virtual

Reimplemented from BesTofDigitizerV.

◆ Digitize() [3/3]

virtual void BesTofDigitizerEcV2::Digitize ( ScintSingle * ,
BesTofDigitsCollection *  )
virtual

Reimplemented from BesTofDigitizerV.

◆ DirectPh() [1/3]

void BesTofDigitizerEcV2::DirectPh ( G4int partId,
G4ThreeVector emtPos,
G4double & pathL,
G4int & forb )

Definition at line 210 of file BesTofDigitizerEcV2.cc.

211 {
212 // generation photon have random direction
213 // optical parameters of scintillation simulation
214 // G4double cos_spanEc = 1-1/m_refIndex;
215 G4double cos_spanEc = 1;
216 G4double ran;
217 // dcos=cos_span*(ran*2.0-1.0);
218 ran = G4UniformRand();
219 // assuming uniform phi distribution, simulate cos distr only
220 G4double dcosEc = cos_spanEc * ( ran * 2.0 - 1.0 );
221 G4double r2 = sqrt( emtPos.x() * emtPos.x() + emtPos.y() * emtPos.y() );
222 if ( dcosEc > 0.0 && dcosEc != 1 )
223 {
224 forb = 0; // forward
225 pathL = ( r2 - m_ecR1 ) / ( 1.0 - dcosEc );
226 }
227 else if ( dcosEc < 0 && dcosEc != -1 )
228 {
229 forb = 0;
230 pathL = ( 2 * 838 - r2 - m_ecR1 ) / ( 1.0 + dcosEc );
231 }
232}

Referenced by TofPmtAccum().

◆ DirectPh() [2/3]

void BesTofDigitizerEcV2::DirectPh ( G4int ,
G4ThreeVector ,
G4double & ,
G4int &  )

◆ DirectPh() [3/3]

void BesTofDigitizerEcV2::DirectPh ( G4int ,
G4ThreeVector ,
G4double & ,
G4int &  )

◆ ReadData() [1/3]

void BesTofDigitizerEcV2::ReadData ( )

Definition at line 39 of file BesTofDigitizerEcV2.cc.

39 {
40 BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance();
41
42 m_ecR1 = tofPara->GetEcR1();
43 m_tau1Ec = tofPara->GetTau1Ec();
44 m_tau2Ec = tofPara->GetTau2Ec();
45 m_tau3Ec = tofPara->GetTau3Ec();
46 m_tauRatioEc = tofPara->GetTauRatioEc();
47 m_refIndexEc = tofPara->GetRefIndexEc();
48 m_phNConstEc = tofPara->GetPhNConstEc();
49 m_Cpe2pmtEc = tofPara->GetCpe2pmtEc();
50 m_rAngleEc = tofPara->GetRAngleEc();
51 m_QEEc = tofPara->GetQEEc();
52 m_CEEc = tofPara->GetCEEc();
53 m_peCorFacEc = tofPara->GetPeCorFacEc();
54 m_attenEc = tofPara->GetAttenEc();
55
56 m_ttsMeanEc = tofPara->GetTTSmeanEc();
57 m_ttsSigmaEc = tofPara->GetTTSsigmaEc();
58 m_PMTgainEc = tofPara->GetPMTgainEc();
59 m_CeEc = tofPara->GetCeEc();
60 m_riseTimeEc = tofPara->GetRiseTimeEc();
61 m_LLthreshEc = tofPara->GetLLthreshEc();
62 m_HLthreshEc = tofPara->GetHLthreshEc();
63 m_preGainEc = tofPara->GetPreGainEc();
64 m_noiseSigmaEc = tofPara->GetNoiseSigmaEc();
65}
static BesTofGeoParameter * GetInstance()

Referenced by BesTofDigitizerEcV2().

◆ ReadData() [2/3]

void BesTofDigitizerEcV2::ReadData ( )

◆ ReadData() [3/3]

void BesTofDigitizerEcV2::ReadData ( )

◆ Scintillation() [1/3]

G4double BesTofDigitizerEcV2::Scintillation ( G4int partId)

Definition at line 234 of file BesTofDigitizerEcV2.cc.

234 {
235 G4double tmp_tauRatio, tmp_tau1, tmp_tau2, tmp_tau3;
236 tmp_tauRatio = m_tauRatioEc;
237 tmp_tau1 = m_tau1Ec;
238 tmp_tau2 = m_tau2Ec;
239 tmp_tau3 = m_tau3Ec;
240
241 G4double UniformR = tmp_tauRatio / ( 1 + tmp_tauRatio );
242 G4double EmissionTime;
243 if ( G4UniformRand() > UniformR )
244 {
245 while ( 1 )
246 {
247 EmissionTime = -tmp_tau2 * log( G4UniformRand() );
248 if ( G4UniformRand() - exp( EmissionTime / tmp_tau2 - EmissionTime / tmp_tau1 ) > 1.E-8 )
249 break;
250 }
251 }
252 else EmissionTime = -tmp_tau3 * log( G4UniformRand() );
253 return EmissionTime;
254}
EvtComplex exp(const EvtComplex &c)

Referenced by TofPmtAccum().

◆ Scintillation() [2/3]

G4double BesTofDigitizerEcV2::Scintillation ( G4int )

◆ Scintillation() [3/3]

G4double BesTofDigitizerEcV2::Scintillation ( G4int )

◆ TofPmtAccum() [1/3]

void BesTofDigitizerEcV2::TofPmtAccum ( BesTofHit * hit)

Definition at line 137 of file BesTofDigitizerEcV2.cc.

137 {
138 G4double cvelScint = c_light / m_refIndexEc;
139 // Get information of this step
140 G4ThreeVector pos = hit->GetPos();
141 G4int trackIndex = hit->GetTrackIndex();
142 G4int partId = hit->GetPartId();
143 G4double edep = hit->GetEdep();
144 G4double stepL = hit->GetStepL();
145 G4double deltaT = hit->GetDeltaT();
146 G4double timeFlight = hit->GetTime() - m_beamTime;
147 if ( timeFlight < m_globalTime )
148 {
149 m_globalTime = timeFlight;
150 m_trackIndex = trackIndex;
151 }
152
153 G4ThreeVector pDirection = hit->GetPDirection();
154 G4double nx = pDirection.x();
155 G4double ny = pDirection.y();
156 G4double nz = pDirection.z();
157
158 // Cpe2pmt=cathode area/scint area
159 // peCorFac=correction factor for eff. of available Npe
160
161 // number of photons generated in this step
162 G4int NphStep;
163 NphStep = G4int( edep * m_phNConstEc * m_Cpe2pmtEc * 0.66 * m_QEEc * m_CEEc * m_peCorFacEc );
164
165 G4double ddS, ddT;
166 if ( NphStep > 0 )
167 {
168 for ( G4int i = 0; i < NphStep; i++ )
169 {
170 // uniform scintilation in each step
171 ddS = stepL * G4UniformRand();
172 ddT = deltaT * G4UniformRand();
173 G4ThreeVector emtPos;
174 emtPos.setX( pos.x() + nx * ddS );
175 emtPos.setY( pos.y() + ny * ddS );
176 emtPos.setZ( pos.z() + nz * ddS );
177
178 // check scinillation light whether to hit the pmt or not
179 // forb=0/1 for forward(z>0, east) and backward(z<0, west)
180 G4double pathL = 0;
181 G4int forb;
182 DirectPh( partId, emtPos, pathL, forb );
183
184 // check if photon can reach PMT or not, after attenuation
185 G4double ran = G4UniformRand();
186 if ( pathL > 0 && exp( -pathL / m_attenEc ) > ran )
187 {
188 // propagation time in scintillator
189 G4double scinSwim = pathL / cvelScint;
190 // scintillation timing
191 // G4double scinTime=GenPhoton(partId);
192 G4double scinTime = Scintillation( partId );
193
194 // PMT transit time
195 G4double transitTime = TransitTime();
196 // sum up all time components
197 G4double endTime = timeFlight + ddT + scinSwim + scinTime + transitTime;
198
199 // store timing into binned buffer
200 AccuSignal( endTime, forb );
201
202 // update 1st and last timings here
203 if ( m_t1st[forb] > endTime ) m_t1st[forb] = endTime;
204 if ( m_tLast[forb] < endTime ) m_tLast[forb] = endTime;
205 }
206 }
207 }
208}
void AccuSignal(G4double, G4int)
G4double Scintillation(G4int)
void DirectPh(G4int, G4ThreeVector, G4double &, G4int &)

Referenced by Digitize().

◆ TofPmtAccum() [2/3]

void BesTofDigitizerEcV2::TofPmtAccum ( BesTofHit * )

◆ TofPmtAccum() [3/3]

void BesTofDigitizerEcV2::TofPmtAccum ( BesTofHit * )

◆ TofPmtInit() [1/3]

void BesTofDigitizerEcV2::TofPmtInit ( )

Definition at line 124 of file BesTofDigitizerEcV2.cc.

124 {
125 m_trackIndex = -999;
126 m_globalTime = 9999;
127 m_t1st[0] = 100;
128 m_t1st[1] = 100;
129 m_tLast[0] = 0.;
130 m_tLast[1] = 0;
131 m_totalPhot[0] = 0;
132 m_totalPhot[1] = 0;
133 for ( G4int i = 0; i < 2; i++ )
134 for ( G4int j = 0; j < m_profBinNEcV2; j++ ) m_nPhot[j][i] = 0;
135}

Referenced by Digitize().

◆ TofPmtInit() [2/3]

void BesTofDigitizerEcV2::TofPmtInit ( )

◆ TofPmtInit() [3/3]

void BesTofDigitizerEcV2::TofPmtInit ( )

◆ TofPmtRspns() [1/3]

void BesTofDigitizerEcV2::TofPmtRspns ( G4int partId)

Definition at line 298 of file BesTofDigitizerEcV2.cc.

298 {
299 // to generate PMT signal shape for single photoelectron.
300 // only one time for a job.
301 static G4double snpe[m_snpeBinNEcV2];
302 static G4int istore_snpe = -1;
303
304 // Model: f(t)=Gain*mv_1pe* t**2 * exp-(t/tau)**2/normal-const
305 // normalization const =sqrt(pi)*tau*tau*tau/4.0
306 G4double tau = m_riseTimeEc;
307 G4double norma_const = sqrt( M_PI ) * tau * tau * tau / 4.0; // in unit of ns**3
308 G4double echarge = 1.6e-7; // in unit of PC
309
310 // time profile of pmt signals for Back and Forward PMT.
311 G4double profPmt[m_profBinNEcV2][2];
312
313 G4double t;
314 G4int n1, n2, ii;
315 G4int phtn;
316
317 if ( istore_snpe < 0 )
318 {
319 istore_snpe = 1;
320 for ( G4int i = 0; i < m_snpeBinNEcV2; i++ )
321 {
322 t = ( i + 1 ) * m_timeBinSize;
323 snpe[i] = m_PMTgainEc * m_CeEc * t * t * exp( -( t / tau ) * ( t / tau ) ) / norma_const;
324 }
325 }
326 // for barrel and endcap tof: fb=2 or 1
327 G4int fb = 1;
328
329 for ( G4int j = 0; j < 2; j++ )
330 {
331 m_TDC[j] = -999.0;
332 m_ADC[j] = -999.0;
333 }
334 for ( G4int j = 0; j < fb; j++ )
335 {
336 if ( m_totalPhot[j] > 0 )
337 {
338 n1 = G4int( m_t1st[j] / m_timeBinSize );
339 n2 = G4int( m_tLast[j] / m_timeBinSize );
340
341 for ( G4int i = 0; i < m_profBinNEcV2; i++ ) profPmt[i][j] = 0.0;
342
343 // generate PMT pulse
345 for ( G4int i = n1; i < n2; i++ )
346 {
347 phtn = m_nPhot[i][j];
348 if ( phtn > 0 )
349 {
350 for ( G4int ihst = 0; ihst < m_snpeBinNEcV2; ihst++ )
351 {
352 ii = i + ihst;
353 if ( ii < m_profBinNEcV2 ) profPmt[ii][j] += phtn * snpe[ihst];
354 }
355 }
356 }
357
358 // add preamplifier and noise
359 for ( int i = 0; i < m_profBinNEcV2; i++ )
360 {
361 if ( profPmt[i][j] > 0 )
362 profPmt[i][j] =
363 m_preGainEc * profPmt[i][j] + G4RandGauss::shoot( 0, m_noiseSigmaEc );
364 }
365
366 // get pulse height
367 G4double max = 0;
368 for ( int i = 0; i < m_profBinNEcV2; i++ )
369 {
370 if ( profPmt[i][j] > max ) max = profPmt[i][j];
371 }
372
373 G4double tmp_HLthresh, tmp_LLthresh;
374 if ( partId == 1 )
375 {
376 tmp_HLthresh = m_HLthreshEc;
377 tmp_LLthresh = m_LLthreshEc;
378 }
379 else
380 {
381 tmp_HLthresh = m_HLthreshEc;
382 tmp_LLthresh = m_LLthreshEc;
383 }
384
385 // get final tdc and adc
386 if ( max >= tmp_HLthresh )
387 {
388 for ( int i = 0; i < m_profBinNEcV2; i++ )
389 {
390 if ( profPmt[i][j] >= tmp_LLthresh )
391 {
392 m_TDC[j] = i * m_timeBinSize;
393 m_ADC[j] = m_preGainEc * m_totalPhot[j] * echarge * m_PMTgainEc;
394 break;
395 }
396 }
397 }
398 }
399 }
400}
#define max(a, b)
int n2
Definition SD0Tag.cxx:59
int n1
Definition SD0Tag.cxx:58
#define M_PI
Definition TConstant.h:4
int t()
Definition t.c:1

Referenced by Digitize().

◆ TofPmtRspns() [2/3]

void BesTofDigitizerEcV2::TofPmtRspns ( G4int )

◆ TofPmtRspns() [3/3]

void BesTofDigitizerEcV2::TofPmtRspns ( G4int )

◆ TransitTime() [1/3]

G4double BesTofDigitizerEcV2::TransitTime ( )

Definition at line 283 of file BesTofDigitizerEcV2.cc.

283 {
284 // get time transit spread
285 return G4RandGauss::shoot( m_ttsMeanEc, m_ttsSigmaEc );
286}

Referenced by TofPmtAccum().

◆ TransitTime() [2/3]

G4double BesTofDigitizerEcV2::TransitTime ( )

◆ TransitTime() [3/3]

G4double BesTofDigitizerEcV2::TransitTime ( )

The documentation for this class was generated from the following files: