CMS 3D CMS Logo

MaterialBudgetHcal.cc
Go to the documentation of this file.
2 
7 
11 
15 
16 #include "G4Step.hh"
17 #include "G4Track.hh"
18 
19 #include <iostream>
20 #include <memory>
21 
23  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("MaterialBudgetHcal");
24  rMax_ = m_p.getUntrackedParameter<double>("RMax", 4.5) * CLHEP::m;
25  zMax_ = m_p.getUntrackedParameter<double>("ZMax", 13.0) * CLHEP::m;
26  fromdd4hep_ = m_p.getUntrackedParameter<bool>("Fromdd4hep", false);
27  bool doHcal = m_p.getUntrackedParameter<bool>("DoHCAL", true);
28  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcal initialized with rMax " << rMax_ << " mm and zMax " << zMax_
29  << " mm doHcal is set to " << doHcal << " and Fromdd4hep to " << fromdd4hep_;
30  if (doHcal) {
31  theHistoHcal_ = std::make_unique<MaterialBudgetHcalHistos>(m_p);
32  theHistoCastor_.reset(nullptr);
33  } else {
34  theHistoHcal_.reset(nullptr);
35  theHistoCastor_ = std::make_unique<MaterialBudgetCastorHistos>(m_p);
36  }
37 }
38 
40  //----- Check that selected volumes are indeed part of the geometry
41  // Numbering From DDD
42  if (fromdd4hep_) {
44  (*job)()->get<IdealGeometryRecord>().get(pDD);
45  if (theHistoHcal_)
46  theHistoHcal_->fillBeginJob((*pDD));
47  } else {
49  (*job)()->get<IdealGeometryRecord>().get(pDD);
50  if (theHistoHcal_)
51  theHistoHcal_->fillBeginJob((*pDD));
52  }
53 }
54 
56  const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted
57  if (theHistoHcal_)
58  theHistoHcal_->fillStartTrack(aTrack);
59  if (theHistoCastor_)
60  theHistoCastor_->fillStartTrack(aTrack);
61 }
62 
63 void MaterialBudgetHcal::update(const G4Step* aStep) {
64  //---------- each step
65  if (theHistoHcal_)
66  theHistoHcal_->fillPerStep(aStep);
67  if (theHistoCastor_)
68  theHistoCastor_->fillPerStep(aStep);
69 
70  //----- Stop tracking after selected position
71  if (stopAfter(aStep)) {
72  G4Track* track = aStep->GetTrack();
73  track->SetTrackStatus(fStopAndKill);
74  }
75 }
76 
78  if (theHistoHcal_)
79  theHistoHcal_->fillEndTrack();
80  if (theHistoCastor_)
81  theHistoCastor_->fillEndTrack();
82 }
83 
84 bool MaterialBudgetHcal::stopAfter(const G4Step* aStep) {
85  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
86  double rr = hitPoint.perp();
87  double zz = std::abs(hitPoint.z());
88 
89  if (rr > rMax_ || zz > zMax_) {
90  edm::LogVerbatim("MaterialBudget") << " MaterialBudgetHcal::StopAfter R = " << rr << " and Z = " << zz;
91  return true;
92  } else {
93  return false;
94  }
95 }
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
ESTransientHandle.h
MessageLogger.h
BeginOfJob.h
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
EndOfTrack.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDCompactView.h
EndOfTrack
Definition: EndOfTrack.h:6
BeginOfTrack.h
MaterialBudgetHcal::theHistoHcal_
std::unique_ptr< MaterialBudgetHcalHistos > theHistoHcal_
Definition: MaterialBudgetHcal.h:37
MaterialBudgetHcal.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
BeginOfTrack
Definition: BeginOfTrack.h:6
BeginOfJob
Definition: BeginOfJob.h:8
DDCompactView.h
MaterialBudgetHcal::rMax_
double rMax_
Definition: MaterialBudgetHcal.h:39
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Event.h
MaterialBudgetHcal::MaterialBudgetHcal
MaterialBudgetHcal(const edm::ParameterSet &)
Definition: MaterialBudgetHcal.cc:22
IdealGeometryRecord.h
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
MaterialBudgetHcal::zMax_
double zMax_
Definition: MaterialBudgetHcal.h:39
MaterialBudgetHcal::update
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
Definition: MaterialBudgetHcal.cc:39
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
EventSetup.h
MaterialBudgetHcal::stopAfter
bool stopAfter(const G4Step *)
Definition: MaterialBudgetHcal.cc:84
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MaterialBudgetHcal::theHistoCastor_
std::unique_ptr< MaterialBudgetCastorHistos > theHistoCastor_
Definition: MaterialBudgetHcal.h:38
MaterialBudgetHcal::fromdd4hep_
bool fromdd4hep_
Definition: MaterialBudgetHcal.h:40