16 #include "G4VPhysicalVolume.hh" 19 #include "G4NavigationHistory.hh" 20 #include "Randomize.hh" 22 #include "CLHEP/Units/GlobalPhysicalConstants.h" 23 #include "CLHEP/Units/GlobalSystemOfUnits.h" 43 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
47 edm::LogInfo(
"HFShower") <<
"HFShowerParam::Use of shower library is set to " 48 << useShowerLibrary <<
" Use of Gflash is set to " 49 << useGflash <<
" P.E. per GeV " << pePerGeV
50 <<
", ref. index of fibre " << ref_index
51 <<
", Track EM Flag " << trackEM <<
", edMin " 52 << edMin <<
" GeV, use of Short fibre info in" 53 <<
" shower library set to " << !(
onlyLong)
54 <<
", use of parametrization for last part set to " 55 << parametrizeLast <<
", Mean lambda " << lambdaMean
56 <<
", aperture (cutoff) " << aperture
63 LogDebug(
"HFShower") <<
"HFShowerParam::Save histos in directory " 64 <<
"ProfileFromParam";
66 hzvem = showerDir.
make<TH1F>(
"hzvem",
"Longitudinal Profile (EM Part);Number of PE",330,0.0,1650.0);
67 hzvhad = showerDir.
make<TH1F>(
"hzvhad",
"Longitudinal Profile (Had Part);Number of PE",330,0.0,1650.0);
68 em_2d_1 = showerDir.
make<TH2F>(
"em_2d_1",
"Lateral Profile vs. Shower Depth;cm;Events",800,800.0,1600.0,100,50.0,150.0);
69 em_long_1 = showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
70 em_long_1_tuned = showerDir.
make<TH1F>(
"em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
71 em_lateral_1 = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events",100,50.0,150.0);
72 em_2d_2 = showerDir.
make<TH2F>(
"em_2d_2",
"Lateral Profile vs. Shower Depth;cm;Events",800,800.0,1600.0,100,50.0,150.0);
73 em_long_2 = showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
74 em_lateral_2 = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events",100,50.0,150.0);
75 em_long_gflash = showerDir.
make<TH1F>(
"em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots",800,800.0,1600.0);
76 em_long_sl = showerDir.
make<TH1F>(
"em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots",800,800.0,1600.0);
79 edm::LogInfo(
"HFShower") <<
"HFShowerParam::No file is available for " 80 <<
"saving histos so the flag is set to false";
88 edm::LogInfo(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
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())/
GeV;
114 double zint = hitPoint.z();
119 <<
track->GetDefinition()->GetParticleName()
120 <<
" of energy " << pin <<
" GeV" 121 <<
" Pos x,y,z = " << hitPoint.x() <<
"," 122 << hitPoint.y() <<
"," << zint <<
" (" << zz <<
"," 123 << localPoint.z() <<
", " 124 << (localPoint.z()+0.5*
gpar[1]) <<
") Local " 127 std::vector<HFShowerParam::Hit>
hits;
133 double pBeta =
track->GetDynamicParticle()->GetTotalMomentum() /
track->GetDynamicParticle()->GetTotalEnergy();
134 double dirz = (
track->GetDynamicParticle()->GetMomentumDirection()).
z();
135 if (hitPoint.z() < 0) dirz *= -1.;
137 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits Momentum " 138 <<
track->GetDynamicParticle()->GetMomentumDirection()
139 <<
" HitPoint " << hitPoint <<
" dirz " << dirz;
141 if (!isEM &&
track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1/
ref_index) &&
142 aStep->GetTotalEnergyDeposit() > 0.) { other =
true; }
151 }
else if ((
track->GetDefinition()->GetPDGCharge() != 0) &&
153 edep = (aStep->GetTotalEnergyDeposit())/
GeV;
157 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep
158 <<
" weight " << weight <<
" final " <<edep*weight
159 <<
", Kill = " << kill <<
", pin = " << pin
160 <<
", edMin = " <<
edMin <<
" Other " <<
other;
167 for (
unsigned int i=0;
i<hitSL.size();
i++) {
174 if (npmt <= 0) ok =
false;
178 hit.
depth = hitSL[
i].depth;
179 hit.
time = hitSL[
i].time;
189 if (hit.
depth == 1) {
193 }
else if (hit.
depth == 2) {
201 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth " 202 << hit.
depth <<
" with edep " << hit.
edep 203 <<
" Time " << hit.
time;
209 for (
unsigned int i=0;
i<hitSL.size(); ++
i) {
211 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(),
212 hitSL[
i].position.z());
217 if (zv < 0. || zv >
gpar[1]) {
219 std::cout<<
"-#Zcut-HFShowerParam::getHits:z="<<zv<<
",m="<<gpar[1]<<std::endl;
226 edm::LogInfo(
"HFShower") <<
"HFShowerParam::getHits:#PMT= " 227 << npmt <<
",z = " << zv;
231 edm::LogInfo(
"HFShower") <<
"-#PMT=0 cut-HFShowerParam::" 232 <<
"getHits: npmt = " << npmt;
235 }
else if (npmt > 24) {
240 edm::LogInfo(
"HFShower") <<
"-SHORT cut-HFShowerParam::" 241 <<
"getHits:zMin=" << gpar[0];
247 edm::LogInfo(
"HFShower") <<
"HFShowerParam: npmt " << npmt
248 <<
" zv " <<
std::abs(pe_effect.z())
249 <<
":" << gpar[4] <<
":" << zv <<
":" 250 << gpar[0] <<
" ok " << ok <<
" depth " 254 if (G4UniformRand() > 0.5) depth = 2;
255 if (depth == 2 && zv < gpar[0]) ok =
false;
259 double r1 = G4UniformRand();
261 edm::LogInfo(
"HFShower") <<
"HFShowerParam:Distance to PMT (" <<npmt
262 <<
") " << dist <<
", exclusion flag " 267 double r2 = G4UniformRand();
269 edm::LogInfo(
"HFShower") <<
"HFShowerParam:Extra exclusion " 270 << r2 <<
">" << weight <<
" " 278 hit.
time = time + hitSL[
i].time;
287 if (hit.
depth == 1) {
291 }
else if (hit.
depth == 2) {
299 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth " 300 << hit.
depth <<
" with edep " 301 << hit.
edep <<
" Time " << hit.
time;
310 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
315 if (npmt <= 0) ok =
false;
318 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits hitPoint " << hitPoint <<
" flag " <<
ok;
326 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep " 327 << edep <<
" Time " << tSlice <<
":" << time
342 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep " 343 << edep <<
" Time " << tSlice <<
":" << time
355 for (
unsigned int ii=0;
ii<hits.size(); ++
ii) {
357 if (zv > 12790)
edm::LogInfo(
"HFShower")<<
"HFShowerParam: Abnormal hit along " 359 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName()
360 <<
" at " << hits[
ii].position <<
" zz " 361 << zv <<
" Edep " << edep <<
" due to " 362 <<
track->GetDefinition()->GetParticleName()
363 <<
" time " << hit.
time;
365 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits kill (" << kill
366 <<
") track " <<
track->GetTrackID()
367 <<
" at " << hitPoint
368 <<
" and deposit " << edep <<
" " << hits.size()
369 <<
" times" <<
" ZZ " << zz <<
" " <<
gpar[0];
380 LogDebug(
"HFShower") <<
"HFShowerParam:getDDDArray called for " <<
str;
388 const std::vector<double> & fvec = value.
doubles();
389 int nval = fvec.size();
392 <<
" bins " << nval <<
" < 2 ==> illegal";
393 throw cms::Exception(
"Unknown",
"HFShowerParam") <<
"nval < 2 for array " 399 throw cms::Exception(
"Unknown",
"HFShowerParam") <<
"cannot get array "
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
T getParameter(std::string const &) const
HFShowerParam(const std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< Hit > gfParameterization(const G4Step *aStep, bool onlyLong=false)
std::vector< Hit > getHits(const G4Step *aStep, bool &ok, double weight, bool onlyLong=false)
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
void initRun(const HcalDDDSimConstants *)
double attLength(double lambda)
void initRun(const HcalDDDSimConstants *)
std::vector< double > gpar
double zShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
HFShowerLibrary * showerLibrary
Compact representation of the geometrical detector hierarchy.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
static int PMTNumber(const G4ThreeVector &pe_effect)
Cos< T >::type cos(const T &t)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Abs< T >::type abs(const T &t)
std::vector< Hit > getHits(const G4Step *aStep, double weight, bool &isKilled)
T * make(const Args &...args) const
make new ROOT object
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
static int position[264][3]
static bool isGammaElectronPositron(int pdgCode)
Power< A, B >::type pow(const A &a, const B &b)
void initRun(G4ParticleTable *, const HcalDDDSimConstants *)