BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofDigitizerBrV2 Class Reference

#include <BesTofDigitizerBrV2.hh>

+ Inheritance diagram for BesTofDigitizerBrV2:

Public Member Functions

 BesTofDigitizerBrV2 ()
 
 ~BesTofDigitizerBrV2 ()
 
virtual void Digitize (ScintSingle *, BesTofDigitsCollection *)
 
void ReadData ()
 
void TofPmtInit ()
 
void TofPmtAccum (BesTofHit *, G4int)
 
void DirectPh (G4int, G4ThreeVector, G4double &, G4int &)
 
G4double Scintillation (G4int)
 
G4double TransitTime ()
 
void AccuSignal (G4double, G4int)
 
void TofPmtRspns (G4int)
 
G4double Reflectivity (G4double n1, G4double n2, G4double theta)
 
G4double Reflectivity (G4double n1, G4double n2, G4double n3, G4double theta)
 
G4double BirksLaw (BesTofHit *hit)
 
- Public Member Functions inherited from BesTofDigitizerV
 BesTofDigitizerV ()
 
 ~BesTofDigitizerV ()
 
void Initialize ()
 
virtual void Digitize (ScintSingle *, BesTofDigitsCollection *)
 

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

Definition at line 34 of file BesTofDigitizerBrV2.hh.

Constructor & Destructor Documentation

◆ BesTofDigitizerBrV2()

BesTofDigitizerBrV2::BesTofDigitizerBrV2 ( )

Definition at line 27 of file BesTofDigitizerBrV2.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 if(!sc.isSuccess())
37 {
38 std::cout << " Could not initialize Realization Service in BesTofDigitizerBrV2" << std::endl;
39 }
40 else
41 {
42 m_G4Svc = dynamic_cast<G4Svc *>(tmpSvc);
43 }
44
45 //retrieve RealizationSvc
46 IRealizationSvc *tmpReal;
47 StatusCode scReal = svcLocator->service("RealizationSvc",tmpReal);
48 if (!scReal.isSuccess())
49 {
50 std::cout << " Could not initialize Realization Service in BesTofDigitizerBrV2" << std::endl;
51 }
52 else
53 {
54 m_RealizationSvc = dynamic_cast<RealizationSvc*>(tmpReal);
55 }
56
57
58}
Definition: G4Svc.h:32
Definition: IG4Svc.h:30

◆ ~BesTofDigitizerBrV2()

BesTofDigitizerBrV2::~BesTofDigitizerBrV2 ( )

Definition at line 88 of file BesTofDigitizerBrV2.cc.

89{
90 ;
91}

Member Function Documentation

◆ AccuSignal()

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

Definition at line 746 of file BesTofDigitizerBrV2.cc.

747{
748 G4int ihst;
749 ihst=G4int(endTime/m_timeBinSize);
750 if (ihst>0 &&ihst<m_profBinN)
751 {
752 m_nPhot[ihst][forb]=m_nPhot[ihst][forb]+1;
753 m_totalPhot[forb]=m_totalPhot[forb]+1;
754 }
755}
const G4int m_profBinN

Referenced by TofPmtAccum().

◆ BirksLaw()

G4double BesTofDigitizerBrV2::BirksLaw ( BesTofHit hit)

Definition at line 379 of file BesTofDigitizerBrV2.cc.

380{
381 const G4double kappa = 0.015*cm/MeV;
382 const G4String brMaterial = "BC408";
383 G4double dE = hit->GetEdep();
384 //G4cout << "The edep is "<< dE << G4endl;
385 G4double dX = hit->GetStepL();
386 //G4Material* materiral = hit->GetMaterial();
387 G4double charge = hit->GetCharge();
388 G4double cor_dE = dE;
389 //if((materiral->GetName()==brMaterial) && charge!=0.&& dX!=0.)
390 if(charge!=0.&& dX!=0.)
391 {
392 cor_dE = dE/(1+kappa*dE/dX);
393 //if(dE>20)
394 //{
395 // G4cout << "\n dE > 20. Details are below:" << G4endl;
396 // G4cout << "dE/dx:" << dE/dX << G4endl;
397 // G4cout << "dE:" << dE << "; dX:" << dX << G4endl;
398 // G4cout << "It is BC408. cor_dE is " << cor_dE << G4endl;
399 // G4double ratio = cor_dE/dE;
400 // G4cout << "The ratio cor_dE/edep is "<< ratio << G4endl;
401 //}
402 //G4cout << "It is BC408. cor_dE is " << cor_dE << G4endl;
403 //G4double ratio = cor_dE/dE;
404 //G4cout << "The ratio cor_dE/edep is "<< ratio << G4endl;
405 }
406 return cor_dE;
407
408}
G4double GetStepL()
Definition: BesTofHit.hh:63
G4double GetCharge()
Definition: BesTofHit.hh:72
G4double GetEdep()
Definition: BesTofHit.hh:62

Referenced by TofPmtAccum().

◆ Digitize()

void BesTofDigitizerBrV2::Digitize ( ScintSingle scint,
BesTofDigitsCollection DC 
)
virtual

Reimplemented from BesTofDigitizerV.

Definition at line 93 of file BesTofDigitizerBrV2.cc.

