15 #include "G4SDManager.hh"
18 #include "G4VProcess.hh"
20 #include "G4Cerenkov.hh"
21 #include "G4ParticleTable.hh"
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
23 #include "CLHEP/Units/GlobalPhysicalConstants.h"
24 #include "Randomize.hh"
25 #include "G4Poisson.hh"
44 edm::LogVerbatim(
"ForwardSim") <<
"***************************************************\n"
46 <<
"* Constructing a ZdcSD with name " <<
name <<
" *\n"
48 <<
"***************************************************";
68 auto const preStepPoint = aStep->GetPreStepPoint();
70 double etrack = preStepPoint->GetKineticEnergy();
82 auto const theTrack = aStep->GetTrack();
83 edm::LogVerbatim(
"ForwardSim") <<
"----------------New track------------------------------\n"
84 <<
"Incident EnergyTrack: " << etrack <<
" MeV \n"
86 <<
"ZdcSD::getFromLibrary " <<
hits.size() <<
" hits for " << GetName() <<
" of "
87 << primaryID <<
" with " << theTrack->GetDefinition()->GetParticleName() <<
" of "
88 << etrack <<
" MeV\n";
95 for (
unsigned int i = 0;
i <
hits.size();
i++) {
99 unsigned int unitID =
hits[
i].detID;
120 double NCherPhot = 0.;
123 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
124 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
125 const G4String& nameVolume = currentPV->GetName();
127 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
128 const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
129 G4double stepL = aStep->GetStepLength() / cm;
130 G4double
beta = preStepPoint->GetBeta();
131 G4double
charge = preStepPoint->GetCharge();
134 G4Track* theTrack = aStep->GetTrack();
135 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
136 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
139 const G4ThreeVector& vert_mom = theTrack->GetVertexMomentumDirection();
143 vert_mom.z() /
sqrt(vert_mom.x() * vert_mom.x() + vert_mom.y() * vert_mom.y() + vert_mom.z() * vert_mom.z());
147 if (vert_mom.x() != 0)
148 phi = std::atan2(vert_mom.y(), vert_mom.x());
153 double stepE = aStep->GetTotalEnergyDeposit();
156 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
157 G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
158 const G4String& postnameVolume = postPV->GetName();
160 <<
" preStepPoint: " << nameVolume <<
"," << stepL <<
"," << stepE <<
"," <<
beta
162 <<
" postStepPoint: " << postnameVolume <<
"," << costheta <<
"," <<
theta <<
","
164 <<
" Etot(GeV)= " << theTrack->GetTotalEnergy() /
GeV;
166 const double bThreshold = 0.67;
167 if ((
beta > bThreshold) && (
charge != 0) && (nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber")) {
171 const float nMedium = 1.4925;
175 const float photEnSpectrDE = 1.24;
181 const float effPMTandTransport = 0.15;
184 const float thFullRefl = 23.;
185 float thFullReflRad = thFullRefl *
pi / 180.;
193 float costh = hit_mom.z() /
sqrt(hit_mom.x() * hit_mom.x() + hit_mom.y() * hit_mom.y() + hit_mom.z() * hit_mom.z());
200 float costhcher = 1. / (nMedium *
beta);
204 float DelFibPart =
std::abs(th - thFibDirRad);
218 if (DelFibPart > (thFullReflRad + thcher)) {
225 if ((th + thcher) < (thFibDirRad + thFullReflRad) && (th - thcher) > (thFibDirRad - thFullReflRad)) {
232 if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher)) {
242 float arg_arcos = 0.;
243 float tan_arcos = 2. *
a *
d;
245 arg_arcos = (
r *
r -
a *
a -
d *
d) / tan_arcos;
251 d_qz = th_arcos / twopi;
258 double meanNCherPhot = 0.;
259 int poissNCherPhot = 0;
261 meanNCherPhot = 370. *
charge *
charge * (1. - 1. / (nMedium * nMedium *
beta *
beta)) * photEnSpectrDE * stepL;
263 poissNCherPhot =
std::max((
int)G4Poisson(meanNCherPhot), 0);
264 NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
268 edm::LogVerbatim(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: gED: " << stepE <<
"," << costh <<
"," << th <<
","
269 << costhcher <<
"," << thcher <<
"," << DelFibPart <<
"," <<
d <<
"," <<
a <<
","
270 <<
r <<
"," << hitPoint <<
"," << hit_mom <<
"," << vert_mom <<
"," << localPoint
271 <<
"," <<
charge <<
"," <<
beta <<
"," << stepL <<
"," << d_qz <<
"," << variant
272 <<
"," << meanNCherPhot <<
"," << poissNCherPhot <<
"," << NCherPhot;
290 if (
beta <= bThreshold)
293 edm::LogVerbatim(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
294 if (!(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber"))
295 edm::LogVerbatim(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
307 edm::LogVerbatim(
"ForwardSim") <<
"ZdcSD: updates numbering scheme for " << GetName();