14 #include "G4VPhysicalVolume.hh"
17 #include "Randomize.hh"
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
31 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
32 const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
33 const G4Track*
track = aStep->GetTrack();
35 const G4DynamicParticle* aParticle = track->GetDynamicParticle();
36 const G4ThreeVector& momDir = aParticle->GetMomentumDirection();
37 double energy = preStepPoint->GetKineticEnergy();
38 G4ThreeVector hitPoint = preStepPoint->GetPosition();
39 const G4ThreeVector& hitPointOrig = preStepPoint->GetPosition();
40 G4int parCode = track->GetDefinition()->GetPDGEncoding();
52 G4ThreeVector posLocal;
53 double tSlice = (postStepPoint->GetGlobalTime()) / nanosecond;
60 double xxlocal, yylocal, zzlocal;
63 side = (hitPointOrig.z() > 0.) ?
true :
false;
69 for (
int i = 0;
i <
npe;
i++) {
78 zz = (hitPointOrig.z() > 0.) ? zzlocal +
Z0 : zzlocal -
Z0;
79 pos = G4ThreeVector(xx, yy, zz);
80 posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
91 zz = (hitPointOrig.z() > 0.) ? zzlocal +
Z0 : zzlocal -
Z0;
92 pos = G4ThreeVector(xx, yy, zz);
93 posLocal = G4ThreeVector(xxlocal, yylocal, zzlocal);
98 oneHit.
depth = channel;
103 hitPoint.setX(hitPointOrig.x() -
X0);
104 hitPoint.setY(hitPointOrig.y() -
Y0);
105 double setZ = (hitPointOrig.z() > 0.) ? hitPointOrig.z() -
Z0 : fabs(hitPointOrig.z()) -
Z0;
118 hits.push_back(oneHit);
120 edm::LogVerbatim(
"ZdcShower") <<
"\nZdcShowerLibrary:Generated Hit " << nHit <<
" orig hit pos " << hitPointOrig
121 <<
" orig hit pos local coord" << hitPoint <<
" new position "
122 << (
hits[nHit].position) <<
" Channel " << (
hits[nHit].
depth) <<
" side " << side
123 <<
" Time " << (
hits[nHit].time) <<
" DetectorID " << (
hits[nHit].detID)
124 <<
" Had Energy " << (
hits[nHit].DeHad) <<
" EM Energy " << (
hits[nHit].DeEM)
132 const G4ThreeVector& momDir,
140 energy = energy / GeV;
142 edm::LogVerbatim(
"ZdcShower") <<
"\n ZdcShowerLibrary::getEnergyFromLibrary input/output variables:"
143 <<
" phi: " << 59.2956 * momDir.phi() <<
" theta: " << 59.2956 * momDir.theta()
144 <<
" xin : " << hitPoint.x() <<
" yin : " << hitPoint.y() <<
" zin : " << hitPoint.z()
145 <<
" track en: " << energy <<
"(GeV)"
146 <<
" section: " << section <<
" side: " << side <<
" channel: " << channel
147 <<
" partID: " << parCode;
153 float xin = hitPoint.x();
154 float yin = hitPoint.y();
159 if (section == 1 && !isEM) {
168 if (section == 2 && !isEM) {
178 if (section == 1 && isEM) {
192 eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
194 (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 *
pow((energy / 300.0), 0.99);
195 esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
196 (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 30.0 *
pow((energy / 300.0), 0.54);
199 eav = ((((((-0.0002 * xin - 2.0e-13) * xin + 0.0022) * xin + 1.0e-11) * xin - 0.0217) * xin - 3.0e-10) * xin +
201 (((0.0001 * yin + 0.0056) * yin + 0.0508) * yin + 1.0) * 300.0 *
pow((energy / 300.0), 1.12);
202 esig = ((((((0.0005 * xin - 1.0e-12) * xin - 0.0052) * xin + 5.0e-11) * xin + 0.032) * xin - 2.0e-10) * xin + 1.0) *
203 (((0.0006 * yin + 0.0071) * yin - 0.031) * yin + 1.0) * 54.0 *
pow((energy / 300.0), 0.93);
207 if (eav < 0. || esig < 0.) {
208 edm::LogVerbatim(
"ZdcShower") <<
" Negative everage energy or esigma from parametrization \n"
209 <<
" xin: " << xin <<
"(cm)"
210 <<
" yin: " << yin <<
"(cm)"
211 <<
" track en: " << energy <<
"(GeV)"
212 <<
" eaverage: " << eav <<
" (GeV)"
213 <<
" esigma: " << esig <<
" (GeV)"
214 <<
" edist: " << edis <<
" (GeV)";
222 while (nphotons == -1 || nphotons >
int(eav + 5. * esig))
226 <<
" eaverage: " << eav / GeV <<
" (GeV)"
227 <<
" esigma: " << esig / GeV <<
" (GeV)"
228 <<
" edist: " << edis <<
" (GeV)"
229 <<
" dE hit: " << nphotons / GeV <<
" (GeV)";
238 efluct = eav + esig * CLHEP::RandGaussQ::shoot();
240 efluct = eav + esig * CLHEP::RandLandau::shoot();
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
ZdcShowerLibrary(const std::string &name, edm::ParameterSet const &p)
static const double theXChannelBoundaries[]
int getEnergyFromLibrary(const G4ThreeVector &posHit, const G4ThreeVector &momDir, double energy, G4int parCode, HcalZDCDetId::Section section, bool side, int channel)
static const double theZHadChannelBoundaries[]
std::vector< ZdcShowerLibrary::Hit > hits
Abs< T >::type abs(const T &t)
static bool isStableHadronIon(const G4Track *)
int photonFluctuation(double eav, double esig, double edis)
T getParameter(std::string const &) const
static bool isGammaElectronPositron(int pdgCode)
std::vector< Hit > & getHits(const G4Step *aStep, bool &ok)
static const double theZSectionBoundaries[]
Power< A, B >::type pow(const A &a, const B &b)