94{
95 m_beamTime = m_G4Svc->GetBeamTime() * ns;
97
98 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
99 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
100 m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID));
101
102 if (m_G4Svc->TofRootFlag())
103 {
104 m_eTotal = 0;
105 m_nDigi = 0;
106 m_partIdMPV = -9;
107 m_scinNbMPV = -9;
108 m_edepMPV = 0;
109 m_nDigiOut = 0;
110 }
111
112 if (m_THC)
113 {
114 //for each digi, compute TDC and ADC
115 G4int partId, scinNb, nHits;
116 G4double edep;
117 BesTofHit* hit;
118 partId=scint->GetPartId();
119 scinNb=scint->GetScinNb();
120 edep = scint->GetEdep();
121 nHits=scint->GetHitIndexes()->size();
122
123
124 //std::cout << "BesTofDigitizerBrV2 Partid scinNb " << partId << " " << scinNb << std::endl;
125 //cout << "*** scinNb:" << scinNb << " *** " << m_tofCaliSvc->BAtten(scinNb) << "***" << endl;
126 //cout << "*****scinNb:"<< scinNb << " ***** A2:" << m_tofCaliSvc->BGainBackward(scinNb)
127 // << " ***** A1:" << m_tofCaliSvc->BGainForward(scinNb) << endl;
128
129 TofPmtInit();
130
131 //fill tof Ntuple
132 if (m_G4Svc->TofRootFlag())
133 {
134 if (edep>m_edepMPV)
135 {
136 m_partIdMPV = partId;
137 m_scinNbMPV = scinNb;
138 m_edepMPV = edep;
139 }
140 m_eTotal += edep;
141 m_nDigi ++;
142
143 m_partId = partId;
144 m_scinNb = scinNb;
145 m_edep = edep;
146 m_nHits = nHits;
147 }
148
149 if (edep>0.01)
150 {
151 for (G4int j=0;j<nHits;j++)
152 {
153 hit= (*m_THC)[( *(scint->GetHitIndexes()) )[j]];
154 TofPmtAccum(hit, scinNb);
155 }
156 if (m_G4Svc->TofRootFlag())
157 {
158 m_time1st0=m_t1st[0];
159 m_time1st1=m_t1st[1];
160 m_timelast0=m_tLast[0];
161 m_timelast1=m_tLast[1];
162 m_totalPhot0=m_totalPhot[0];
163 m_totalPhot1=m_totalPhot[1];
164 }
165 //get final tdc and adc
166 TofPmtRspns(scinNb);
167 //G4cout<<"pre-cut " << partId << "\nadc0:"<<m_ADC[0]<<"; adc1:"
168 // <<m_ADC[1]<<"; tdc0:"<<m_TDC[0]<<"; tdc1:"
169 // <<m_TDC[1]<<G4endl;
170
171 G4double temp0 = m_ADC[0]+m_TDC[0];
172 G4double temp1 = m_ADC[1]+m_TDC[1];
173 //cout << "partid: " << partId << " temp0: " << temp0 << " temp1: " << temp1 << endl;
174 //if ( partId==1 && m_ADC[0]>255 && m_ADC[1]>255 && m_TDC[0]>0. && m_TDC[1]>0.)
175 if ( partId==1 && (temp0 > -1998. || temp1 > -1998.))
176 {
177 //const double MAX_ADC = 8191 * 0.3; // channel set up to 8192 will lead to overflow.
178 BesTofDigi* digi = new BesTofDigi;
180 digi->SetPartId(partId);
181 digi->SetScinNb(scinNb);
182 digi->SetForwADC( m_ADC[0]) ;
183 digi->SetBackADC( m_ADC[1]) ;
184 if (m_TDC[0]>0)
185 m_TDC[0] = m_TDC[0]+m_beamTime;
186 if (m_TDC[1]>0)
187 m_TDC[1] = m_TDC[1]+m_beamTime;
188 digi->SetForwTDC( m_TDC[0]) ;
189 digi->SetBackTDC( m_TDC[1]) ;
190 //G4cout<<"+++++++++++++++++++++++++++++barrel\nadc0:"<<m_ADC[0]<<"; adc1:"
191 // <<m_ADC[1]<<"; tdc0:"<<m_TDC[0]<<"; tdc1:"
192 // <<m_TDC[1]<<G4endl;
193
194 m_besTofDigitsCollection->insert(digi);
195
196 if (m_G4Svc->TofRootFlag())
197 m_nDigiOut++;
198
199 }
200 if (m_G4Svc->TofRootFlag())
201 m_tupleTof1->write();
202
203 }
204
205 if (m_G4Svc->TofRootFlag())
206 m_tupleTof2->write();
207 }
208}
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition: BesTofHit.hh:108
void SetPartId(G4int partId)
Definition: BesTofDigi.hh:39
void SetForwADC(G4double ADC)
Definition: BesTofDigi.hh:41
void SetTrackIndex(G4int index)
Definition: BesTofDigi.hh:38
void SetBackADC(G4double ADC)
Definition: BesTofDigi.hh:42
void SetForwTDC(G4double TDC)
Definition: BesTofDigi.hh:43
void SetScinNb(G4int scinNb)
Definition: BesTofDigi.hh:40
void SetBackTDC(G4double TDC)
Definition: BesTofDigi.hh:44
void TofPmtAccum(BesTofHit *, G4int)
static NTuple::Item< double > m_partId
static NTuple::Item< double > m_eTotal
static NTuple::Item< double > m_timelast1
static NTuple::Item< double > m_timelast0
static NTuple::Item< double > m_scinNb
static NTuple::Tuple * m_tupleTof2
static NTuple::Item< double > m_edep
static NTuple::Item< double > m_totalPhot0
static NTuple::Item< double > m_scinNbMPV
static NTuple::Item< double > m_nDigi
BesTofDigitsCollection * m_besTofDigitsCollection
static NTuple::Item< double > m_nHits
static NTuple::Item< double > m_partIdMPV
static NTuple::Item< double > m_time1st1
static NTuple::Item< double > m_nDigiOut
BesTofHitsCollection * m_THC
static NTuple::Item< double > m_totalPhot1
static NTuple::Tuple * m_tupleTof1
static NTuple::Item< double > m_edepMPV
static NTuple::Item< double > m_time1st0
double GetBeamTime()
Definition: G4Svc.h:85
bool TofRootFlag()
Definition: G4Svc.h:118
G4int GetPartId()
Definition: ScintSingle.hh:44
vector< G4int > * GetHitIndexes()
Definition: ScintSingle.hh:47
G4int GetScinNb()
Definition: ScintSingle.hh:45
G4double GetEdep()
Definition: ScintSingle.hh:46
#define ns(x)
Definition: xmltok.c:1504

