13 #include "G4VPhysicalVolume.hh" 16 #include "G4ParticleTable.hh" 17 #include "Randomize.hh" 18 #include "G4PhysicalConstants.hh" 19 #include "CLHEP/Units/GlobalSystemOfUnits.h" 24 :
hf(0), evtInfo(0), emBranch(0), hadBranch(0),
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();
216 G4Track *
track = aStep->GetTrack();
218 const G4DynamicParticle *aParticle = track->GetDynamicParticle();
219 G4ThreeVector momDir = aParticle->GetMomentumDirection();
222 G4ThreeVector hitPoint = preStepPoint->GetPosition();
223 G4String partType = track->GetDefinition()->GetParticleName();
224 int parCode = track->GetDefinition()->GetPDGEncoding();
236 double pin = preStepPoint->GetTotalEnergy();
240 double zint = hitPoint.z();
241 double R=
sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
243 double phiin = atan2(hitPoint.y(),hitPoint.x());
251 select(0, pin, etain, phiin);
258 select(1, pin, etain, phiin);
266 hit = (*showerEvent);
286 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: ";
300 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: Record " << record
301 <<
" of type " << type <<
" with " << nHit
302 <<
" CastorShowerHits";
326 double r = G4UniformRand();
374 if(phiin < phiMin) phiin = phiin +
M_PI ;
375 if(phiin >= phiMin && phiin < phiMax) {
378 double remainder = fmod(phiin , M_PI/4) ;
379 phiin = phiMin + remainder ;
385 if (ienergy==-1) ienergy=0;
386 if (ieta==-1) ieta=0;
391 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary:: Select record " << irec
392 <<
" of type " <<
type ;
422 for(;i<
SLetas.size()-1;i++)
423 if (eta >=
SLetas.at(i) && eta <
SLetas.at(i+1))
return (
int)
i;
425 if (eta>=
SLetas.at(i))
return (
int)
i;
438 for(;i<
SLphis.size()-1;i++)
439 if (phi >=
SLphis.at(i) && phi <
SLphis.at(i+1))
return (
int)
i;
441 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