13 #include "G4VPhysicalVolume.hh"
16 #include "G4ParticleTable.hh"
17 #include "Randomize.hh"
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
23 : hf(0), evtInfo(0), emBranch(0), hadBranch(0),
24 nMomBin(0), totEvents(0), evtPerBin(0),
25 nBinsE(0),nBinsEta(0),nBinsPhi(0),
26 nEvtPerBinE(0),nEvtPerBinEta(0),nEvtPerBinPhi(0),
27 SLenergies(),SLetas(),SLphis() {
64 if (pTreeName.find(
".") == 0) pTreeName.erase(0,2);
65 const char* nTree = pTreeName.c_str();
66 hf = TFile::Open(nTree);
70 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" failed";
72 <<
"Opening of " << pTreeName <<
" fails\n";
74 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" successfully";
78 TTree*
event = (TTree *)
hf ->Get(
"CastorCherenkovPhotons");
80 evtInfo = (TBranchObject *)
event->GetBranch(branchEvInfo.c_str());
84 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: " << branchEvInfo.c_str()
85 <<
" Branch does not exit in Event";
86 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Event information absent\n";
89 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: Events Tree does not exist";
90 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Events tree absent\n";
94 emBranch = (TBranchObject *)
event->GetBranch(branchEM.c_str());
98 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: Branch " << branchEM
100 <<
" entries and Branch " << branchHAD
140 edm::LogInfo(
"CastorShower") <<
" CastorShowerLibrary::loadEventInfo : "
141 <<
"\n \n Total number of events : " <<
totEvents
142 <<
"\n Number of bins (E) : " <<
nBinsE
144 <<
"\n Number of bins (Eta) : " <<
nBinsEta
146 <<
"\n Number of bins (Phi) : " <<
nBinsPhi
147 <<
"\n Number of events/bin (Phi) : " <<
nEvtPerBinPhi <<
"\n";
150 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLenergies[" <<
i <<
"] = "
153 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLetas[" <<
i <<
"] = "
156 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLphis[" <<
i <<
"] = "
171 G4String particleName;
173 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary::initParticleTable"
174 <<
" *** Accessing PDGEncoding ***" ;
176 emPDG = theParticleTable->FindParticle(particleName=
"e-")->GetPDGEncoding();
177 epPDG = theParticleTable->FindParticle(particleName=
"e+")->GetPDGEncoding();
178 gammaPDG = theParticleTable->FindParticle(particleName=
"gamma")->GetPDGEncoding();
179 pi0PDG = theParticleTable->FindParticle(particleName=
"pi0")->GetPDGEncoding();
180 etaPDG = theParticleTable->FindParticle(particleName=
"eta")->GetPDGEncoding();
181 nuePDG = theParticleTable->FindParticle(particleName=
"nu_e")->GetPDGEncoding();
182 numuPDG = theParticleTable->FindParticle(particleName=
"nu_mu")->GetPDGEncoding();
183 nutauPDG = theParticleTable->FindParticle(particleName=
"nu_tau")->GetPDGEncoding();
184 anuePDG = theParticleTable->FindParticle(particleName=
"anti_nu_e")->GetPDGEncoding();
185 anumuPDG = theParticleTable->FindParticle(particleName=
"anti_nu_mu")->GetPDGEncoding();
186 anutauPDG = theParticleTable->FindParticle(particleName=
"anti_nu_tau")->GetPDGEncoding();
187 geantinoPDG = theParticleTable->FindParticle(particleName=
"geantino")->GetPDGEncoding();
188 mumPDG = theParticleTable->FindParticle(particleName=
"mu-")->GetPDGEncoding();
189 mupPDG = theParticleTable->FindParticle(particleName=
"mu+")->GetPDGEncoding();
192 LogDebug(
"CastorShower") <<
"CastorShowerLibrary: Particle codes for e- = " <<
emPDG
198 <<
", anti_nu_mu = " <<
anumuPDG <<
", anti_nu_tau = "
203 edm::LogInfo(
"CastorShower") <<
" ***** Successfully called: "
204 <<
"CastorShowerLibrary::initParticleTable() ***** " ;
213 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
215 G4Track * track = aStep->GetTrack();
217 const G4DynamicParticle *aParticle = track->GetDynamicParticle();
218 G4ThreeVector momDir = aParticle->GetMomentumDirection();
221 G4ThreeVector hitPoint = preStepPoint->GetPosition();
222 G4String partType = track->GetDefinition()->GetParticleName();
223 int parCode = track->GetDefinition()->GetPDGEncoding();
235 double pin = preStepPoint->GetTotalEnergy();
236 double etain = momDir.getEta();
237 double phiin = momDir.getPhi();
239 double zint = hitPoint.z();
240 double R=
sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
242 phiin = atan2(hitPoint.y(),hitPoint.x());
250 select(0, pin, etain, phiin);
257 select(1, pin, etain, phiin);
265 hit = (*showerEvent);
285 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: ";
299 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: Record " << record
300 <<
" of type " << type <<
" with " << nHit
301 <<
" CastorShowerHits";
325 double r = G4UniformRand();
372 double phiMax =
M_PI/4 ;
373 if(phiin < phiMin) phiin = phiin +
M_PI ;
374 if(phiin >= phiMin && phiin < phiMax) {
377 double remainder = fmod(phiin , M_PI/4) ;
378 phiin = phiMin + remainder ;
384 if (ienergy==-1) ienergy=0;
385 if (ieta==-1) ieta=0;
390 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary:: Select record " << irec
391 <<
" of type " <<
type ;
421 for(;i<
SLetas.size()-1;i++)
422 if (eta >=
SLetas.at(i) && eta <
SLetas.at(i+1))
return (
int)
i;
424 if (eta>=
SLetas.at(i))
return (
int)
i;
437 for(;i<
SLphis.size()-1;i++)
438 if (phi >=
SLphis.at(i) && phi <
SLphis.at(i+1))
return (
int)
i;
440 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)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
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