Referenced by BesTofDigitizer::Digitize().

◆ DirectPh()

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

Definition at line 457 of file BesTofDigitizerBrV2.cc.

458{
459 //std::cout << "BesTofDigitizerBrV2::DirectPh()" << std::endl;
460 const static G4double silicon_oil_index = 1.43;
461 const static G4double glass_index = 1.532;
462 //generation photon have random direction
463 //optical parameters of scintillation simulation
464 G4double cos_span=1-cos( asin(silicon_oil_index/m_refIndex) );
465 //G4double cos_spanEc = 1;
466 G4double dcos, ran;
467 ran=G4UniformRand();
468 //assuming uniform phi distribution, simulate cos distr only
469 dcos=cos_span*(ran*2.0-1.0);
470 //G4double dcosEc = cos_spanEc*(ran*2.0-1.0);
471 G4double r2=sqrt(emtPos.x()*emtPos.x()+emtPos.y()*emtPos.y());
472 G4int nRef=0;
473 G4double costheta,sintheta;
474 G4double theta,thetaR; // thetaR is scin to air full ref angle. about 39.265 degree.
475 costheta=dcos>0?(1-dcos):(1+dcos);
476 theta=acos(costheta);
477 sintheta=sin(theta);
478 thetaR=asin(1/m_refIndex);
479 G4double R1;
480 R1=Reflectivity(m_refIndex,1.0,theta);
481 G4double ratio1Mean=(CLHEP::pi)*25.5*25.5/(57.1+60.7)/25.0; //0.693657
482 G4double ratio2Mean=(19.5/25.5)*(19.5/25.5); //0.584775
483 G4double ratio1=G4RandGauss::shoot(ratio1Mean,0.015);
484 G4double ratio2=G4RandGauss::shoot(ratio2Mean,0.015);
485 G4double ratio3Mean=0.945*ratio1Mean*ratio2Mean;
486 G4double ratio3=G4RandGauss::shoot(ratio3Mean,0.015);
487
488 G4double R2=1-Reflectivity(m_refIndex,silicon_oil_index, glass_index, theta);
489 if (dcos > 0 && dcos != 1)
490 {
491 if (theta < thetaR) // theta < 39.265 degree
492 {
493 if (G4UniformRand()<ratio1) //coup1
494 {
495 if (G4UniformRand()<R2)
496 {
497 if (G4UniformRand()<ratio2) //PMT 39mm
498 {
499 forb=0;
500 pathL=(m_scinLength/2-emtPos.z())/costheta;
501 }
502 }
503 else
504 {
505 if (G4UniformRand()<ratio3)
506 {
507 forb=1;
508 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
509 }
510 }
511 }
512 else //Air
513 {
514 if (G4UniformRand()<R1)
515 {
516 G4double tempran=G4UniformRand();
517 if (tempran<ratio3)
518 {
519 forb=1;
520 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
521 }
522 else if (tempran>ratio1&&G4UniformRand()<R1&&G4UniformRand()<ratio3)
523 {
524 forb=0;
525 pathL=(2.5*m_scinLength-emtPos.z())/costheta;
526 }
527 }
528 }
529 }
530 else // 39.265 <= theta < 64.832
531 {
532 if (G4UniformRand()<ratio1) //coup1
533 {
534 if (G4UniformRand()<R2)
535 {
536 if (G4UniformRand()<ratio2) //PMT 39mm
537 {
538 forb=0;
539 pathL=(m_scinLength/2-emtPos.z())/costheta;
540 }
541 }
542 else
543 {
544 if (G4UniformRand()<ratio3)
545 {
546 forb=1;
547 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
548 }
549 }
550 }
551 else //Air
552 {
553 G4double tempran=G4UniformRand();
554 if (tempran<ratio3)
555 {
556 forb=1;
557 pathL=(1.5*m_scinLength-emtPos.z())/costheta;
558 }
559 else if (tempran>ratio1 && G4UniformRand()<ratio3)
560 {
561 forb=0;
562 pathL=(2.5*m_scinLength-emtPos.z())/costheta;
563 }
564 }
565 }
566 }
567 else if (dcos < 0 && dcos != -1)
568 {
569 if (theta < thetaR) // theta < 39.265 degree
570 {
571 if (G4UniformRand()<ratio1) //coup1
572 {
573 if (G4UniformRand()<R2)
574 {
575 if (G4UniformRand()<ratio2) //PMT 39mm
576 {
577 forb=1;
578 pathL=(m_scinLength/2+emtPos.z())/costheta;
579 }
580 }
581 else
582 {
583 if (G4UniformRand()<ratio3)
584 {
585 forb=0;
586 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
587 }
588 }
589 }
590 else //Air
591 {
592 if (G4UniformRand()<R1)
593 {
594 G4double tempran=G4UniformRand();
595 if (tempran<ratio3)
596 {
597 forb=0;
598 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
599 }
600 else if (tempran>ratio1&&G4UniformRand()<R1&&G4UniformRand()<ratio3)
601 {
602 forb=1;
603 pathL=(2.5*m_scinLength+emtPos.z())/costheta;
604 }
605 }
606 }
607 }
608 else // 39.265 <= theta < 64.832
609 {
610 if (G4UniformRand()<ratio1) //coup1
611 {
612 if (G4UniformRand()<R2)
613 {
614 if (G4UniformRand()<ratio2) //PMT 39mm
615 {
616 forb=1;
617 pathL=(m_scinLength/2+emtPos.z())/costheta;
618 }
619 }
620 else
621 {
622 if (G4UniformRand()<ratio3)
623 {
624 forb=0;
625 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
626 }
627 }
628 }
629 else //Air
630 {
631 G4double tempran=G4UniformRand();
632 if (tempran<ratio3)
633 {
634 forb=0;
635 pathL=(1.5*m_scinLength+emtPos.z())/costheta;
636 }
637 else if (tempran>ratio1 && G4UniformRand()<ratio3)
638 {
639 forb=1;
640 pathL=(2.5*m_scinLength+emtPos.z())/costheta;
641 }
642 }
643 }
644 }
645
646 G4double convFactor=180./3.1415926;
647 if (theta>asin(1)-thetaR)
648 {
649 G4double alpha = G4UniformRand()*asin(1.);
650 G4int nRef1 = pathL*sintheta*cos(alpha)/50.0+0.5;
651 G4int nRef2 = pathL*sintheta*sin(alpha)/58.9+0.5;
652 G4double beta1=acos(sintheta*cos(alpha));
653 G4double beta2=acos(sintheta*sin(alpha));
654 beta2 -= 3.75/convFactor;
655 G4double R21,R22;
656 R21=Reflectivity(m_refIndex,1.0,beta1);
657 R22=Reflectivity(m_refIndex,1.0,beta2);
658 for (G4int i=0;i<nRef1;i++)
659 {
660 if (G4UniformRand()<(1-R21) && G4UniformRand()<0.15)
661 pathL=-9;
662 }
663 for (G4int i=0;i<nRef2;i++)
664 {
665 if (G4UniformRand()<(1-R22) && G4UniformRand()<0.15)
666 pathL=-9;
667 }
668 }
669}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
const double alpha
G4double Reflectivity(G4double n1, G4double n2, G4double theta)

