15 #include "G4VPhysicalVolume.hh"
18 #include "G4NavigationHistory.hh"
19 #include "Randomize.hh"
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
35 bool useShowerLibrary = m_HF.
getParameter<
bool>(
"UseShowerLibrary");
40 double lambdaMean = m_HF.
getParameter<
double>(
"LambdaMean");
43 edm::LogInfo(
"HFShower") <<
"HFShowerParam::Use of shower library is set to "
44 << useShowerLibrary <<
" Use of Gflash is set to "
45 << useGflash <<
" P.E. per GeV " << pePerGeV
46 <<
", ref. index of fibre " << ref_index
47 <<
", Track EM Flag " << trackEM <<
", edMin "
48 << edMin <<
" GeV, use of Short fibre info in"
49 <<
" shower library set to " << !(
onlyLong)
50 <<
", use of parametrization for last part set to "
51 << parametrizeLast <<
", Mean lambda " << lambdaMean
52 <<
", Application of Fiducial Cut " << applyFidCut;
58 LogDebug(
"HFShower") <<
"HFShowerParam::Save histos in directory "
59 <<
"ProfileFromParam";
61 hzv = showerDir.
make<TH1F>(
"hzv",
"Longitudinal Profile;Radiation Length;Number of Spots",330,0.0,1650.0);
62 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);
63 em_long_1 = showerDir.
make<TH1F>(
"em_long_1",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
64 em_long_1_tuned = showerDir.
make<TH1F>(
"em_long_1_tuned",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
65 em_lateral_1 = showerDir.
make<TH1F>(
"em_lateral_1",
"Lateral Profile;cm;Events",100,50.0,150.0);
66 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);
67 em_long_2 = showerDir.
make<TH1F>(
"em_long_2",
"Longitudinal Profile;Radiation Length;Number of Spots",800,800.0,1600.0);
68 em_lateral_2 = showerDir.
make<TH1F>(
"em_lateral_2",
"Lateral Profile;cm;Events",100,50.0,150.0);
69 em_long_gflash = showerDir.
make<TH1F>(
"em_long_gflash",
"Longitudinal Profile From GFlash;cm;Number of Spots",800,800.0,1600.0);
70 em_long_sl = showerDir.
make<TH1F>(
"em_long_sl",
"Longitudinal Profile From Shower Library;cm;Number of Spots",800,800.0,1600.0);
73 LogDebug(
"HFShower") <<
"HFShowerParam::No file is available for "
74 <<
"saving histos so the flag is set to false";
78 G4String attribute =
"ReadOutName";
90 edm::LogInfo(
"HFShower") <<
"HFShowerParam: " <<gpar.size() <<
" gpar (cm)";
91 for (
unsigned int ig=0; ig<gpar.size(); ig++)
92 edm::LogInfo(
"HFShower") <<
"HFShowerParam: gpar[" << ig <<
"] = "
93 << gpar[ig]/cm <<
" cm";
95 edm::LogError(
"HFShower") <<
"HFShowerParam: cannot get filtered "
96 <<
" view for " << attribute <<
" matching "
99 <<
"cannot match " << attribute <<
" to " << name <<
"\n";
106 edm::LogInfo(
"HFShower") <<
"att. length used for (lambda=" << lambdaMean
118 emPDG = theParticleTable->FindParticle(
"e-")->GetPDGEncoding();
119 epPDG = theParticleTable->FindParticle(
"e+")->GetPDGEncoding();
120 gammaPDG = theParticleTable->FindParticle(
"gamma")->GetPDGEncoding();
123 <<
" for e+ = " <<
epPDG <<
" for gamma = "
131 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
132 G4Track * track = aStep->GetTrack();
133 G4ThreeVector hitPoint = preStepPoint->GetPosition();
134 G4int particleCode = track->GetDefinition()->GetPDGEncoding();
136 G4ThreeVector localPoint = G4ThreeVector(hitPoint.x(),hitPoint.y(),zv);
138 double pin = (preStepPoint->GetTotalEnergy())/GeV;
139 double zint = hitPoint.z();
144 << track->GetDefinition()->GetParticleName()
145 <<
" of energy " << pin <<
" GeV"
146 <<
" Pos x,y,z = " << hitPoint.x() <<
","
147 << hitPoint.y() <<
"," << zint <<
" (" << zz <<
","
148 << localPoint.z() <<
", "
149 << (localPoint.z()+0.5*
gpar[1]) <<
") Local "
152 std::vector<HFShowerParam::Hit> hits;
158 double pBeta = track->GetDynamicParticle()->GetTotalMomentum() / track->GetDynamicParticle()->GetTotalEnergy();
160 if (track->GetDefinition()->GetPDGCharge() != 0 && pBeta > (1/
ref_index) &&
161 aStep->GetTotalEnergyDeposit() > 0) other =
true;
165 if (particleCode ==
emPDG || particleCode ==
epPDG ||
166 particleCode ==
gammaPDG || other) {
173 }
else if (track->GetDefinition()->GetPDGCharge() != 0 &&
175 edep = (aStep->GetTotalEnergyDeposit())/GeV;
177 std::string
path =
"ShowerLibrary";
179 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits edep = " << edep
180 <<
", Kill = " << kill <<
", pin = " << pin
181 <<
", edMin = " <<
edMin <<
" Other " << other;
187 for (
unsigned int i=0;
i<hitSL.size();
i++) {
191 if (npmt <= 0) ok =
false;
195 hit.
depth = hitSL[
i].depth;
196 hit.
time = hitSL[
i].time;
203 if (hit.
depth == 1) {
207 }
else if (hit.
depth == 2) {
214 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth "
215 << hit.
depth <<
" with edep " << hit.
edep
216 <<
" Time " << hit.
time;
222 for (
unsigned int i=0;
i<hitSL.size();
i++) {
224 G4ThreeVector pe_effect(hitSL[
i].
position.x(), hitSL[
i].position.y(), hitSL[
i].position.z());
229 if (zv < 0 ) ok =
false;
230 if (zv >
gpar[1]) ok =
false;
233 if (npmt <= 0) ok =
false;
234 else if (npmt > 24) {
235 if (zv >
gpar[0]) depth = 2;
239 edm::LogInfo(
"HFShower") <<
"HFShowerParam: npmt " << npmt
240 <<
" zv " <<
std::abs(pe_effect.z())
241 <<
":" <<
gpar[4] <<
":" << zv <<
":"
242 <<
gpar[0] <<
" ok " << ok <<
" depth "
246 if (G4UniformRand() > 0.5) depth = 2;
247 if (depth == 2 && zv <
gpar[0]) ok =
false;
251 double r1 = G4UniformRand();
253 edm::LogInfo(
"HFShower") <<
"HFShowerParam:Distance to PMT (" <<npmt
254 <<
") " << dist <<
", exclusion flag "
263 hit.
time = time + hitSL[
i].time;
270 if (hit.
depth == 1) {
274 }
else if (hit.
depth == 2) {
281 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth "
282 << hit.
depth <<
" with edep "
283 << hit.
edep <<
" Time " << hit.
time;
291 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
298 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 1 with edep "
299 << edep <<
" Time " << tSlice <<
":" << time
308 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Hit at depth 2 with edep "
309 << edep <<
" Time " << tSlice <<
":" << time
315 for (
unsigned int ii=0; ii<hits.size(); ii++) {
318 edm::LogInfo(
"HFShower") <<
"HFShowerParam: Abnormal hit along "
320 << preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName()
321 <<
" at " << hits[ii].position <<
" zz "
322 << zv <<
" Edep " << edep <<
" due to "
323 << track->GetDefinition()->GetParticleName()
324 <<
" time " << hit.
time;
328 track->SetTrackStatus(fStopAndKill);
329 G4TrackVector tv = *(aStep->GetSecondary());
330 for (
unsigned int kk=0; kk<tv.size(); kk++) {
331 if (tv[kk]->
GetVolume() == preStepPoint->GetPhysicalVolume())
332 tv[kk]->SetTrackStatus(fStopAndKill);
336 edm::LogInfo(
"HFShower") <<
"HFShowerParam: getHits kill (" << kill
337 <<
") track " << track->GetTrackID()
338 <<
" at " << hitPoint
339 <<
" and deposit " << edep <<
" " << hits.size()
340 <<
" times" <<
" ZZ " << zz <<
" " <<
gpar[0];
352 LogDebug(
"HFShower") <<
"HFShowerParam:getDDDArray called for " << str;
359 const std::vector<double> & fvec = value.
doubles();
360 int nval = fvec.size();
363 <<
" bins " << nval <<
" < 2 ==> illegal";
365 <<
"nval < 2 for array " << str <<
"\n";
370 edm::LogError(
"HFShower") <<
"HFShowerParam : cannot get array " << str;
372 <<
"cannot get array " << str <<
"\n";
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
std::vector< Hit > getHits(G4Step *aStep, bool &ok, bool onlyLong=false)
void addFilter(const DDFilter &, log_op op=AND)
std::vector< Hit > getHits(G4Step *aStep)
static int PMTNumber(G4ThreeVector pe_effect)
double attLength(double lambda)
std::vector< double > gpar
Exp< T >::type exp(const T &t)
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)
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)
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
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.