14 #include "G4VPhysicalVolume.hh" 17 #include "G4ParticleTable.hh" 18 #include "Randomize.hh" 19 #include "CLHEP/Units/PhysicalConstants.h" 20 #include "CLHEP/Units/SystemOfUnits.h" 26 #include "TBranchObject.h" 32 nMomBin(0), totEvents(0), evtPerBin(0),
33 nBinsE(0),nBinsEta(0),nBinsPhi(0),
34 nEvtPerBinE(0),nEvtPerBinEta(0),nEvtPerBinPhi(0),
35 SLenergies(),SLetas(),SLphis() {
70 if (pTreeName.find(
".") == 0) pTreeName.erase(0,2);
71 const char* nTree = pTreeName.c_str();
72 hf = TFile::Open(nTree);
76 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" failed";
78 <<
"Opening of " << pTreeName <<
" fails\n";
80 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" successfully";
84 TTree*
event = (TTree *)
hf ->Get(
"CastorCherenkovPhotons");
86 evtInfo = (TBranchObject *)
event->GetBranch(branchEvInfo.c_str());
90 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: " << branchEvInfo.c_str()
91 <<
" Branch does not exit in Event";
92 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Event information absent\n";
95 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: Events Tree does not exist";
96 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Events tree absent\n";
100 emBranch = (TBranchObject *)
event->GetBranch(branchEM.c_str());
102 hadBranch = (TBranchObject *)
event->GetBranch(branchHAD.c_str());
104 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: Branch " << branchEM
105 <<
" has " <<
emBranch->GetEntries()
106 <<
" entries and Branch " << branchHAD
143 edm::LogInfo(
"CastorShower") <<
" CastorShowerLibrary::loadEventInfo : " 144 <<
"\n \n Total number of events : " <<
totEvents 145 <<
"\n Number of bins (E) : " <<
nBinsE 147 <<
"\n Number of bins (Eta) : " <<
nBinsEta 149 <<
"\n Number of bins (Phi) : " <<
nBinsPhi 150 <<
"\n Number of events/bin (Phi) : " <<
nEvtPerBinPhi <<
"\n";
153 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLenergies[" <<
i <<
"] = " 156 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLetas[" <<
i <<
"] = " 159 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary: SLphis[" <<
i <<
"] = " 167 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
168 G4Track *
track = aStep->GetTrack();
170 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
182 double pin = preStepPoint->GetTotalEnergy();
183 double zint = hitPoint.z();
184 double R=
sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
186 double phiin = atan2(hitPoint.y(),hitPoint.x());
194 select(0, pin, etain, phiin);
196 select(1, pin, etain, phiin);
199 hit = (*showerEvent);
218 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: ";
232 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: Record " << record
233 <<
" of type " << type <<
" with " << nHit
234 <<
" CastorShowerHits";
258 double r = G4UniformRand();
273 if(phiin < phiMin) phiin = phiin +
M_PI ;
274 if(phiin >= phiMin && phiin < phiMax) {
277 double remainder = fmod(phiin, phiMax) ;
278 phiin = phiMin + remainder ;
284 if (ienergy==-1) ienergy=0;
285 if (ieta==-1) ieta=0;
290 edm::LogInfo(
"CastorShower") <<
"CastorShowerLibrary:: Select record " << irec
291 <<
" of type " <<
type ;
327 for(;i<
SLetas.size()-1;i++)
328 if (eta >=
SLetas.at(i) && eta <
SLetas.at(i+1))
return (
int)
i;
330 if (eta>=
SLetas.at(i))
return (
int)
i;
346 for(;i<
SLphis.size()-1;i++)
347 if (phi >=
SLphis.at(i) && phi <
SLphis.at(i+1))
return (
int)
i;
349 if (phi>=
SLphis.at(i))
return (
int)
i;
void Clear(Option_t *option="") override
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int FindEnergyBin(double)
void select(int, double, double=0, double=9)
CastorShowerLibrary(const std::string &name, edm::ParameterSet const &p)
Geom::Theta< T > theta() const
std::vector< double > SLetas
unsigned int nEvtPerBinPhi
CastorShowerEvent getShowerHits(const G4Step *, bool &)
std::vector< double > SLphis
TBranchObject * hadBranch
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
unsigned int getNEvtPerBin()
static bool isStableHadronIon(const G4Track *)
void initFile(edm::ParameterSet const &)
std::vector< double > SLenergies
CastorShowerLibraryInfo * eventInfo
void loadEventInfo(TBranchObject *)
CastorShowerEvent * showerEvent
static bool isGammaElectronPositron(int pdgCode)
unsigned int nEvtPerBinEta