Referenced by TofPmtAccum().

◆ ReadData()

void BesTofDigitizerBrV2::ReadData ( )

Definition at line 60 of file BesTofDigitizerBrV2.cc.

61{
63
64 m_scinLength = tofPara->GetBr1L();
65 m_tau1 = tofPara->GetTau1();
66 m_tau2 = tofPara->GetTau2();
67 m_tau3 = tofPara->GetTau3();
68 m_tauRatio = tofPara->GetTauRatio();
69 m_refIndex = tofPara->GetRefIndex();
70 m_phNConst = tofPara->GetPhNConst();
71 m_Cpe2pmt = tofPara->GetCpe2pmt();
72 m_rAngle = tofPara->GetRAngle();
73 m_QE = tofPara->GetQE();
74 m_CE = tofPara->GetCE();
75 m_peCorFac = tofPara->GetPeCorFac();
76
77 m_ttsMean = tofPara->GetTTSmean();
78 m_ttsSigma = tofPara->GetTTSsigma();
79 m_Ce = tofPara->GetCe();
80 m_LLthresh = tofPara->GetLLthresh();
81 m_HLthresh = tofPara->GetHLthresh();
82 m_preGain = tofPara->GetPreGain();
83 m_noiseSigma = tofPara->GetNoiseSigma();
84
85
86}
static BesTofGeoParameter * GetInstance()

Referenced by BesTofDigitizerBrV2().

◆ Reflectivity() [1/2]

G4double BesTofDigitizerBrV2::Reflectivity ( G4double  n1,
G4double  n2,
G4double  n3,
G4double  theta 
)

Definition at line 410 of file BesTofDigitizerBrV2.cc.

