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) {
41 onlyLong_ = m_HF2.getParameter<
bool>(
"OnlyLong");
43 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
50 <<
" Use of Gflash is set to " << useGflash <<
" P.E. per GeV " <<
pePerGeV_
51 <<
", ref. index of fibre " <<
ref_index_ <<
", Track EM Flag " <<
trackEM_ <<
", edMin "
52 <<
edMin_ <<
" GeV, use of Short fibre info in"
53 <<
" shower library set to " << !(
onlyLong_)
55 <<
", Mean lambda " << lambdaMean <<
", aperture (cutoff) " <<
aperture_
60 if (
tfile.isAvailable()) {
63 <<
"ProfileFromParam";
65 hzvem_ = showerDir.
make<TH1F>(
"hzvem",
"Longitudinal Profile (EM Part);Number of PE", 330, 0.0, 1650.0);
66 hzvhad_ = showerDir.
make<TH1F>(
"hzvhad",
"Longitudinal Profile (Had Part);Number of PE", 330, 0.0, 1650.0);
68 "em_2d_1",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
70 showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
72 "em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
73 em_lateral_1_ = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
75 "em_2d_2",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
77 showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
78 em_lateral_2_ = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
80 "em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots", 800, 800.0, 1600.0);
82 "em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots", 800, 800.0, 1600.0);
85 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::No file is available for saving histos so the "
86 <<
"flag is set to false";
95 gflash_ = std::make_unique<HFGflash>(
p);
100 edm::LogVerbatim(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
107 auto const preStepPoint = aStep->GetPreStepPoint();
108 auto const track = aStep->GetTrack();
110 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
112 G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(), hitPoint.y(),
zv);
114 double pin = (preStepPoint->GetTotalEnergy()) /
CLHEP::GeV;
115 double zint = hitPoint.z();
119 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits " <<
track->GetDefinition()->GetParticleName()
120 <<
" of energy " << pin <<
" GeV Pos x,y,z = " << hitPoint.x() <<
"," << hitPoint.y()
121 <<
"," << zint <<
" (" <<
zz <<
"," << localPoint.z() <<
", "
122 << (localPoint.z() + 0.5 *
gpar_[1]) <<
") Local " << localPoint;
124 std::vector<HFShowerParam::Hit>
hits;
126 hit.position = hitPoint;
130 double pBeta =
track->GetDynamicParticle()->GetTotalMomentum() /
track->GetDynamicParticle()->GetTotalEnergy();
131 double dirz = (
track->GetDynamicParticle()->GetMomentumDirection()).
z();
132 if (hitPoint.z() < 0)
136 <<
track->GetDynamicParticle()->GetMomentumDirection() <<
" HitPoint " << hitPoint
139 if (!isEM &&
track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1 /
ref_index_) &&
140 aStep->GetTotalEnergyDeposit() > 0.) {
152 edep = (aStep->GetTotalEnergyDeposit()) /
GeV;
156 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep <<
" weight " <<
weight <<
" final "
157 << edep *
weight <<
", Kill = " << isKilled <<
", pin = " << pin
165 for (
unsigned int i = 0;
i < hitSL.size();
i++) {
176 hit.position = hitSL[
i].position;
177 hit.depth = hitSL[
i].depth;
178 hit.time = hitSL[
i].time;
186 double sq =
sqrt(
pow(
hit.position.
x() / CLHEP::cm, 2) +
pow(
hit.position.
y() / CLHEP::cm, 2));
187 double zp =
hit.position.
z() / CLHEP::cm;
188 if (
hit.depth == 1) {
192 }
else if (
hit.depth == 2) {
201 <<
"HFShowerParam: Hit at depth " <<
hit.depth <<
" with edep " <<
hit.edep <<
" Time " <<
hit.time;
206 std::vector<HFGflash::Hit> hitSL =
gflash_->gfParameterization(aStep,
onlyLong_);
207 for (
unsigned int i = 0;
i < hitSL.size(); ++
i) {
209 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(), hitSL[
i].position.z());
214 if (zv < 0. || zv >
gpar_[1]) {
223 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::getHits:#PMT= " << npmt <<
",z = " <<
zv;
227 edm::LogVerbatim(
"HFShower") <<
"-#PMT=0 cut-HFShowerParam::getHits: npmt = " << npmt;
230 }
else if (npmt > 24) {
242 <<
"HFShowerParam: npmt " << npmt <<
" zv " <<
std::abs(pe_effect.z()) <<
":" <<
gpar_[4] <<
":" <<
zv
243 <<
":" <<
gpar_[0] <<
" ok " <<
ok <<
" depth " <<
depth;
246 if (G4UniformRand() > 0.5)
252 double dist =
fibre_->zShift(localPoint,
depth, 0);
253 double r1 = G4UniformRand();
255 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam:Distance to PMT (" << npmt <<
") " << dist
261 double r2 = G4UniformRand();
264 <<
"HFShowerParam:Extra exclusion " <<
r2 <<
">" <<
weight <<
" " << (
r2 >
weight);
269 hit.position = hitSL[
i].position;
278 double sq =
sqrt(
pow(
hit.position.
x() / CLHEP::cm, 2) +
pow(
hit.position.
y() / CLHEP::cm, 2));
279 double zp =
hit.position.
z() / CLHEP::cm;
280 if (
hit.depth == 1) {
284 }
else if (
hit.depth == 2) {
293 <<
"HFShowerParam: Hit at depth " <<
hit.depth <<
" with edep " <<
hit.edep <<
" Time " <<
hit.time;
302 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
303 double time =
fibre_->tShift(localPoint, 1, 0);
311 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits hitPoint " << hitPoint <<
" flag " <<
ok;
319 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep " << edep <<
" Time " << tSlice
320 <<
":" <<
time <<
":" <<
hit.time;
334 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep " << edep <<
" Time " << tSlice
346 for (
unsigned int ii = 0;
ii <
hits.size(); ++
ii) {
350 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName() <<
" at "
351 <<
hits[
ii].position <<
" zz " <<
zv <<
" Edep " << edep <<
" due to "
352 <<
track->GetDefinition()->GetParticleName() <<
" time " <<
hit.time;
354 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits kill (" << isKilled <<
") track " <<
track->GetTrackID()
355 <<
" at " << hitPoint <<
" and deposit " << edep <<
" " <<
hits.size() <<
" times"
356 <<
" ZZ " <<
zz <<
" " <<
gpar_[0];