CMS 3D CMS Logo

MaterialBudgetHcal.cc
Go to the documentation of this file.
2 
7 
11 
14 
15 #include "G4Step.hh"
16 #include "G4Track.hh"
17 
18 #include <iostream>
19 
20 MaterialBudgetHcal::MaterialBudgetHcal(const edm::ParameterSet& p) : theHistoHcal(nullptr), theHistoCastor(nullptr) {
21  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("MaterialBudgetHcal");
22  rMax = m_p.getUntrackedParameter<double>("RMax", 4.5) * CLHEP::m;
23  zMax = m_p.getUntrackedParameter<double>("ZMax", 13.0) * CLHEP::m;
24  bool doHcal = m_p.getUntrackedParameter<bool>("DoHCAL", true);
25  edm::LogInfo("MaterialBudget") << "MaterialBudgetHcal initialized with rMax " << rMax << " mm and zMax " << zMax
26  << " mm"
27  << " doHcal is set to " << doHcal;
28  if (doHcal)
30  else
32 }
33 
35  if (theHistoHcal)
36  delete theHistoHcal;
37  if (theHistoCastor)
38  delete theHistoCastor;
39 }
40 
42  //----- Check that selected volumes are indeed part of the geometry
43  // Numbering From DDD
45  (*job)()->get<IdealGeometryRecord>().get(pDD);
46  if (theHistoHcal)
47  theHistoHcal->fillBeginJob((*pDD));
48 }
49 
51  const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted
52  if (theHistoHcal)
54  if (theHistoCastor)
56 }
57 
58 void MaterialBudgetHcal::update(const G4Step* aStep) {
59  //---------- each step
60  if (theHistoHcal)
61  theHistoHcal->fillPerStep(aStep);
62  if (theHistoCastor)
64 
65  //----- Stop tracking after selected position
66  if (stopAfter(aStep)) {
67  G4Track* track = aStep->GetTrack();
68  track->SetTrackStatus(fStopAndKill);
69  }
70 }
71 
73  if (theHistoHcal)
75  if (theHistoCastor)
77 }
78 
79 bool MaterialBudgetHcal::stopAfter(const G4Step* aStep) {
80  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
81  double rr = hitPoint.perp();
82  double zz = std::abs(hitPoint.z());
83 
84  if (rr > rMax || zz > zMax) {
85  LogDebug("MaterialBudget") << " MaterialBudgetHcal::StopAfter R = " << rr << " and Z = " << zz;
86  return true;
87  } else {
88  return false;
89  }
90 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define nullptr
void fillBeginJob(const DDCompactView &)
bool stopAfter(const G4Step *)
void fillStartTrack(const G4Track *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MaterialBudgetCastorHistos * theHistoCastor
~MaterialBudgetHcal() override
MaterialBudgetHcal(const edm::ParameterSet &)
MaterialBudgetHcalHistos * theHistoHcal
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.