411{
412 G4double I1,I2,I3,rp1,rs1,rp2,rs2,Rp1,Rs1,Rp2,Rs2,Rp,Rs;
413 G4double R=1.0;
414 //n1=m_refIndex;
415 //n2=1.0;
416 I1=theta;
417 if(I1<asin(n2/n1))
418 {
419 I2=asin(sin(I1)*(n1/n2));
420 rp1=(n1/cos(I1)-n2/cos(I2))/(n1/cos(I1)+n2/cos(I2));
421 rs1=(n1*cos(I1)-n2*cos(I2))/(n1*cos(I1)+n2*cos(I2));
422 Rp1=rp1*rp1;
423 Rs1=rs1*rs1;
424
425 I3=asin(sin(I1)*(n1/n3));
426 rp2=(n2/cos(I2)-n3/cos(I3))/(n2/cos(I2)+n3/cos(I3));
427 rs2=(n2*cos(I2)-n3*cos(I3))/(n2*cos(I2)+n3*cos(I3));
428 Rp2=rp2*rp2;
429 Rs2=rs2*rs2;
430 Rp=(Rp1+Rp2-2*Rp1*Rp2)/(1-Rp1*Rp2);
431 Rs=(Rs1+Rs2-2*Rs1*Rs2)/(1-Rs1*Rs2);
432 R=(Rp+Rs)/2.;
433 }
434 return R;
435}
int n2
Definition: SD0Tag.cxx:55
int n1
Definition: SD0Tag.cxx:54
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)
Definition: TUtil.h:27

◆ Reflectivity() [2/2]

G4double BesTofDigitizerBrV2::Reflectivity ( G4double  n1,
G4double  n2,
G4double  theta 
)

Definition at line 438 of file BesTofDigitizerBrV2.cc.

439{
440 G4double I1,I2,rp,rs,Rp,Rs;
441 G4double R=1.0;
442 //n1=m_refIndex;
443 //n2=1.0;
444 I1=theta;
445 if (I1<asin(n2/n1))
446 {
447 I2=asin(sin(I1)*(n1/n2));
448 rp=(n1/cos(I1)-n2/cos(I2))/(n1/cos(I1)+n2/cos(I2));
449 rs=(n1*cos(I1)-n2*cos(I2))/(n1*cos(I1)+n2*cos(I2));
450 Rp=rp*rp;
451 Rs=rs*rs;
452 R=(Rp+Rs)/2.;
453 }
454 return R;
455}

Referenced by DirectPh().

◆ Scintillation()

G4double BesTofDigitizerBrV2::Scintillation ( G4int  partId)

Definition at line 693 of file BesTofDigitizerBrV2.cc.

694{
695 G4double tmp_tauRatio,tmp_tau1,tmp_tau2,tmp_tau3;
696 tmp_tauRatio = m_tauRatio;
697 tmp_tau1 = m_tau1;
698 tmp_tau2 = m_tau2;
699 tmp_tau3 = m_tau3;
700 G4double UniformR = tmp_tauRatio/(1+tmp_tauRatio);
701 G4double EmissionTime;
702 if (G4UniformRand()>UniformR) {
703 while (1) {
704 EmissionTime = -tmp_tau2*log( G4UniformRand() );
705 if (G4UniformRand()-exp(EmissionTime/tmp_tau2-EmissionTime/tmp_tau1)>1.E-8)
706 break;
707 }
708 }
709 else EmissionTime = -tmp_tau3*log( G4UniformRand() );
710 return EmissionTime;
711}
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252

Referenced by TofPmtAccum().

◆ TofPmtAccum()

void BesTofDigitizerBrV2::TofPmtAccum ( BesTofHit hit,
G4int  scinNb 
)

Definition at line 246 of file BesTofDigitizerBrV2.cc.

