13 #include "G4VPhysicalVolume.hh" 16 #include "G4ParticleTable.hh" 17 #include "Randomize.hh" 18 #include "G4PhysicalConstants.hh" 19 #include "CLHEP/Units/GlobalSystemOfUnits.h" 25 nMomBin(0), totEvents(0), evtPerBin(0),
26 nBinsE(0),nBinsEta(0),nBinsPhi(0),
27 nEvtPerBinE(0),nEvtPerBinEta(0),nEvtPerBinPhi(0),
28 SLenergies(),SLetas(),SLphis() {
65 if (pTreeName.find(
".") == 0) pTreeName.erase(0,2);
66 const char* nTree = pTreeName.c_str();
67 hf = TFile::Open(nTree);
71 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" failed";
73 <<
"Opening of " << pTreeName <<
" fails\n";
75 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" successfully";
79 TTree*
event = (TTree *)
hf ->Get(
"CastorCherenkovPhotons");
81 evtInfo = (TBranchObject *)
event->GetBranch(branchEvInfo.c_str());
85 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: " << branchEvInfo.c_str()
86 <<
" Branch does not exit in Event";
87 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Event information absent\n";
90 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: Events Tree does not exist";
91 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Events tree absent\n";
95 emBranch = (TBranchObject *)
event->GetBranch(branchEM.c_str());
99 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: Branch " << branchEM
100 <<
" has " <<
emBranch->GetEntries()
101 <<
" entries and Branch " << branchHAD
141 edm::LogInfo(
"CastorShower") <<
" CastorShowerLibrary::loadEventInfo : " 142 <<
"\n \n Total number of events : " <<
totEvents 143 <<
"\n Number of bins (E) : " <<
nBinsE 145 <<
"\n Number of bins (Eta) : " <<
nBinsEta 147 <<
"\n Number of bins (Phi) : " <<
nBinsPhi 148 <<
"\n Number of events/bin (Phi) : " <<
nEvtPerBinPhi <<
"\n";
151 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLenergies[" <<
i <<
"] = " 154 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLetas[" <<
i <<
"] = " 157 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLphis[" <<
i <<
"] = " 174 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary::initParticleTable" 175 <<
" *** Accessing PDGEncoding ***" ;
177 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
178 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
179 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
180 pi0PDG = theParticleTable->FindParticle(particleName=
"pi0")->GetPDGEncoding();
181 etaPDG = theParticleTable->FindParticle(particleName=
"eta")->GetPDGEncoding();
182 nuePDG = theParticleTable->FindParticle(particleName=
"nu_e")->GetPDGEncoding();
183 numuPDG = theParticleTable->FindParticle(particleName=
"nu_mu")->GetPDGEncoding();
184 nutauPDG = theParticleTable->FindParticle(particleName=
"nu_tau")->GetPDGEncoding();
185 anuePDG = theParticleTable->FindParticle(particleName=
"anti_nu_e")->GetPDGEncoding();
186 anumuPDG = theParticleTable->FindParticle(particleName=
"anti_nu_mu")->GetPDGEncoding();
187 anutauPDG = theParticleTable->FindParticle(particleName=
"anti_nu_tau")->GetPDGEncoding();
188 geantinoPDG = theParticleTable->FindParticle(particleName=
"geantino")->GetPDGEncoding();
189 mumPDG = theParticleTable->FindParticle(particleName=
"mu-")->GetPDGEncoding();
190 mupPDG = theParticleTable->FindParticle(particleName=
"mu+")->GetPDGEncoding();
193 LogDebug(
"CastorShower") <<
"CastorShowerLibrary: Particle codes for e- = " <<
emPDG 199 <<
", anti_nu_mu = " <<
anumuPDG <<
", anti_nu_tau = " 204 edm::LogInfo(
"CastorShower") <<
" ***** Successfully called: " 205 <<
"CastorShowerLibrary::initParticleTable() ***** " ;
214 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
215 G4Track *
track = aStep->GetTrack();
217 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
218 G4String partType = track->GetDefinition()->GetParticleName();
219 int parCode = track->GetDefinition()->GetPDGEncoding();
231 double pin = preStepPoint->GetTotalEnergy();
232 double zint = hitPoint.z();
233 double R=
sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
235 double phiin = atan2(hitPoint.y(),hitPoint.x());
243 select(0, pin, etain, phiin);
250 select(1, pin, etain, phiin);
258 hit = (*showerEvent);
278 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: ";
292 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: Record " << record
293 <<
" of type " << type <<
" with " << nHit
294 <<
" CastorShowerHits";
318 double r = G4UniformRand();
366 if(phiin < phiMin) phiin = phiin +
M_PI ;
367 if(phiin >= phiMin && phiin < phiMax) {
370 double remainder = fmod(phiin , M_PI/4) ;
371 phiin = phiMin + remainder ;
377 if (ienergy==-1) ienergy=0;
378 if (ieta==-1) ieta=0;
383 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary:: Select record " << irec
384 <<
" of type " <<
type ;
414 for(;i<
SLetas.size()-1;i++)
415 if (eta >=
SLetas.at(i) && eta <
SLetas.at(i+1))
return (
int)
i;
417 if (eta>=
SLetas.at(i))
return (
int)
i;
430 for(;i<
SLphis.size()-1;i++)
431 if (phi >=
SLphis.at(i) && phi <
SLphis.at(i+1))
return (
int)
i;
433 if (phi>=
SLphis.at(i))
return (
int)
i;
T getParameter(std::string const &) const
void initParticleTable(G4ParticleTable *)
T getUntrackedParameter(std::string const &, T const &) const
int FindEnergyBin(double)
void select(int, double, double=0, double=9)
Geom::Theta< T > theta() const
std::vector< double > SLetas
unsigned int nEvtPerBinPhi
std::vector< double > SLphis
TBranchObject * hadBranch
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
CastorShowerLibrary(std::string &name, edm::ParameterSet const &p)
unsigned int getNEvtPerBin()
void initFile(edm::ParameterSet const &)
std::vector< double > SLenergies
CastorShowerLibraryInfo * eventInfo
void loadEventInfo(TBranchObject *)
CastorShowerEvent getShowerHits(G4Step *, bool &)
CastorShowerEvent * showerEvent
unsigned int nEvtPerBinEta