16 #include "G4SDManager.hh" 19 #include "G4VProcess.hh" 21 #include "G4Cerenkov.hh" 22 #include "G4ParticleTable.hh" 23 #include "G4PhysicalConstants.hh" 24 #include "CLHEP/Units/GlobalSystemOfUnits.h" 25 #include "CLHEP/Units/GlobalPhysicalConstants.h" 26 #include "Randomize.hh" 27 #include "G4Poisson.hh" 28 #include "G4TwoVector.hh" 46 edm::LogVerbatim(
"ForwardSim") <<
"***************************************************\n" 48 <<
"* Constructing a ZdcSD with name " <<
name <<
" *\n" 50 <<
"***************************************************";
67 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
81 edm::LogVerbatim(
"ZdcSD") <<
"ZdcSD::" << GetName() <<
" ID= " << aStep->GetTrack()->GetTrackID()
82 <<
" prID= " << aStep->GetTrack()->GetParentID()
83 <<
" Eprestep= " << aStep->GetPreStepPoint()->GetKineticEnergy()
84 <<
" step= " << aStep->GetStepLength() <<
" Edep= " << aStep->GetTotalEnergyDeposit();
92 auto const theTrack = aStep->GetTrack();
95 double time = theTrack->GetGlobalTime() / nanosecond;
108 G4ThreeVector
pre = aStep->GetPreStepPoint()->GetPosition();
123 const double NA = 0.22;
127 const double ALPHA = 0.0072973525693;
128 const double HBARC = 6.582119514E-16 * 2.99792458E8 ;
132 G4Material* material = aStep->GetTrack()->GetMaterial();
134 if (material->GetName() !=
"quartz")
137 const G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
138 const G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
139 const G4String volumeName = pPreStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume()->GetName();
141 G4ThreeVector
pre = pPreStepPoint->GetPosition();
142 G4ThreeVector
post = pPostStepPoint->GetPosition();
148 const G4ThreeVector localPre =
setToLocal(
pre, pPreStepPoint->GetTouchable());
149 const G4ThreeVector localPost =
setToLocal(
post, pPreStepPoint->GetTouchable());
152 const G4ThreeVector particleDirection = (localPost - localPre) / (localPost - localPre).mag();
154 const G4DynamicParticle* aParticle = aStep->GetTrack()->GetDynamicParticle();
155 int charge = round(aParticle->GetDefinition()->GetPDGCharge());
160 double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
161 double stepLength = aStep->GetStepLength() / 1000;
171 double photonE =
EMIN + G4UniformRand() * (
EMAX -
EMIN);
177 double omega = G4UniformRand() * twopi;
181 edm::LogVerbatim(
"ZdcSD") <<
"E_gamma: " << photonE <<
"\t omega: " << omega <<
"\t thetaC: " << thetaC;
184 double px = photonE *
sin(thetaC) *
cos(omega);
185 double py = photonE *
sin(thetaC) *
sin(omega);
186 double pz = photonE *
cos(thetaC);
187 G4ThreeVector photonMomentum(
px,
py, pz);
190 edm::LogVerbatim(
"ZdcSD") <<
"pPR = (" << particleDirection.x() <<
"," << particleDirection.y() <<
"," 191 << particleDirection.z() <<
")";
195 photonMomentum.rotateUz(particleDirection);
198 edm::LogVerbatim(
"ZdcSD") <<
"pLAB = (" << photonMomentum.x() <<
"," << photonMomentum.y() <<
"," 199 << photonMomentum.z() <<
")";
202 G4ThreeVector photonPosition = localPre + G4UniformRand() * (localPost - localPre);
205 G4TwoVector r0(photonPosition);
206 G4TwoVector
v0(photonMomentum);
209 double R2 = 0.3 * 0.3;
211 if (r0.mag() <
R && photonMomentum.z() < 0.0) {
213 double a =
v0.mag2();
214 double b = 2.0 * r0 *
v0;
215 double c = r0.mag2() - R2;
221 double t = (-
b +
sqrt(
b *
b - 4.0 *
a *
c)) / (2.0 *
a);
222 G4ThreeVector
n(r0.x() +
v0.x() *
t, r0.y() +
v0.y() *
t, 0.0);
223 double cosTheta = (
n * photonMomentum) / (
n.mag() * photonE);
231 edm::LogVerbatim(
"ZdcSD") <<
"r = (" << photonPosition.x() <<
"," << photonPosition.y() <<
"," 232 << photonPosition.z() <<
")" << std::endl;
257 const std::vector<double> ENERGY_TAB{1.75715, 1.81902, 1.88311, 1.94944, 2.0183, 2.08939, 2.16302, 2.23919,
258 2.31789, 2.39954, 2.48416, 2.57175, 2.66232, 2.75643, 2.85349, 2.95411,
259 3.05756, 3.16528, 3.2774, 3.39218, 3.5123, 3.6359, 3.76394, 3.89642,
260 4.03332, 4.17596, 4.32302, 4.47596, 4.63319, 4.79629};
262 const std::vector<double> RINDEX_TAB{1.45517, 1.45572, 1.45631, 1.45693, 1.45758, 1.45826, 1.45899, 1.45976,
263 1.46057, 1.46144, 1.46238, 1.46337, 1.46444, 1.46558, 1.4668, 1.46812,
264 1.46953, 1.47105, 1.4727, 1.47447, 1.4764, 1.47847, 1.48071, 1.48315,
265 1.48579, 1.48868, 1.49182, 1.49526, 1.499, 1.5031};
276 photonE = G4UniformRand() * (
EMAX - Emin) + Emin;
286 const std::vector<double> EMIN_TAB{1.75715, 1.81902, 1.88311, 1.94944, 2.0183, 2.08939, 2.16302, 2.23919,
287 2.31789, 2.39954, 2.48416, 2.57175, 2.66232, 2.75643, 2.85349, 2.95411,
288 3.05756, 3.16528, 3.2774, 3.39218, 3.5123, 3.6359, 3.76394, 3.89642,
289 4.03332, 4.17596, 4.32302, 4.47596, 4.63319};
292 const std::vector<double> INTEGRAL_TAB{1.39756, 1.36835, 1.33812, 1.30686, 1.27443, 1.24099, 1.20638, 1.17061,
293 1.1337, 1.09545, 1.05586, 1.01493, 0.972664, 0.928815, 0.883664, 0.836938,
294 0.788988, 0.739157, 0.687404, 0.634547, 0.579368, 0.522743, 0.464256, 0.40393,
295 0.341808, 0.27732, 0.211101, 0.142536, 0.0723891};
301 const std::vector<double> LAMBDA_TAB{263.27, 265.98, 268.69, 271.39, 273.20, 275.90, 282.22, 282.22, 293.04,
302 308.38, 325.52, 346.26, 367.91, 392.27, 417.53, 440.98, 463.53, 484.28,
303 502.32, 516.75, 528.48, 539.30, 551.93, 564.56, 574.48, 584.41, 595.23,
304 606.96, 616.88, 625.00, 632.22, 637.63, 642.14, 647.55, 652.96, 656.57,
305 661.08, 666.49, 669.20, 673.71, 677.32, 680.93, 686.34, 692.65};
308 const std::vector<double> EFF_TAB{2.215, 2.860, 3.659, 4.724, 5.989, 7.734, 9.806, 9.806, 12.322,
309 15.068, 17.929, 20.570, 22.963, 24.050, 23.847, 22.798, 20.445, 18.003,
310 15.007, 12.282, 9.869, 7.858, 6.373, 5.121, 4.077, 3.276, 2.562,
311 2.077, 1.669, 1.305, 1.030, 0.805, 0.629, 0.492, 0.388, 0.303,
312 0.239, 0.187, 0.144, 0.113, 0.088, 0.069, 0.054, 0.043};
316 for (
int i = 0;
i < 44 - 1;
i++) {
317 if (lambda > LAMBDA_TAB[
i] && lambda < LAMBDA_TAB[
i + 1]) {
318 double a = (EFF_TAB[
i] - EFF_TAB[
i + 1]) / (LAMBDA_TAB[
i] - LAMBDA_TAB[
i + 1]);
319 double b = EFF_TAB[
i] -
a * LAMBDA_TAB[
i];
320 return (
a * lambda +
b) / 100.0;
330 for (
unsigned int i = 0;
i <
X.size() - 1;
i++) {
331 if (
x >
X[
i] &&
x <
X[
i + 1]) {
340 if (fabs(
X[0] -
x) < 1E-8)
342 else if (fabs(
X[
X.size() - 1] -
x) < 1E-8)
343 return Y[
X.size() - 1];
366 auto const theTrack = aStep->GetTrack();
369 if (primaryID == 0) {
371 auto const preStepPoint = aStep->GetPreStepPoint();
372 double etrack = preStepPoint->GetKineticEnergy();
373 edm::LogVerbatim(
"ZdcSD") <<
"ZdcSD: Problem with primaryID **** set by force to TkID **** " 374 << theTrack->GetTrackID() <<
" E " << etrack;
376 primaryID = theTrack->GetTrackID();
CaloG4Hit * currentHit[2]
double convertEnergyToWavelength(double)
Log< level::Info, true > LogVerbatim
std::unique_ptr< ZdcNumberingScheme > numberingScheme
T getParameter(std::string const &) const
double photonEnergyDist(int, double, double)
double calculateN2InvIntegral(double)
virtual uint16_t getDepth(const G4Step *)
std::vector< ZdcShowerLibrary::Hit > hits
Sin< T >::type sin(const T &t)
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
virtual int getTrackID(const G4Track *)
double calculateCherenkovDeposit(const G4Step *)
double evaluateFunction(const std::vector< double > &, const std::vector< double > &, double)
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
void resetForNewPrimary(const G4Step *)
Cos< T >::type cos(const T &t)
int setTrackID(const G4Step *step) override
bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory) override
ZdcSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double calculateMeanNumberOfPhotons(int, double, double)
bool hitExists(const G4Step *, int k)
double pmtEfficiency(double)
std::unique_ptr< ZdcShowerLibrary > showerLibrary
static bool isGammaElectronPositron(int pdgCode)
double generatePhotonEnergy(int, double, double)
double linearInterpolation(double, double, double, double, double)
uint32_t setDetUnitId(const G4Step *step) override
void NaNTrap(const G4Step *step) const
void setParameterized(bool val)