247{
249 //std::cout << "BesTofDigitizerBrV2::TofPmtAccum()" << std::endl;
250 G4double cvelScint=c_light/m_refIndex/1.07;
251 //Get information of this step
252 G4ThreeVector pos=hit->GetPos();
253 G4int trackIndex = hit->GetTrackIndex();
254 G4int partId =hit->GetPartId();
255 G4double edep=hit->GetEdep();
256 G4double stepL=hit->GetStepL();
257 G4double deltaT=hit->GetDeltaT();
258 G4double timeFlight=hit->GetTime()-m_beamTime;
259 //std::cout << "timeFlight: " << timeFlight << std::endl;
260 if (timeFlight < m_globalTime)
261 {
262 m_globalTime = timeFlight;
263 m_trackIndex = trackIndex;
264 }
265
266 G4ThreeVector pDirection=hit->GetPDirection();
267 G4double nx=pDirection.x();
268 G4double ny=pDirection.y();
269 G4double nz=pDirection.z();
270
271 //phNConst=(Nph/MeV)*(QE)*(CE)*(1-cos(crit));
272 // =10000 * 0.2 * 0.6 * (1-cos(39.265))=270.931
273 //asin(1/1.58) = 39.265248
274 //only the light has theta=0---39.265 can go out to PMT, the probability is computed with solid angle
275 //solid angle = phi*(1-cos(theta)), phi=2pi
276
277 //Cpe2pmt=cathode area/scint area
278 //peCorFac=correction factor for eff. of available Npe
279
280 //G4double thetaProb = 1-sqrt(m_refIndex*m_refIndex-1)/m_refIndex;
281 G4double thetaProb=1-cos( asin(1.43/m_refIndex));
282 //G4double thetaProbEc = 1-1/m_refIndex;
283
284 //number of photons generated in this step
285 G4double nMean, nPhoton;
286 //std::cout << "0 BirksLaw(): " << std::endl;
287 nMean = m_phNConst*BirksLaw(hit);
288 //std::cout << "1 BirksLaw(): " << std::endl;
289
290 if(nMean>10)
291 {
292 G4double resolutionScale=1.;
293 G4double sigma=resolutionScale*sqrt(nMean);
294 nPhoton=G4int(G4RandGauss::shoot(nMean,sigma)+0.5);
295 }
296 else
297 nPhoton=G4int(G4Poisson(nMean));
298 //G4cout<<"nPhoton:"<<nPhoton<<G4endl;
299
300 G4int NphStep;
301 if (partId==1)
302 NphStep=G4int(nPhoton*thetaProb*m_rAngle*m_QE*m_CE*m_peCorFac);
303 //else
304 //NphStep=G4int(edep*m_phNConstEc*m_Cpe2pmtEc*0.66*m_QEEc*m_CE*m_peCorFac);
305 //introduce poission distribution of Npe
306 //G4double Navr = NphStep;
307 //G4double NpePoiss = G4double(G4Poisson(Navr));
308 //G4double adcW_corr =5.0;
309 //NphStep=G4int( (NpePoiss - Navr)*adcW_corr + Navr );
310
311 if (m_G4Svc->TofRootFlag())
312 m_NphAllSteps += NphStep;
313 //std::cout << "m_G4Svc->TofRootFlag(): " << m_G4Svc->TofRootFlag() << std::endl;
314
315 G4double ddS, ddT;
316 if (NphStep>0)
317 {
318 for (G4int i=0;i<NphStep;i++)
319 {
320 //uniform scintilation in each step
321 ddS=stepL*G4UniformRand();
322 ddT=deltaT*G4UniformRand();
323 G4ThreeVector emtPos;
324 emtPos.setX(pos.x() + nx*ddS);
325 emtPos.setY(pos.y() + ny*ddS);
326 emtPos.setZ(pos.z() + nz*ddS);
327
328 //check scinillation light whether to hit the pmt or not
329 //forb=0/1 for forward(z>0, east) and backward(z<0, west)
330 G4double pathL=0;
331 G4int forb;
332 DirectPh(partId, emtPos, pathL, forb);
333
334
335 //check if photon can reach PMT or not, after attenuation
336
337 G4double ran = G4UniformRand();
338 //G4double attenL = tofPara->GetAtten(scinNb);
339 //G4double attenL = 10.*(m_tofCaliSvc->BAtten(scinNb))/0.75; // cm into mm
340 G4double attenL = m_tofSimSvc->BarAttenLength(scinNb);
341 attenL = 10.*attenL/0.75; // cm into mm
342
343 if (pathL>0 && exp(-pathL/attenL) > ran)
344 {
345 //propagation time in scintillator
346 G4double scinSwim=pathL/cvelScint;
347 //scintillation timing
348 //G4double scinTime=GenPhoton(partId);
349 G4double scinTime=Scintillation(partId);
350
351 //PMT transit time
352 G4double transitTime=TransitTime();
353 //sum up all time components
354 G4double endTime= timeFlight + ddT + scinSwim + scinTime + transitTime;
355 //std::cout << "endtime: " << endTime << std::endl;
356
357 if (m_G4Svc->TofRootFlag())
358 {
359 //m_forb = forb;
360 //m_timeFlight = timeFlight;
361 //m_ddT = ddT;
362 m_scinSwim = scinSwim;
363 //m_scinTime = scinTime;
364 //m_transitTime = transitTime;
365 m_endTime = endTime;
366 m_tupleTof3->write();
367 }
368 //store timing into binned buffer
369 AccuSignal(endTime, forb);
370
371 //update 1st and last timings here
372 if (m_t1st[forb]>endTime) m_t1st[forb] = endTime;
373 if (m_tLast[forb]<endTime) m_tLast[forb]= endTime;
374 }
375 }
376 }
377}
void AccuSignal(G4double, G4int)
G4double Scintillation(G4int)
void DirectPh(G4int, G4ThreeVector, G4double &, G4int &)
G4double BirksLaw(BesTofHit *hit)
static NTuple::Tuple * m_tupleTof3
static NTuple::Item< double > m_NphAllSteps
static NTuple::Item< double > m_scinSwim
static NTuple::Item< double > m_endTime
ITofSimSvc * m_tofSimSvc
G4double GetDeltaT()
Definition: BesTofHit.hh:67
G4ThreeVector GetPDirection()
Definition: BesTofHit.hh:68
G4double GetTime()
Definition: BesTofHit.hh:66
G4ThreeVector GetPos()
Definition: BesTofHit.hh:65
G4int GetPartId()
Definition: BesTofHit.hh:60
G4int GetTrackIndex()
Definition: BesTofHit.hh:58
virtual const double BarAttenLength(unsigned int id)=0

Referenced by Digitize().

◆ TofPmtInit()

