13 #include "G4SDManager.hh"
16 #include "G4VProcess.hh"
18 #include "G4Cerenkov.hh"
19 #include "G4ParticleTable.hh"
20 #include "CLHEP/Units/GlobalSystemOfUnits.h"
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
22 #include "Randomize.hh"
23 #include "G4Poisson.hh"
41 edm::LogVerbatim(
"ZdcSD") <<
"***************************************************\n"
43 <<
"* Constructing a ZdcSD with name " <<
name <<
" *\n"
45 <<
"***************************************************";
65 auto const preStepPoint = aStep->GetPreStepPoint();
66 auto const theTrack = aStep->GetTrack();
68 double etrack = preStepPoint->GetKineticEnergy();
79 LogDebug(
"ForwardSim") <<
"----------------New track------------------------------\n"
80 <<
"Incident EnergyTrack: " << etrack <<
" MeV \n"
82 <<
"ZdcSD::getFromLibrary " <<
hits.size() <<
" hits for " << GetName() <<
" of "
83 << primaryID <<
" with " << theTrack->GetDefinition()->GetParticleName() <<
" of " << etrack
91 for (
unsigned int i = 0;
i <
hits.size();
i++) {
95 unsigned int unitID =
hits[
i].detID;
101 LogDebug(
"ForwardSim") <<
"ZdcSD: Final Hit number:" <<
i <<
"-->"
114 double NCherPhot = 0.;
117 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
118 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
119 const G4String& nameVolume = currentPV->GetName();
121 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
122 const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
123 G4double stepL = aStep->GetStepLength() / cm;
124 G4double
beta = preStepPoint->GetBeta();
125 G4double
charge = preStepPoint->GetCharge();
128 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
129 G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
130 const G4String& postnameVolume = postPV->GetName();
133 G4Track* theTrack = aStep->GetTrack();
134 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
135 const G4ThreeVector& vert_mom = theTrack->GetVertexMomentumDirection();
136 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
140 vert_mom.z() /
sqrt(vert_mom.x() * vert_mom.x() + vert_mom.y() * vert_mom.y() + vert_mom.z() * vert_mom.z());
144 if (vert_mom.x() != 0)
145 phi = std::atan2(vert_mom.y(), vert_mom.x());
150 double stepE = aStep->GetTotalEnergyDeposit();
151 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: \n"
152 <<
" preStepPoint: " << nameVolume <<
"," << stepL <<
"," << stepE <<
"," <<
beta <<
","
154 <<
" postStepPoint: " << postnameVolume <<
"," << costheta <<
"," <<
theta <<
"," <<
eta
155 <<
"," <<
phi <<
"," <<
particleType <<
" id= " << theTrack->GetTrackID()
156 <<
" Etot(GeV)= " << theTrack->GetTotalEnergy() /
GeV;
158 const double bThreshold = 0.67;
159 if ((
beta > bThreshold) && (
charge != 0) && (nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber")) {
160 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: pass ";
162 const float nMedium = 1.4925;
166 const float photEnSpectrDE = 1.24;
172 const float effPMTandTransport = 0.15;
175 const float thFullRefl = 23.;
176 float thFullReflRad = thFullRefl *
pi / 180.;
184 float costh = hit_mom.z() /
sqrt(hit_mom.x() * hit_mom.x() + hit_mom.y() * hit_mom.y() + hit_mom.z() * hit_mom.z());
191 float costhcher = 1. / (nMedium *
beta);
195 float DelFibPart =
std::abs(th - thFibDirRad);
208 if (DelFibPart > (thFullReflRad + thcher)) {
213 if ((th + thcher) < (thFibDirRad + thFullReflRad) && (th - thcher) > (thFibDirRad - thFullReflRad)) {
218 if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher)) {
225 float arg_arcos = 0.;
226 float tan_arcos = 2. *
a *
d;
228 arg_arcos = (
r *
r -
a *
a -
d *
d) / tan_arcos;
234 d_qz = th_arcos / twopi;
241 double meanNCherPhot = 0.;
242 int poissNCherPhot = 0;
244 meanNCherPhot = 370. *
charge *
charge * (1. - 1. / (nMedium * nMedium *
beta *
beta)) * photEnSpectrDE * stepL;
246 poissNCherPhot =
std::max((
int)G4Poisson(meanNCherPhot), 0);
247 NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
250 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: gED: " << stepE <<
"," << costh <<
"," << th <<
","
251 << costhcher <<
"," << thcher <<
"," << DelFibPart <<
"," <<
d <<
"," <<
a <<
"," <<
r <<
","
252 << hitPoint <<
"," << hit_mom <<
"," << vert_mom <<
"," << localPoint <<
"," <<
charge <<
","
253 <<
beta <<
"," << stepL <<
"," << d_qz <<
"," << variant <<
"," << meanNCherPhot <<
","
254 << poissNCherPhot <<
"," << NCherPhot;
271 if (
beta <= bThreshold)
272 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail beta=" <<
beta;
274 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
275 if (!(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber"))
276 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
288 edm::LogVerbatim(
"ZdcSD") <<
"ZdcSD: updates numbering scheme for " << GetName();