15 #include "G4VPhysicalVolume.hh"
18 #include "G4NavigationHistory.hh"
19 #include "Randomize.hh"
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
36 bool useShowerLibrary = m_HF.
getParameter<
bool>(
"UseShowerLibrary");
41 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
45 edm::LogInfo(
"HFShower") <<
"HFShowerParam::Use of shower library is set to "
46 << useShowerLibrary <<
" Use of Gflash is set to "
47 << useGflash <<
" P.E. per GeV " << pePerGeV
48 <<
", ref. index of fibre " << ref_index
49 <<
", Track EM Flag " << trackEM <<
", edMin "
50 << edMin <<
" GeV, use of Short fibre info in"
51 <<
" shower library set to " << !(
onlyLong)
52 <<
", use of parametrization for last part set to "
53 << parametrizeLast <<
", Mean lambda " << lambdaMean
54 <<
", aperture (cutoff) " << aperture
61 LogDebug(
"HFShower") <<
"HFShowerParam::Save histos in directory "
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);
66 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);
67 em_long_1 = showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
68 em_long_1_tuned = showerDir.
make<TH1F>(
"em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
69 em_lateral_1 = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events",100,50.0,150.0);
70 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);
71 em_long_2 = showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
72 em_lateral_2 = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events",100,50.0,150.0);
73 em_long_gflash = showerDir.
make<TH1F>(
"em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots",800,800.0,1600.0);
74 em_long_sl = showerDir.
make<TH1F>(
"em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots",800,800.0,1600.0);
77 edm::LogInfo(
"HFShower") <<
"HFShowerParam::No file is available for "
78 <<
"saving histos so the flag is set to false";
82 G4String attribute =
"ReadOutName";
94 edm::LogInfo(
"HFShower") <<
"HFShowerParam: " <<gpar.size() <<
" gpar (cm)";
95 for (
unsigned int ig=0; ig<gpar.size(); ig++)
96 edm::LogInfo(
"HFShower") <<
"HFShowerParam: gpar[" << ig <<
"] = "
97 << gpar[ig]/cm <<
" cm";
99 edm::LogError(
"HFShower") <<
"HFShowerParam: cannot get filtered "
100 <<
" view for " << attribute <<
" matching " <<
name;
101 throw cms::Exception(
"Unknown",
"HFShowerParam") <<
"cannot match " << attribute
102 <<
" to " << name <<
"\n";
109 edm::LogInfo(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
120 emPDG = theParticleTable->FindParticle(
"e-")->GetPDGEncoding();
121 epPDG = theParticleTable->FindParticle(
"e+")->GetPDGEncoding();
122 gammaPDG = theParticleTable->FindParticle(
"gamma")->GetPDGEncoding();
132 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
133 G4Track * track = aStep->GetTrack();
134 G4ThreeVector hitPoint = preStepPoint->GetPosition();
135 G4int particleCode = track->GetDefinition()->GetPDGEncoding();
137 G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(),hitPoint.y(),zv);
139 double pin = (preStepPoint->GetTotalEnergy())/GeV;
140 double zint = hitPoint.z();
145 << track->GetDefinition()->GetParticleName()
146 <<
" of energy " << pin <<
" GeV"
147 <<
" Pos x,y,z = " << hitPoint.x() <<
","
148 << hitPoint.y() <<
"," << zint <<
" (" << zz <<
","
149 << localPoint.z() <<
", "
150 << (localPoint.z()+0.5*
gpar[1]) <<
") Local "
153 std::vector<HFShowerParam::Hit> hits;
159 double pBeta = track->GetDynamicParticle()->GetTotalMomentum() / track->GetDynamicParticle()->GetTotalEnergy();
160 double dirz = (track->GetDynamicParticle()->GetMomentumDirection()).
z();
161 if (hitPoint.z() < 0) dirz *= -1.;
163 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits Momentum "
164 <<track->GetDynamicParticle()->GetMomentumDirection()
165 <<
" HitPoint " << hitPoint <<
" dirz " << dirz;
168 if (track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1/
ref_index) &&
169 aStep->GetTotalEnergyDeposit() > 0) other =
true;
173 if (particleCode ==
emPDG || particleCode ==
epPDG ||
174 particleCode ==
gammaPDG || other) {
181 }
else if ((track->GetDefinition()->GetPDGCharge() != 0) &&
183 edep = (aStep->GetTotalEnergyDeposit())/GeV;
187 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep
188 <<
" weight " << weight <<
" final " <<edep*weight
189 <<
", Kill = " << kill <<
", pin = " << pin
190 <<
", edMin = " <<
edMin <<
" Other " << other;
197 for (
unsigned int i=0;
i<hitSL.size();
i++) {
204 if (npmt <= 0) ok =
false;
208 hit.
depth = hitSL[
i].depth;
209 hit.
time = hitSL[
i].time;
219 if (hit.
depth == 1) {
223 }
else if (hit.
depth == 2) {
231 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth "
232 << hit.
depth <<
" with edep " << hit.
edep
233 <<
" Time " << hit.
time;
239 for (
unsigned int i=0;
i<hitSL.size(); ++
i) {
241 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(),
242 hitSL[
i].position.z());
247 if (zv < 0. || zv >
gpar[1]) {
249 std::cout<<
"-#Zcut-HFShowerParam::getHits:z="<<zv<<
",m="<<gpar[1]<<std::endl;
256 edm::LogInfo(
"HFShower") <<
"HFShowerParam::getHits:#PMT= "
257 << npmt <<
",z = " << zv;
261 edm::LogInfo(
"HFShower") <<
"-#PMT=0 cut-HFShowerParam::"
262 <<
"getHits: npmt = " << npmt;
265 }
else if (npmt > 24) {
270 edm::LogInfo(
"HFShower") <<
"-SHORT cut-HFShowerParam::"
271 <<
"getHits:zMin=" << gpar[0];
277 edm::LogInfo(
"HFShower") <<
"HFShowerParam: npmt " << npmt
278 <<
" zv " <<
std::abs(pe_effect.z())
279 <<
":" << gpar[4] <<
":" << zv <<
":"
280 << gpar[0] <<
" ok " << ok <<
" depth "
284 if (G4UniformRand() > 0.5) depth = 2;
285 if (depth == 2 && zv < gpar[0]) ok =
false;
289 double r1 = G4UniformRand();
291 edm::LogInfo(
"HFShower") <<
"HFShowerParam:Distance to PMT (" <<npmt
292 <<
") " << dist <<
", exclusion flag "
297 double r2 = G4UniformRand();
299 edm::LogInfo(
"HFShower") <<
"HFShowerParam:Extra exclusion "
300 << r2 <<
">" << weight <<
" "
308 hit.
time = time + hitSL[
i].time;
317 if (hit.
depth == 1) {
321 }
else if (hit.
depth == 2) {
329 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth "
330 << hit.
depth <<
" with edep "
331 << hit.
edep <<
" Time " << hit.
time;
340 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
345 if (npmt <= 0) ok =
false;
348 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits hitPoint " << hitPoint <<
" flag " <<
ok;
356 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep "
357 << edep <<
" Time " << tSlice <<
":" << time
372 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep "
373 << edep <<
" Time " << tSlice <<
":" << time
385 for (
unsigned int ii=0;
ii<hits.size(); ++
ii) {
387 if (zv > 12790)
edm::LogInfo(
"HFShower")<<
"HFShowerParam: Abnormal hit along "
389 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName()
390 <<
" at " << hits[
ii].position <<
" zz "
391 << zv <<
" Edep " << edep <<
" due to "
392 <<track->GetDefinition()->GetParticleName()
393 <<
" time " << hit.
time;
397 track->SetTrackStatus(fStopAndKill);
398 G4TrackVector tv = *(aStep->GetSecondary());
399 for (
unsigned int kk=0; kk<tv.size(); ++kk) {
400 if (tv[kk]->
GetVolume() == preStepPoint->GetPhysicalVolume())
401 tv[kk]->SetTrackStatus(fStopAndKill);
405 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits kill (" << kill
406 <<
") track " << track->GetTrackID()
407 <<
" at " << hitPoint
408 <<
" and deposit " << edep <<
" " << hits.size()
409 <<
" times" <<
" ZZ " << zz <<
" " <<
gpar[0];
420 LogDebug(
"HFShower") <<
"HFShowerParam:getDDDArray called for " << str;
428 const std::vector<double> & fvec = value.
doubles();
429 int nval = fvec.size();
432 <<
" bins " << nval <<
" < 2 ==> illegal";
433 throw cms::Exception(
"Unknown",
"HFShowerParam") <<
"nval < 2 for array "
438 edm::LogError(
"HFShower") <<
"HFShowerParam : cannot get array " << str;
439 throw cms::Exception(
"Unknown",
"HFShowerParam") <<
"cannot get array "
std::vector< Hit > gfParameterization(G4Step *aStep, bool &ok, bool onlyLong=false)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
void addFilter(const DDFilter &, log_op op=AND)
static int PMTNumber(G4ThreeVector pe_effect)
std::vector< Hit > getHits(G4Step *aStep, bool &ok, double weight, bool onlyLong=false)
double attLength(double lambda)
std::vector< double > gpar
HFShowerLibrary * showerLibrary
HFShowerParam(std::string &name, const DDCompactView &cpv, edm::ParameterSet const &p)
type of data representation of DDCompactView
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
static int position[TOTALCHAMBERS][3]
double zShift(G4ThreeVector point, int depth, int fromEndAbs=0)
Cos< T >::type cos(const T &t)
double tShift(G4ThreeVector point, int depth, int fromEndAbs=0)
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::...
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
static const G4LogicalVolume * GetVolume(const std::string &name)
std::vector< Hit > getHits(G4Step *aStep, double weight)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
DDsvalues_type mergedSpecifics() const
void initRun(G4ParticleTable *theParticleTable)
void initRun(G4ParticleTable *)
bool firstChild()
set the current node to the first child ...
T * make() const
make new ROOT object
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
Power< A, B >::type pow(const A &a, const B &b)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.