void BesTofDigitizerBrV2::TofPmtInit ( )

Definition at line 210 of file BesTofDigitizerBrV2.cc.

211{
212 Initialize();
213
214 m_t1st[0]=100;
215 m_t1st[1]=100;
216 m_tLast[0]=0.;
217 m_tLast[1]=0;
218 m_totalPhot[0]=0;
219 m_totalPhot[1]=0;
220 for (G4int i=0;i<2;i++)
221 for (G4int j=0;j<m_profBinN;j++)
222 m_nPhot[j][i]=0;
223
224 if (m_G4Svc->TofRootFlag())
225 {
226 m_partId = -9;
227 m_scinNb = -9;
228 m_edep = 0;
229 m_nHits = 0;
230 m_time1st0 = 100;
231 m_time1st1 = 100;
232 m_timelast0 = 0;
233 m_timelast1 = 0;
234 m_totalPhot0 = 0;
235 m_totalPhot1 = 0;
236 m_NphAllSteps = 0;
237 m_max0 = 0;
238 m_max1 = 0;
239 m_tdc0 = -999;
240 m_adc0 = -999;
241 m_tdc1 = -999;
242 m_adc1 = -999;
243 }
244}
static NTuple::Item< double > m_tdc1
static NTuple::Item< double > m_max0
static NTuple::Item< double > m_tdc0
static NTuple::Item< double > m_adc1
static NTuple::Item< double > m_adc0
static NTuple::Item< double > m_max1

Referenced by Digitize().

◆ TofPmtRspns()

void BesTofDigitizerBrV2::TofPmtRspns ( G4int  scinNb)

Definition at line 757 of file BesTofDigitizerBrV2.cc.

