25:G4VDigitizerModule(modName),m_emcCalibConstSvc(0)
27 collectionName.push_back(
"BesEmcDigitsCollection");
28 m_besEmcDigitsCollection = 0;
31 ISvcLocator* svcLocator = Gaudi::svcLocator();
33 StatusCode sc=svcLocator->service(
"G4Svc", iG4Svc);
34 m_G4Svc=
dynamic_cast<G4Svc *
>(iG4Svc);
37 if(m_G4Svc->EmcRootFlag())
39 m_tupleEmc1 = m_G4Svc->GetTupleEmc1();
40 sc = m_tupleEmc1->addItem(
"partId",m_partId);
41 sc = m_tupleEmc1->addItem(
"nTheta",m_nTheta);
42 sc = m_tupleEmc1->addItem(
"nPhi",m_nPhi);
43 sc = m_tupleEmc1->addItem(
"edep",m_eDep);
44 sc = m_tupleEmc1->addItem(
"nHits",m_nHits);
45 sc = m_tupleEmc1->addItem(
"adc",m_adc);
46 sc = m_tupleEmc1->addItem(
"tdc",m_tdc);
48 m_tupleEmc2 = m_G4Svc->GetTupleEmc2();
49 sc = m_tupleEmc2->addItem(
"etot",m_eTot);
50 sc = m_tupleEmc2->addItem(
"nDigi",m_nDigi);
54 sc = svcLocator->service(
"EmcCalibConstSvc", m_emcCalibConstSvc);
55 if(sc != StatusCode::SUCCESS) {
56 G4cout <<
"BesEmcDigitizer Error: Can't get EmcCalibConstSvc." << G4endl;
75 (
"BesEmcDigitizer",
"BesEmcDigitsCollection");
76 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
81 EHCID = DigiMan->GetHitsCollectionID(
"BesEmcHitsCollection");
90 m_crystalGroup =
new vector<CrystalSingle*>;
92 G4int size=m_crystalGroup->size();
94 G4int partId, nTheta,
nPhi, nHits;
95 G4double eTot=0, eDigi;
98 G4double coherentNoise = RandGauss::shoot()*m_G4Svc->EmcCoherentNoise();
100 for(G4int i=0;i<size;i++)
102 cryst = (*m_crystalGroup)[i];
114 const int indexSize = 200;
115 G4double e[indexSize];
116 for(G4int i=0;i<indexSize;i++)
121 for(G4int j=0;j<nHits;j++)
126 if(index<indexSize&&index>=0)
129 G4cout<<
"Track index overload!"<<G4endl;
133 for(G4int i=1;i<indexSize;i++)
148 digi->
SetTime(m_G4Svc->EmcTime());
152 if(m_G4Svc->EmcNoiseLevel()>0)
153 wave->
addElecNoise(m_G4Svc->EmcIncoherentNoise(),coherentNoise);
156 m_energy = wave->
max(
bin);
158 m_energy -= 0.46*MeV;
162 if(m_G4Svc->EmcLightOutput())
164 G4int index = m_emcCalibConstSvc->getIndex(partId,nTheta,
nPhi);
165 G4double adc2e = m_emcCalibConstSvc->getDigiCalibConst(index);
167 G4double CrystalDeadEcut = m_emcCalibConstSvc->getCrystalDeadEcut(index);
169 if (m_G4Svc->EmcElecSaturation()==1){
170 G4double emaxData = m_emcCalibConstSvc->getCrystalEmaxData(index);
182 else if (m_G4Svc->EmcElecSatuDead()==1&&CrystalDeadEcut>0&&m_energy/1000.0>CrystalDeadEcut)
198 if(m_G4Svc->EmcRootFlag())
207 m_tupleEmc1->write();
213 m_besEmcDigitsCollection->insert(digi);
218 if(m_G4Svc->EmcNoiseLevel()==2)
220 else if(m_G4Svc->EmcNoiseLevel()==3)
225 if(m_G4Svc->EmcRootFlag())
229 m_tupleEmc2->write();
232 StoreDigiCollection(m_besEmcDigitsCollection);
234 for(
size_t i=0;i<m_crystalGroup->size();i++)
236 delete (*m_crystalGroup)[i];
238 m_crystalGroup->clear();
239 delete m_crystalGroup;
294 vector<BesEmcDigi*>* vecDC = m_besEmcDigitsCollection->GetVector();
295 G4int nDigi = m_besEmcDigitsCollection->entries();
296 G4int partMax,thetaMax,phiMax;
297 partMax=thetaMax=phiMax=-99;
300 for(G4int i=0;i<nDigi;i++) {
312 G4int thetan,thetap,phin,phip;
320 }
else if(thetaMax==1) {
330 }
else if(phiMax==1) {
338 for(G4int theta=thetan;theta<=thetap;theta++) {
339 for(G4int phi=phin;phi<=phip;phi++) {
343 for(G4int i=0;i<nDigi;i++) {
361 digi->
SetTime(m_G4Svc->EmcTime());
365 wave->
addElecNoise(m_G4Svc->EmcIncoherentNoise(),coherentNoise);
369 m_energy = wave->
max(
bin);
371 if(m_G4Svc->EmcLightOutput()) {
382 ecorr = -0.1285*log(m_energy/6805.);
384 ecorr = -2.418+9.513e-4*m_energy;
387 if(m_energy-ecorr>m_G4Svc->EmcNoiseThreshold()) {
388 m_besEmcDigitsCollection->insert(digi);
402 vector<BesEmcDigi*>* vecDC = m_besEmcDigitsCollection->GetVector();
403 G4int nDigi = m_besEmcDigitsCollection->entries();
406 for(G4int part=0;part<3;part++) {
415 for(G4int theta=0;theta<thetaNb;theta++) {
424 for(G4int phi=0;phi<phiNb;phi++) {
431 for(G4int i=0;i<nDigi;i++) {
450 bool fastSimulation =
true;
453 m_energy = RandGauss::shoot()*m_G4Svc->EmcNoiseSigma();
454 m_energy += m_G4Svc->EmcNoiseMean();
455 digi->
SetTime((G4int)(G4UniformRand()*60));
460 digi->
SetTime(m_G4Svc->EmcTime());
463 wave->
addElecNoise(m_G4Svc->EmcIncoherentNoise(),coherentNoise);
467 m_energy = wave->
max(
bin);
472 if(m_G4Svc->EmcLightOutput()) {
480 ecorr = -0.1285*log(m_energy/6805.);
482 ecorr = -2.418+9.513e-4*m_energy;
485 if(m_energy-ecorr>m_G4Svc->EmcNoiseThreshold()) {
486 m_besEmcDigitsCollection->insert(digi);