11#include "BesEmcDigitizer.hh"
12#include "BesEmcDigi.hh"
13#include "BesEmcHit.hh"
14#include "BesEmcWaveform.hh"
15#include "G4DigiManager.hh"
16#include "BesEmcParameter.hh"
17#include "Randomize.hh"
19#include "GaudiKernel/Bootstrap.h"
20#include "GaudiKernel/ISvcLocator.h"
21#include "G4Svc/G4Svc.h"
22#include "EmcCalibConstSvc/EmcCalibConstSvc.h"
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);
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);
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;
65void BesEmcDigitizer::Initialize()
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;
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++)
156 m_energy = wave->
max(
bin);
158 m_energy -= 0.46*MeV;
164 G4int index = m_emcCalibConstSvc->
getIndex(partId,nTheta,
nPhi);
201 m_tupleEmc1->write();
207 m_besEmcDigitsCollection->insert(digi);
223 m_tupleEmc2->write();
226 StoreDigiCollection(m_besEmcDigitsCollection);
228 for(
size_t i=0;i<m_crystalGroup->size();i++)
230 delete (*m_crystalGroup)[i];
232 m_crystalGroup->clear();
233 delete m_crystalGroup;
239 G4int partId, nTheta,
nPhi, size,
flag;
242 G4int nHits = m_EHC->entries();
245 for(G4int i=0;i<nHits;i++)
252 size = m_crystalGroup->size();
258 for(G4int j=0; j<size;j++)
260 oldCryst = (*m_crystalGroup)[j];
279 m_crystalGroup->push_back(newCryst);
288 vector<BesEmcDigi*>* vecDC = m_besEmcDigitsCollection->GetVector();
289 G4int nDigi = m_besEmcDigitsCollection->entries();
290 G4int partMax,thetaMax,phiMax;
291 partMax=thetaMax=phiMax=-99;
294 for(G4int i=0;i<nDigi;i++) {
306 G4int thetan,thetap,phin,phip;
314 }
else if(thetaMax==1) {
324 }
else if(phiMax==1) {
332 for(G4int theta=thetan;theta<=thetap;theta++) {
333 for(G4int phi=phin;phi<=phip;phi++) {
337 for(G4int i=0;i<nDigi;i++) {
363 m_energy = wave->
max(
bin);
376 ecorr = -0.1285*log(m_energy/6805.);
378 ecorr = -2.418+9.513e-4*m_energy;
382 m_besEmcDigitsCollection->insert(digi);
396 vector<BesEmcDigi*>* vecDC = m_besEmcDigitsCollection->GetVector();
397 G4int nDigi = m_besEmcDigitsCollection->entries();
400 for(G4int part=0;part<3;part++) {
409 for(G4int theta=0;theta<thetaNb;theta++) {
418 for(G4int phi=0;phi<phiNb;phi++) {
425 for(G4int i=0;i<nDigi;i++) {
444 bool fastSimulation =
true;
449 digi->
SetTime((G4int)(G4UniformRand()*60));
461 m_energy = wave->
max(
bin);
474 ecorr = -0.1285*log(m_energy/6805.);
476 ecorr = -2.418+9.513e-4*m_energy;
480 m_besEmcDigitsCollection->insert(digi);
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
G4TDigiCollection< BesEmcDigi > BesEmcDigitsCollection
G4THitsCollection< BesEmcHit > BesEmcHitsCollection
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
void SetTrackIndex(G4int index)
void SetTime(G4double time)
void SetEnergy(G4double energy)
void SetThetaNb(G4int nTheta)
BesEmcWaveform * GetWaveform()
void SetWaveform(BesEmcWaveform *wave)
void SetPhiNb(G4int nPhi)
virtual void AddNoiseAll(G4double coherentNoise)
virtual void AddNoise5x5(G4double coherentNoise)
virtual void GroupHits(BesEmcHitsCollection *)
BesEmcDigitizer(G4String modName)
G4double GetEdepCrystal()
G4int GetNumThetaCrystal()
G4int GetCryInOneLayer(G4int nb)
static BesEmcParameter & GetInstance()
G4double GetLightOutput(G4int i)
void SetNTheta(G4int theta)
vector< G4int > * GetHitIndexes()
double EmcNoiseThreshold()
double EmcIncoherentNoise()
double EmcCoherentNoise()
NTuple::Tuple * GetTupleEmc2()
NTuple::Tuple * GetTupleEmc1()
virtual double getDigiCalibConst(int No) const =0
virtual int getIndex(unsigned int PartId, unsigned int ThetaIndex, unsigned int PhiIndex) const =0
virtual double getCrystalEmaxData(int Index) const =0