758{
759 //std::cout << "BesTofDigitizerBrV2::TofPmtRspns()" << std::endl;
761 //to generate PMT signal shape for single photoelectron.
762 //only one time for a job.
763 G4double snpe[m_snpeBinN][2];
764
765 //Model: f(t)=Gain*mv_1pe* t**2 * exp-(t/tau)**2/normal-const
766 //normalization const =sqrt(pi)*tau*tau*tau/4.0
767 //G4double tau = m_riseTime;
768 G4double norma_const;
769 G4double echarge=1.6e-7; //in unit of PC
770
771 //time profile of pmt signals for Back and Forward PMT.
772 G4double profPmt[m_profBinN][2];
773
774 G4double t;
775 G4double tau;
776 G4int n1, n2, ii;
777 G4int phtn;
778 // forb = 0, east
779 for (G4int i=0;i<m_snpeBinN;i++)
780 {
781 tau = tofPara->GetBrERiseTime(scinNb);
782 norma_const = sqrt(CLHEP::pi)*tau*tau*tau/4.0; //in unit of ns**3
783 t = (i+1)*m_timeBinSize;
784 snpe[i][0] = m_Ce*t*t*exp(- (t/tau) * (t/tau) )/norma_const;// Pulse of one single photoelectron
785 }
786 // forb = 1, west
787 for (G4int i=0;i<m_snpeBinN;i++)
788 {
789 tau = tofPara->GetBrWRiseTime(scinNb);
790 norma_const = sqrt(CLHEP::pi)*tau*tau*tau/4.0; //in unit of ns**3
791 t = (i+1)*m_timeBinSize;
792 snpe[i][1] = m_Ce*t*t*exp(- (t/tau) * (t/tau) )/norma_const;
793 }
794 //for barrel and endcap tof: fb=2 or 1
795 G4int fb=2;
796 G4double Npoisson;
797 G4double pmtGain0,pmtGain,relativeGain,smearPMTgain;
798 G4double smearADC[2] = {0.,0.};
799 G4int runId = m_RealizationSvc->getRunId();
800 pmtGain0 = m_tofSimSvc->BarPMTGain();
801
802// if(runId>=-80000 && runId<=-9484)
803// {
804// // After TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 5.E5
805// // High/Low Threshold for barrel: 500/125 mV
806// pmtGain0 = 6.E5;
807// }
808// else
809// {
810// // Before TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 2.5E5
811// // High/Low Threshold for barrel: 600/150 mV
812// pmtGain0 = 5.E5;
813// }
814
815 G4double timeSmear = G4RandGauss::shoot(0,0.020);
816 if (runId>=-22913 && runId<=-20448) {//for 2011-psipp(20448-22913), smear barrel TOF resolution to ~78ps
817 timeSmear = G4RandGauss::shoot(0,0.040);
818 }
819
820 for (G4int j=0; j<fb; j++)
821 {
822 if (m_totalPhot[j] > 0)
823 {
824 n1=G4int(m_t1st[j]/m_timeBinSize);
825 n2=G4int(m_tLast[j]/m_timeBinSize);
826 //std::cout << "n1: " << n1 << std::endl;
827
828 for (G4int i=0;i<m_profBinN;i++)
829 profPmt[i][j]=0.0;
830
831 //generate PMT pulse
833 for (G4int i=n1;i<n2;i++)
834 {
835 phtn=m_nPhot[i][j];
836 if (phtn>0)
837 {
838 while(1) {
839 Npoisson = G4Poisson(10.0);
840 if(Npoisson>0.) break;
841 }
842 while(1) {
843 //pmtGain = j ? tofPara->GetBrWPMTgain(scinNb) : tofPara->GetBrEPMTgain(scinNb);
844 //relativeGain = j ? m_tofCaliSvc->BGainBackward(scinNb) : m_tofCaliSvc->BGainForward(scinNb);
845 relativeGain = j ? m_tofSimSvc->BarGain2(scinNb) : m_tofSimSvc->BarGain1(scinNb);
846 pmtGain = pmtGain0*relativeGain;
847 smearPMTgain = G4RandGauss::shoot(pmtGain,pmtGain/sqrt(Npoisson));
848 //smearPMTgain = pmtGain;
849 if(smearPMTgain>0) break;
850 }
851 smearADC[j] += phtn*smearPMTgain;
852
853 for (G4int ihst=0; ihst<m_snpeBinN; ihst++)
854 {
855 ii=i+ihst;
856 if (ii<m_profBinN)
857 profPmt[ii][j] += smearPMTgain*phtn*snpe[ihst][j];
858 else
859 break;
860 }
861 }
862 }
863
864 //add preamplifier and noise
865 for (int i=0;i<m_profBinN;i++)
866 {
867 if (profPmt[i][j]>0)
868 profPmt[i][j] = m_preGain*profPmt[i][j]+G4RandGauss::shoot(0,m_noiseSigma);
869 }
870
871 //get pulse height
872 G4double max=0;
873 for (int i=n1;i<m_profBinN;i++)
874 {
875 if (profPmt[i][j]>max)
876 max=profPmt[i][j];
877 }
878 if (m_G4Svc->TofRootFlag())
879 {
880 if (j==0) m_max0=max;
881 else m_max1=max;
882 }
883
884 G4double tmp_HLthresh, tmp_LLthresh, adcFactor;
885 G4double ratio;
886
887 if(runId>=-80000 && runId<=-9484)
888 {
889 // After TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 5.E5
890 // High/Low Threshold for barrel: 500/125 mV
891 tmp_HLthresh = m_HLthresh;
892 tmp_LLthresh = m_LLthresh;
893 adcFactor = 5.89;
894 }
895 else
896 {
897 // Before TOF HV adjustment, PMT Gain of barrel TOF in MC is set to 2.5E5
898 // High/Low Threshold for barrel: 600/150 mV
899 tmp_HLthresh = 600;
900 tmp_LLthresh = 150;
901 adcFactor = 4.8;
902 }
903// if(runId>=-80000 && runId<=-9484)
904// {
905// ratio=2.16*1923.8/2197.8;
906// }
907// else
908// {
909// ratio = 2.11*2437.0/3102.9;
910// }
911 tmp_HLthresh = m_tofSimSvc->BarHighThres();
912 tmp_LLthresh = m_tofSimSvc->BarLowThres();
913 ratio = m_tofSimSvc->BarConstant();
914
915 //get final tdc and adc
916 if (max>=tmp_HLthresh)
917 {
918 for (int i=0;i<m_profBinN;i++)
919 {
920 if ( profPmt[i][j] >= tmp_LLthresh )
921 {
922 m_TDC[j] = i*m_timeBinSize + timeSmear +G4RandGauss::shoot(0,0.025); // Adding Electronical Uncertainty of 25ps
923
924 if( m_G4Svc->TofSaturationFlag())
925 {
926 //get ADC[j] using tofQElecSvc
927 double x = m_preGain*smearADC[j]*echarge*ratio;
928 if (j==0)
929 {
930 m_ADC[j] = m_tofQElecSvc->BQChannel1(scinNb,x);
931 }
932 else
933 {
934 m_ADC[j] = m_tofQElecSvc->BQChannel2(scinNb,x);
935 }
936 }
937 else
938 m_ADC[j] = m_preGain*smearADC[j]*echarge*adcFactor;
939
940
941 if (m_G4Svc->TofRootFlag())
942 {
943 if (j==0) {
944 m_tdc0 = m_TDC[0];
945 m_adc0 = m_ADC[0];
946 }
947 else {
948 m_tdc1 = m_TDC[1];
949 m_adc1 = m_ADC[1];
950 }
951 }
952 break;
953 }
954 }
955 }
956 }
957 }
958}
const G4int m_snpeBinN
Double_t x[10]
ITofQElecSvc * m_tofQElecSvc
G4double GetBrWRiseTime(int scinNb)
G4double GetBrERiseTime(int scinNb)
bool TofSaturationFlag()
Definition: G4Svc.h:122
virtual const double BQChannel2(int id, double q)=0
virtual const double BQChannel1(int id, double q)=0
virtual const double BarConstant()=0
virtual const double BarLowThres()=0
virtual const double BarPMTGain()=0
virtual const double BarGain2(unsigned int id)=0
virtual const double BarHighThres()=0
virtual const double BarGain1(unsigned int id)=0
int t()
Definition: t.c:1

Referenced by Digitize().

◆ TransitTime()

G4double BesTofDigitizerBrV2::TransitTime ( )

Definition at line 740 of file BesTofDigitizerBrV2.cc.

741{
742 //get time transit spread
743 return G4RandGauss::shoot(m_ttsMean,m_ttsSigma);
744}

Referenced by TofPmtAccum().


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