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 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
48 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::Use of shower library is set to " << useShowerLibrary
49 <<
" Use of Gflash is set to " << useGflash <<
" P.E. per GeV " << pePerGeV_
50 <<
", ref. index of fibre " << ref_index_ <<
", Track EM Flag " << trackEM_ <<
", edMin " 51 << edMin_ <<
" GeV, use of Short fibre info in" 52 <<
" shower library set to " << !(
onlyLong_)
53 <<
", use of parametrization for last part set to " << parametrizeLast_
54 <<
", Mean lambda " << lambdaMean <<
", aperture (cutoff) " << aperture_
62 <<
"ProfileFromParam";
64 hzvem_ = showerDir.
make<TH1F>(
"hzvem",
"Longitudinal Profile (EM Part);Number of PE", 330, 0.0, 1650.0);
65 hzvhad_ = showerDir.
make<TH1F>(
"hzvhad",
"Longitudinal Profile (Had Part);Number of PE", 330, 0.0, 1650.0);
67 "em_2d_1",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
69 showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
71 "em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
72 em_lateral_1_ = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
74 "em_2d_2",
"Lateral Profile vs. Shower Depth;cm;Events", 800, 800.0, 1600.0, 100, 50.0, 150.0);
76 showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots", 800, 800.0, 1600.0);
77 em_lateral_2_ = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events", 100, 50.0, 150.0);
79 "em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots", 800, 800.0, 1600.0);
81 "em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots", 800, 800.0, 1600.0);
84 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::No file is available for saving histos so the " 85 <<
"flag is set to false";
94 gflash_ = std::make_unique<HFGflash>(
p);
99 edm::LogVerbatim(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
100 <<
") = " << 1 / (attLMeanInv_ * CLHEP::cm) <<
" cm";
106 auto const preStepPoint = aStep->GetPreStepPoint();
107 auto const track = aStep->GetTrack();
109 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
111 G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(), hitPoint.y(), zv);
113 double pin = (preStepPoint->GetTotalEnergy()) /
CLHEP::GeV;
114 double zint = hitPoint.z();
118 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits " <<
track->GetDefinition()->GetParticleName()
119 <<
" of energy " << pin <<
" GeV Pos x,y,z = " << hitPoint.x() <<
"," << hitPoint.y()
120 <<
"," << zint <<
" (" << zz <<
"," << localPoint.z() <<
", " 121 << (localPoint.z() + 0.5 *
gpar_[1]) <<
") Local " << localPoint;
123 std::vector<HFShowerParam::Hit>
hits;
129 double pBeta =
track->GetDynamicParticle()->GetTotalMomentum() /
track->GetDynamicParticle()->GetTotalEnergy();
130 double dirz = (
track->GetDynamicParticle()->GetMomentumDirection()).
z();
131 if (hitPoint.z() < 0)
135 <<
track->GetDynamicParticle()->GetMomentumDirection() <<
" HitPoint " << hitPoint
138 if (!isEM &&
track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1 /
ref_index_) &&
139 aStep->GetTotalEnergyDeposit() > 0.) {
151 edep = (aStep->GetTotalEnergyDeposit()) /
GeV;
155 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep <<
" weight " << weight <<
" final " 156 << edep * weight <<
", Kill = " << isKilled <<
", pin = " << pin
164 for (
unsigned int i = 0;
i < hitSL.size();
i++) {
176 hit.
depth = hitSL[
i].depth;
177 hit.
time = hitSL[
i].time;
186 double zp = hit.
position.z() / CLHEP::cm;
187 if (hit.
depth == 1) {
191 }
else if (hit.
depth == 2) {
200 <<
"HFShowerParam: Hit at depth " << hit.
depth <<
" with edep " << hit.
edep <<
" Time " << hit.
time;
205 std::vector<HFGflash::Hit> hitSL =
gflash_->gfParameterization(aStep,
onlyLong_);
206 for (
unsigned int i = 0;
i < hitSL.size(); ++
i) {
208 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(), hitSL[
i].position.z());
213 if (zv < 0. || zv >
gpar_[1]) {
215 edm::LogVerbatim(
"HFShower") <<
"-#Zcut-HFShowerParam::getHits:z=" << zv <<
",m=" << gpar_[1];
222 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam::getHits:#PMT= " << npmt <<
",z = " << zv;
226 edm::LogVerbatim(
"HFShower") <<
"-#PMT=0 cut-HFShowerParam::getHits: npmt = " << npmt;
229 }
else if (npmt > 24) {
234 edm::LogVerbatim(
"HFShower") <<
"-SHORT cut-HFShowerParam::getHits:zMin=" << gpar_[0];
241 <<
"HFShowerParam: npmt " << npmt <<
" zv " <<
std::abs(pe_effect.z()) <<
":" << gpar_[4] <<
":" << zv
242 <<
":" << gpar_[0] <<
" ok " << ok <<
" depth " << depth;
245 if (G4UniformRand() > 0.5)
247 if (depth == 2 && zv < gpar_[0])
251 double dist =
fibre_->zShift(localPoint, depth, 0);
252 double r1 = G4UniformRand();
254 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam:Distance to PMT (" << npmt <<
") " << dist
260 double r2 = G4UniformRand();
263 <<
"HFShowerParam:Extra exclusion " << r2 <<
">" << weight <<
" " << (r2 >
weight);
266 double time =
fibre_->tShift(localPoint, depth, 0);
270 hit.
time = time + hitSL[
i].time;
278 double zp = hit.
position.z() / CLHEP::cm;
279 if (hit.
depth == 1) {
283 }
else if (hit.
depth == 2) {
292 <<
"HFShowerParam: Hit at depth " << hit.
depth <<
" with edep " << hit.
edep <<
" Time " << hit.
time;
301 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
302 double time =
fibre_->tShift(localPoint, 1, 0);
310 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits hitPoint " << hitPoint <<
" flag " <<
ok;
318 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep " << edep <<
" Time " << tSlice
319 <<
":" << time <<
":" << hit.
time;
327 if (zz >=
gpar_[0]) {
328 time =
fibre_->tShift(localPoint, 2, 0);
333 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep " << edep <<
" Time " << tSlice
334 <<
":" << time << hit.
time;
345 for (
unsigned int ii = 0;
ii < hits.size(); ++
ii) {
348 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: Abnormal hit along " << path <<
" in " 349 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName() <<
" at " 350 << hits[
ii].position <<
" zz " << zv <<
" Edep " << edep <<
" due to " 351 <<
track->GetDefinition()->GetParticleName() <<
" time " << hit.
time;
353 edm::LogVerbatim(
"HFShower") <<
"HFShowerParam: getHits kill (" << isKilled <<
") track " <<
track->GetTrackID()
354 <<
" at " << hitPoint <<
" and deposit " << edep <<
" " << hits.size() <<
" times" 355 <<
" ZZ " << zz <<
" " <<
gpar_[0];
std::unique_ptr< HFGflash > gflash_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
HFShowerParam(const std::string &name, const HcalDDDSimConstants *hcons, const HcalSimulationParameters *hps, edm::ParameterSet const &p)
std::vector< double > gpar_
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
std::unique_ptr< HFFibre > fibre_
std::vector< Hit > getHits(const G4Step *aStep, double weight, bool &isKilled)
T * make(const Args &...args) const
make new ROOT object
const std::vector< double > & getGparHF() const
int PMTNumber(const G4ThreeVector &pe_effect)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
std::unique_ptr< HFShowerLibrary > showerLibrary_
static int position[264][3]
static bool isGammaElectronPositron(int pdgCode)
const HcalDDDSimConstants * hcalConstants_
Power< A, B >::type pow(const A &a, const B &b)