14 #include "G4VPhysicalVolume.hh"
17 #include "G4ParticleTable.hh"
18 #include "Randomize.hh"
19 #include "CLHEP/Units/PhysicalConstants.h"
20 #include "CLHEP/Units/SystemOfUnits.h"
80 if (pTreeName.find(
'.') == 0)
81 pTreeName.erase(0, 2);
82 const char* nTree = pTreeName.c_str();
83 hf = TFile::Open(nTree);
87 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" failed";
88 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Opening of " << pTreeName <<
" fails\n";
90 edm::LogVerbatim(
"CastorShower") <<
"CastorShowerLibrary: opening " << nTree <<
" successfully";
94 TTree*
event =
hf->Get<TTree>(
"CastorCherenkovPhotons");
96 auto evtInfo =
event->GetBranch(branchEvInfo.c_str());
100 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: " << branchEvInfo.c_str()
101 <<
" Branch does not exit in Event";
102 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Event information absent\n";
105 edm::LogError(
"CastorShower") <<
"CastorShowerLibrary: Events Tree does not exist";
106 throw cms::Exception(
"Unknown",
"CastorShowerLibrary") <<
"Events tree absent\n";
110 emBranch =
event->GetBranch(branchEM.c_str());
113 hadBranch =
event->GetBranch(branchHAD.c_str());
117 <<
" entries and Branch " << branchHAD <<
" has " <<
hadBranch->GetEntries()
134 auto* eventInfo = &tempInfo;
135 branch->SetAddress(&eventInfo);
139 totEvents = eventInfo->Energy.getNEvts();
140 nBinsE = eventInfo->Energy.getNBins();
143 nBinsEta = eventInfo->Eta.getNBins();
145 SLetas = eventInfo->Eta.getBin();
146 nBinsPhi = eventInfo->Phi.getNBins();
148 SLphis = eventInfo->Phi.getBin();
155 edm::LogVerbatim(
"CastorShower") <<
" CastorShowerLibrary::loadEventInfo : "
156 <<
"\n \n Total number of events : " <<
totEvents
157 <<
"\n Number of bins (E) : " <<
nBinsE
159 <<
"\n Number of bins (Eta) : " <<
nBinsEta
161 <<
"\n Number of bins (Phi) : " <<
nBinsPhi
162 <<
"\n Number of events/bin (Phi) : " <<
nEvtPerBinPhi <<
"\n";
164 std::stringstream ss1;
165 ss1 <<
"CastorShowerLibrary: energies in GeV:\n";
166 for (
unsigned int i = 0;
i <
nBinsE; ++
i) {
167 if (
i > 0 &&
i / 10 * 10 ==
i) {
172 ss1 <<
"\nCastorShowerLibrary: etas:\n";
174 if (
i > 0 &&
i / 10 * 10 ==
i) {
179 ss1 <<
"\nCastorShowerLibrary: phis:\n";
181 if (
i > 0 &&
i / 10 * 10 ==
i) {
192 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
193 G4Track*
track = aStep->GetTrack();
195 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
207 double pin = preStepPoint->GetTotalEnergy();
208 double zint = hitPoint.z();
209 double R =
sqrt(hitPoint.x() * hitPoint.x() + hitPoint.y() * hitPoint.y());
211 double phiin = atan2(hitPoint.y(), hitPoint.x());
219 hit =
select(0, pin, etain, phiin);
221 hit =
select(1, pin, etain, phiin);
242 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: ";
256 int nHit = showerEvent->
getNhit();
257 LogDebug(
"CastorShower") <<
"CastorShowerLibrary::getRecord: Record " << record <<
" of type " << type <<
" with "
258 << nHit <<
" CastorShowerHits";
282 double r = G4UniformRand();
300 phiin = phiin +
M_PI;
301 if (phiin >= phiMin && phiin < phiMax) {
304 double remainder = fmod(phiin, phiMax);
305 phiin = phiMin + remainder;
322 edm::LogVerbatim(
"CastorShower") <<
"CastorShowerLibrary:: Select record " << irec <<
" of type " <<
type;
361 for (; i <
SLetas.size() - 1; i++)
383 for (; i <
SLphis.size() - 1; i++)
void Clear(Option_t *option="") override
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
static std::vector< std::string > checklist log
int FindEnergyBin(double)
CastorShowerLibrary(const std::string &name, edm::ParameterSet const &p)
Geom::Theta< T > theta() const
Log< level::Error, false > LogError
std::vector< double > SLetas
unsigned int nEvtPerBinPhi
CastorShowerEvent getShowerHits(const G4Step *, bool &)
static constexpr int verbose
std::vector< double > SLphis
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
static bool isStableHadronIon(const G4Track *)
void initFile(edm::ParameterSet const &)
std::vector< double > SLenergies
T getParameter(std::string const &) const
void loadEventInfo(TBranch *)
static bool isGammaElectronPositron(int pdgCode)
CastorShowerEvent select(int, double, double=0, double=9)
CastorShowerEvent getRecord(int, int)
unsigned int nEvtPerBinEta