14 #include "G4VPhysicalVolume.hh"
17 #include "G4NavigationHistory.hh"
18 #include "Randomize.hh"
20 #include "CLHEP/Units/GlobalPhysicalConstants.h"
21 #include "CLHEP/Units/GlobalSystemOfUnits.h"
33 : hcalConstants_(hcons), fillHisto_(
false) {
42 onlyLong_ = m_HF2.getParameter<
bool>(
"OnlyLong");
44 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
51 <<
" Use of Gflash is set to " << useGflash <<
" P.E. per GeV " <<
pePerGeV_
52 <<
", ref. index of fibre " <<
ref_index_ <<
", Track EM Flag " <<
trackEM_ <<
", edMin "
53 <<
edMin_ <<
" GeV, use of Short fibre info in"
54 <<
" shower library set to " << !(
onlyLong_)
57 <<
", Mean lambda " << lambdaMean <<
", aperture (cutoff) " <<
aperture_
62 if (
tfile.isAvailable()) {
65 <<
"ProfileFromParam";
67 hzvem_ = showerDir.
make<TH1F>(
"hzvem",
"Longitudinal Profile (EM Part);Number of PE", 330, 0.0, 1650.0);
68 hzvhad_ = showerDir.
make<TH1F>(
"hzvhad",
"Longitudinal Profile (Had Part);Number of PE", 330, 0.0, 1650.0);
70 "em_2d_1",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
72 showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
74 "em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
75 em_lateral_1_ = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
77 "em_2d_2",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
79 showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
80 em_lateral_2_ = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
82 "em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots", 800, 800.0, 1600.0);
84 "em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots", 800, 800.0, 1600.0);
87 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::No file is available for saving histos so the "
88 <<
"flag is set to false";
97 gflash_ = std::make_unique<HFGflash>(
p);
102 edm::LogVerbatim(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
109 auto const preStepPoint = aStep->GetPreStepPoint();
110 auto const track = aStep->GetTrack();
112 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
114 G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(), hitPoint.y(),
zv);
116 double pin = (preStepPoint->GetTotalEnergy()) /
CLHEP::GeV;
117 double zint = hitPoint.z();
121 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits " <<
track->GetDefinition()->GetParticleName()
122 <<
" of energy " << pin <<
" GeV Pos x,y,z = " << hitPoint.x() <<
"," << hitPoint.y()
123 <<
"," << zint <<
" (" <<
zz <<
"," << localPoint.z() <<
", "
124 << (localPoint.z() + 0.5 *
gpar_[1]) <<
") Local " << localPoint;
126 std::vector<HFShowerParam::Hit>
hits;
128 hit.position = hitPoint;
132 double pBeta =
track->GetDynamicParticle()->GetTotalMomentum() /
track->GetDynamicParticle()->GetTotalEnergy();
133 double dirz = (
track->GetDynamicParticle()->GetMomentumDirection()).
z();
134 if (hitPoint.z() < 0)
138 <<
track->GetDynamicParticle()->GetMomentumDirection() <<
" HitPoint " << hitPoint
141 if (!isEM &&
track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1 /
ref_index_) &&
142 aStep->GetTotalEnergyDeposit() > 0.) {
154 edep = (aStep->GetTotalEnergyDeposit()) /
GeV;
158 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep <<
" weight " <<
weight <<
" final "
159 << edep *
weight <<
", Kill = " << isKilled <<
", pin = " << pin
167 for (
unsigned int i = 0;
i < hitSL.size();
i++) {
178 hit.position = hitSL[
i].position;
179 hit.depth = hitSL[
i].depth;
180 hit.time = hitSL[
i].time;
188 double sq =
sqrt(
pow(
hit.position.
x() / CLHEP::cm, 2) +
pow(
hit.position.
y() / CLHEP::cm, 2));
189 double zp =
hit.position.
z() / CLHEP::cm;
190 if (
hit.depth == 1) {
194 }
else if (
hit.depth == 2) {
203 <<
"HFShowerParam: Hit at depth " <<
hit.depth <<
" with edep " <<
hit.edep <<
" Time " <<
hit.time;
208 std::vector<HFGflash::Hit> hitSL =
gflash_->gfParameterization(aStep,
onlyLong_);
209 for (
unsigned int i = 0;
i < hitSL.size(); ++
i) {
211 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(), hitSL[
i].position.z());
216 if (zv < 0. || zv >
gpar_[1]) {
225 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::getHits:#PMT= " << npmt <<
",z = " <<
zv;
229 edm::LogVerbatim(
"HFShower") <<
"-#PMT=0 cut-HFShowerParam::getHits: npmt = " << npmt;
232 }
else if (npmt > 24) {
244 <<
"HFShowerParam: npmt " << npmt <<
" zv " <<
std::abs(pe_effect.z()) <<
":" <<
gpar_[4] <<
":" <<
zv
245 <<
":" <<
gpar_[0] <<
" ok " <<
ok <<
" depth " <<
depth;
248 if (G4UniformRand() > 0.5)
254 double dist =
fibre_->zShift(localPoint,
depth, 0);
255 double r1 = G4UniformRand();
257 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam:Distance to PMT (" << npmt <<
") " << dist
263 double r2 = G4UniformRand();
266 <<
"HFShowerParam:Extra exclusion " <<
r2 <<
">" <<
weight <<
" " << (
r2 >
weight);
272 hit.position = hitSL[
i].position;
281 double sq =
sqrt(
pow(
hit.position.
x() / CLHEP::cm, 2) +
pow(
hit.position.
y() / CLHEP::cm, 2));
282 double zp =
hit.position.
z() / CLHEP::cm;
283 if (
hit.depth == 1) {
287 }
else if (
hit.depth == 2) {
296 <<
"HFShowerParam: Hit at depth " <<
hit.depth <<
" with edep " <<
hit.edep <<
" Time " <<
hit.time;
305 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
307 : (
fibre_->tShift(localPoint, 1, 0));
315 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits hitPoint " << hitPoint <<
" flag " <<
ok;
323 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep " << edep <<
" Time " << tSlice
324 <<
":" <<
time <<
":" <<
hit.time;
338 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep " << edep <<
" Time " << tSlice
350 for (
unsigned int ii = 0;
ii <
hits.size(); ++
ii) {
354 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName() <<
" at "
355 <<
hits[
ii].position <<
" zz " <<
zv <<
" Edep " << edep <<
" due to "
356 <<
track->GetDefinition()->GetParticleName() <<
" time " <<
hit.time;
358 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits kill (" << isKilled <<
") track " <<
track->GetTrackID()
359 <<
" at " << hitPoint <<
" and deposit " << edep <<
" " <<
hits.size() <<
" times"
360 <<
" ZZ " <<
zz <<
" " <<
gpar_[0];