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"
43 edm::LogVerbatim(
"ZdcSD") <<
"***************************************************\n"
45 <<
"* Constructing a ZdcSD with name " <<
name <<
" *\n"
47 <<
"***************************************************";
67 auto const preStepPoint = aStep->GetPreStepPoint();
68 auto const theTrack = aStep->GetTrack();
70 double etrack = preStepPoint->GetKineticEnergy();
81 LogDebug(
"ForwardSim") <<
"----------------New track------------------------------\n"
82 <<
"Incident EnergyTrack: " << etrack <<
" MeV \n"
84 <<
"ZdcSD::getFromLibrary " <<
hits.size() <<
" hits for " << GetName() <<
" of "
85 << primaryID <<
" with " << theTrack->GetDefinition()->GetParticleName() <<
" of " << etrack
93 for (
unsigned int i = 0;
i <
hits.size();
i++) {
97 unsigned int unitID =
hits[
i].detID;
103 LogDebug(
"ForwardSim") <<
"ZdcSD: Final Hit number:" <<
i <<
"-->"
116 double NCherPhot = 0.;
119 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
120 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
121 const G4String& nameVolume = currentPV->GetName();
123 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
124 const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
125 G4double stepL = aStep->GetStepLength() / cm;
126 G4double
beta = preStepPoint->GetBeta();
127 G4double
charge = preStepPoint->GetCharge();
130 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
131 G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
132 const G4String& postnameVolume = postPV->GetName();
135 G4Track* theTrack = aStep->GetTrack();
136 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
137 const G4ThreeVector& vert_mom = theTrack->GetVertexMomentumDirection();
138 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
142 vert_mom.z() /
sqrt(vert_mom.x() * vert_mom.x() + vert_mom.y() * vert_mom.y() + vert_mom.z() * vert_mom.z());
146 if (vert_mom.x() != 0)
147 phi = std::atan2(vert_mom.y(), vert_mom.x());
152 double stepE = aStep->GetTotalEnergyDeposit();
153 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: \n"
154 <<
" preStepPoint: " << nameVolume <<
"," << stepL <<
"," << stepE <<
"," <<
beta <<
","
156 <<
" postStepPoint: " << postnameVolume <<
"," << costheta <<
"," <<
theta <<
"," <<
eta
157 <<
"," <<
phi <<
"," <<
particleType <<
" id= " << theTrack->GetTrackID()
158 <<
" Etot(GeV)= " << theTrack->GetTotalEnergy() /
GeV;
160 const double bThreshold = 0.67;
161 if ((
beta > bThreshold) && (
charge != 0) && (nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber")) {
162 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: pass ";
164 const float nMedium = 1.4925;
168 const float photEnSpectrDE = 1.24;
174 const float effPMTandTransport = 0.15;
177 const float thFullRefl = 23.;
178 float thFullReflRad = thFullRefl *
pi / 180.;
186 float costh = hit_mom.z() /
sqrt(hit_mom.x() * hit_mom.x() + hit_mom.y() * hit_mom.y() + hit_mom.z() * hit_mom.z());
193 float costhcher = 1. / (nMedium *
beta);
197 float DelFibPart =
std::abs(th - thFibDirRad);
210 if (DelFibPart > (thFullReflRad + thcher)) {
215 if ((th + thcher) < (thFibDirRad + thFullReflRad) && (th - thcher) > (thFibDirRad - thFullReflRad)) {
220 if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher)) {
227 float arg_arcos = 0.;
228 float tan_arcos = 2. *
a *
d;
230 arg_arcos = (
r *
r -
a *
a -
d *
d) / tan_arcos;
236 d_qz = th_arcos / twopi;
243 double meanNCherPhot = 0.;
244 int poissNCherPhot = 0;
246 meanNCherPhot = 370. *
charge *
charge * (1. - 1. / (nMedium * nMedium *
beta *
beta)) * photEnSpectrDE * stepL;
248 poissNCherPhot =
std::max((
int)G4Poisson(meanNCherPhot), 0);
249 NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
252 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: gED: " << stepE <<
"," << costh <<
"," << th <<
","
253 << costhcher <<
"," << thcher <<
"," << DelFibPart <<
"," <<
d <<
"," <<
a <<
"," <<
r <<
","
254 << hitPoint <<
"," << hit_mom <<
"," << vert_mom <<
"," << localPoint <<
"," <<
charge <<
","
255 <<
beta <<
"," << stepL <<
"," << d_qz <<
"," << variant <<
"," << meanNCherPhot <<
","
256 << poissNCherPhot <<
"," << NCherPhot;
273 if (
beta <= bThreshold)
274 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail beta=" <<
beta;
276 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
277 if (!(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber"))
278 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
290 edm::LogVerbatim(
"ZdcSD") <<
"ZdcSD: updates numbering scheme for " << GetName();