00001 //---------------------------------------------------------------------------// 00002 // BOOST --- BESIII Object_Oriented Simulation Tool // 00003 //---------------------------------------------------------------------------// 00004 //Description: 00005 //Author: Dengzy 00006 //Created: Mar, 2004 00007 //Modified: 00008 //Comment: 00009 //---------------------------------------------------------------------------// 00010 //$Id: BesTofDigitizerEcV1.cc 00011 00012 #include "BesTofDigitizerEcV1.hh" 00013 #include "BesTofDigi.hh" 00014 #include "BesTofHit.hh" 00015 #include "G4DigiManager.hh" 00016 #include "BesTofGeoParameter.hh" 00017 #include "Randomize.hh" 00018 #include "TMath.h" 00019 #include <math.h> 00020 00021 BesTofDigitizerEcV1::BesTofDigitizerEcV1() 00022 { 00023 BesTofGeoParameter* tofPara = BesTofGeoParameter::GetInstance(); 00024 m_bucketPosR = tofPara->GetBucketPosR(); // 445 ??? 00025 } 00026 00027 BesTofDigitizerEcV1::~BesTofDigitizerEcV1() 00028 { 00029 } 00030 00031 void BesTofDigitizerEcV1::Digitize(ScintSingle* scint, BesTofDigitsCollection* DC) 00032 { 00033 G4cout<<"BesTofDigitizerEcV1::Digitize"<<G4endl; 00034 m_besTofDigitsCollection = DC; 00035 G4DigiManager* digiManager = G4DigiManager::GetDMpointer(); 00036 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection"); 00037 m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID)); 00038 if (m_THC) 00039 { 00040 G4int partId, scinNb, nHits; 00041 BesTofHit* hit; 00042 partId=scint->GetPartId(); 00043 scinNb=scint->GetScinNb(); 00044 nHits=scint->GetHitIndexes()->size(); 00045 TofPmtInit(); 00046 for (G4int j=0;j<nHits;j++) 00047 { 00048 hit= (*m_THC)[( *(scint->GetHitIndexes()) )[j]]; 00049 TofPmtAccum(hit); 00050 } 00051 00052 Smear(scinNb); 00053 if ( m_TDC[0]>0 ) 00054 { 00055 BesTofDigi* digi = new BesTofDigi; 00056 digi->SetTrackIndex(m_trackIndex); 00057 digi->SetPartId(partId); 00058 digi->SetScinNb(scinNb); 00059 digi->SetForwADC( m_ADC[0]) ; 00060 digi->SetForwTDC( m_TDC[0]) ; 00061 digi->SetBackADC( m_ADC[1]) ; 00062 digi->SetBackTDC( m_TDC[1]) ; 00063 m_besTofDigitsCollection->insert(digi); 00064 } 00065 } 00066 } 00067 00068 void BesTofDigitizerEcV1::TofPmtInit() 00069 { 00070 Initialize(); 00071 m_t1st = 9999.; 00072 } 00073 00074 void BesTofDigitizerEcV1::TofPmtAccum(BesTofHit* hit) 00075 { 00076 G4int trackIndex = hit->GetTrackIndex(); 00077 G4int scinNb = hit->GetScinNb(); 00078 G4double time = hit->GetTime(); 00079 if (time<m_globalTime) 00080 { 00081 m_globalTime = time; 00082 m_trackIndex = trackIndex; 00083 } 00084 G4double edep = hit->GetEdep(); 00085 G4ThreeVector pos = hit->GetPos(); 00086 G4double posx = pos.x(); 00087 G4double posy = pos.y(); 00088 G4double pathL=abs(m_bucketPosR-sqrt(posx*posx+posy*posy)); 00089 G4double atten; 00090 atten = m_tofCaliSvc->EAtten(scinNb); 00091 m_ADC[0] += edep*exp(-pathL/atten); 00092 00093 if (time<m_t1st) 00094 { 00095 m_t1st = time; 00096 m_r = sqrt(posx*posx+posy*posy); 00097 m_TDC[0] = m_t1st; 00098 } 00099 } 00100 00101 void BesTofDigitizerEcV1::Smear(G4int scinNb) 00102 { 00103 /*G4double tofRes = 0.08; 00104 for(G4int i=0;i<2;i++) 00105 { 00106 m_TDC[i] += tofRes * G4RandGauss::shoot(); 00107 }*/ 00108 00109 double pp[8]; 00110 for (int i=0;i<8;i++) 00111 { 00112 pp[i]=m_tofCaliSvc->ETof(scinNb)->getP(i); 00113 } 00114 m_ADC[0] *= 7.; 00115 m_TDC[0] += (pp[0]+pp[1]*m_r)/TMath::Sqrt(m_ADC[0])+ 00116 pp[2]/m_ADC[0]+ 00117 pp[3]*m_r/m_ADC[0]+ 00118 pp[4]*m_r+ 00119 pp[5]*m_r*m_r+ 00120 pp[6]*m_r*m_r*m_r+ 00121 pp[7]; 00122 }