CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalTBMB Class Reference
Inheritance diagram for HGCalTBMB:
SimWatcher Observer< const BeginOfTrack *> Observer< const G4Step *> Observer< const EndOfTrack *>

Public Member Functions

 HGCalTBMB (const edm::ParameterSet &)
 
 HGCalTBMB (const HGCalTBMB &)=delete
 
const HGCalTBMBoperator= (const HGCalTBMB &)=delete
 
 ~HGCalTBMB () override
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack *>
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step *>
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack *>
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 

Private Member Functions

int findVolume (const G4VTouchable *touch, bool stop) const
 
bool stopAfter (const G4Step *)
 
void update (const BeginOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

std::vector< double > intLen_
 
std::vector< std::string > listNames_
 
std::vector< TH1D * > me100_
 
std::vector< TH1D * > me200_
 
std::vector< TH1D * > me300_
 
unsigned int nList_
 
std::vector< double > radLen_
 
std::vector< double > stepLen_
 
std::string stopName_
 
double stopZ_
 

Additional Inherited Members

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 24 of file HGCalTBMB.cc.

Constructor & Destructor Documentation

◆ HGCalTBMB() [1/2]

HGCalTBMB::HGCalTBMB ( const edm::ParameterSet p)

Definition at line 50 of file HGCalTBMB.cc.

References edm::ParameterSet::getParameter(), compareTotals::hist, mps_fire::i, dqmdumpme::k, listNames_, me100_, me200_, me300_, Skims_PA_cff::name, nList_, AlCaHLTBitMon_ParallelJobs::p, stopName_, stopZ_, AlCaHLTBitMon_QueryRunRegistry::string, compare::tfile, and runGCPTkAlMap::title.

50  {
51  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("HGCalTBMB");
52  listNames_ = m_p.getParameter<std::vector<std::string> >("DetectorNames");
53  stopName_ = m_p.getParameter<std::string>("StopName");
54  stopZ_ = m_p.getParameter<double>("MaximumZ");
55  nList_ = listNames_.size();
56  edm::LogVerbatim("HGCSim") << "HGCalTBMB initialized for " << nList_ << " volumes";
57  for (unsigned int k = 0; k < nList_; ++k)
58  edm::LogVerbatim("HGCSim") << " [" << k << "] " << listNames_[k];
59  edm::LogVerbatim("HGCSim") << "Stop after " << stopZ_ << " or reaching volume " << stopName_;
60 
62  if (!tfile.isAvailable())
63  throw cms::Exception("BadConfig") << "TFileService unavailable: "
64  << "please add it to config file";
65  char name[20], title[80];
66  TH1D* hist;
67  for (unsigned int i = 0; i <= nList_; i++) {
68  std::string named = (i == nList_) ? "Total" : listNames_[i];
69  sprintf(name, "RadL%d", i);
70  sprintf(title, "MB(X0) for (%s)", named.c_str());
71  hist = tfile->make<TH1D>(name, title, 100000, 0.0, 100.0);
72  hist->Sumw2(true);
73  me100_.push_back(hist);
74  sprintf(name, "IntL%d", i);
75  sprintf(title, "MB(L0) for (%s)", named.c_str());
76  hist = tfile->make<TH1D>(name, title, 100000, 0.0, 10.0);
77  hist->Sumw2(true);
78  me200_.push_back(hist);
79  sprintf(name, "StepL%d", i);
80  sprintf(title, "MB(Step) for (%s)", named.c_str());
81  hist = tfile->make<TH1D>(name, title, 100000, 0.0, 50000.0);
82  hist->Sumw2(true);
83  me300_.push_back(hist);
84  }
85  edm::LogVerbatim("HGCSim") << "HGCalTBMB: Booking user histos done ===";
86 }
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double stopZ_
Definition: HGCalTBMB.cc:44
std::string stopName_
Definition: HGCalTBMB.cc:43
Definition: tfile.py:1
std::vector< TH1D * > me100_
Definition: HGCalTBMB.cc:47
unsigned int nList_
Definition: HGCalTBMB.cc:45
std::vector< TH1D * > me300_
Definition: HGCalTBMB.cc:47
std::vector< TH1D * > me200_
Definition: HGCalTBMB.cc:47
std::vector< std::string > listNames_
Definition: HGCalTBMB.cc:42

◆ HGCalTBMB() [2/2]

HGCalTBMB::HGCalTBMB ( const HGCalTBMB )
delete

◆ ~HGCalTBMB()

HGCalTBMB::~HGCalTBMB ( )
override

Definition at line 88 of file HGCalTBMB.cc.

88 {}

Member Function Documentation

◆ findVolume()

int HGCalTBMB::findVolume ( const G4VTouchable *  touch,
bool  stop 
) const
private

Definition at line 164 of file HGCalTBMB.cc.

References cuy::ii, dqmdumpme::k, personalPlayback::level, listNames_, Skims_PA_cff::name, nList_, stopName_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by stopAfter(), and update().

164  {
165  int ivol = -1;
166  int level = (touch->GetHistoryDepth()) + 1;
167  for (int ii = 0; ii < level; ii++) {
168  std::string name = touch->GetVolume(ii)->GetName();
169  if (stop) {
170  if (strcmp(name.c_str(), stopName_.c_str()) == 0)
171  ivol = 0;
172  } else {
173  for (unsigned int k = 0; k < nList_; ++k) {
174  if (strcmp(name.c_str(), listNames_[k].c_str()) == 0) {
175  ivol = k;
176  break;
177  }
178  }
179  }
180  if (ivol >= 0)
181  break;
182  }
183  return ivol;
184 }
std::string stopName_
Definition: HGCalTBMB.cc:43
unsigned int nList_
Definition: HGCalTBMB.cc:45
ii
Definition: cuy.py:589
std::vector< std::string > listNames_
Definition: HGCalTBMB.cc:42

◆ operator=()

const HGCalTBMB& HGCalTBMB::operator= ( const HGCalTBMB )
delete

◆ stopAfter()

bool HGCalTBMB::stopAfter ( const G4Step *  aStep)
private

Definition at line 148 of file HGCalTBMB.cc.

References findVolume(), RemoveAddSevLevel::flag, stopZ_, and geometryCSVtoXML::zz.

Referenced by update().

148  {
149  bool flag(false);
150  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
151  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
152  if (aStep->GetPostStepPoint() != nullptr)
153  hitPoint = aStep->GetPostStepPoint()->GetPosition();
154  double zz = hitPoint.z();
155 
156  if ((findVolume(touch, true) == 0) || (zz > stopZ_))
157  flag = true;
158 #ifdef EDM_ML_DEBUG
159  edm::LogVerbatim("HGCSim") << " HGCalTBMB::Name " << touch->GetVolume(0)->GetName() << " z " << zz << " Flag" << flag;
160 #endif
161  return flag;
162 }
Log< level::Info, true > LogVerbatim
int findVolume(const G4VTouchable *touch, bool stop) const
Definition: HGCalTBMB.cc:164
double stopZ_
Definition: HGCalTBMB.cc:44

◆ update() [1/3]

void HGCalTBMB::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack *>.

Definition at line 90 of file HGCalTBMB.cc.

References createfilelist::int, intLen_, nList_, radLen_, and stepLen_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

90  {
91  radLen_ = std::vector<double>(nList_ + 1, 0);
92  intLen_ = std::vector<double>(nList_ + 1, 0);
93  stepLen_ = std::vector<double>(nList_ + 1, 0);
94 
95 #ifdef EDM_ML_DEBUG
96  const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted
97  const G4ThreeVector& mom = aTrack->GetMomentum();
98  double theEnergy = aTrack->GetTotalEnergy();
99  int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding());
100  edm::LogVerbatim("HGCSim") << "MaterialBudgetHcalHistos: Track " << aTrack->GetTrackID() << " Code " << theID
101  << " Energy " << theEnergy / CLHEP::GeV << " GeV; Momentum " << mom;
102 #endif
103 }
Log< level::Info, true > LogVerbatim
std::vector< double > intLen_
Definition: HGCalTBMB.cc:46
unsigned int nList_
Definition: HGCalTBMB.cc:45
std::vector< double > radLen_
Definition: HGCalTBMB.cc:46
std::vector< double > stepLen_
Definition: HGCalTBMB.cc:46

◆ update() [2/3]

void HGCalTBMB::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 105 of file HGCalTBMB.cc.

References findVolume(), intLen_, nList_, radLen_, stepLen_, stopAfter(), and HLT_2023v12_cff::track.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

105  {
106  G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
107  double step = aStep->GetStepLength();
108  double radl = material->GetRadlen();
109  double intl = material->GetNuclearInterLength();
110 
111  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
112  int indx = findVolume(touch, false);
113 
114  if (indx >= 0) {
115  stepLen_[indx] += step;
116  radLen_[indx] += (step / radl);
117  intLen_[indx] += (step / intl);
118  }
119  stepLen_[nList_] += step;
120  radLen_[nList_] += (step / radl);
121  intLen_[nList_] += (step / intl);
122 #ifdef EDM_ML_DEBUG
123  edm::LogVerbatim("HGCSim") << "HGCalTBMB::Step in " << touch->GetVolume(0)->GetLogicalVolume()->GetName() << " Index "
124  << indx << " Step " << step << " RadL " << step / radl << " IntL " << step / intl;
125 #endif
126 
127  if (stopAfter(aStep)) {
128  G4Track* track = aStep->GetTrack();
129  track->SetTrackStatus(fStopAndKill);
130  }
131 }
Log< level::Info, true > LogVerbatim
int findVolume(const G4VTouchable *touch, bool stop) const
Definition: HGCalTBMB.cc:164
bool stopAfter(const G4Step *)
Definition: HGCalTBMB.cc:148
std::vector< double > intLen_
Definition: HGCalTBMB.cc:46
unsigned int nList_
Definition: HGCalTBMB.cc:45
std::vector< double > radLen_
Definition: HGCalTBMB.cc:46
step
Definition: StallMonitor.cc:98
std::vector< double > stepLen_
Definition: HGCalTBMB.cc:46

◆ update() [3/3]

void HGCalTBMB::update ( const EndOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack *>.

Definition at line 133 of file HGCalTBMB.cc.

References cuy::ii, intLen_, listNames_, me100_, me200_, me300_, Skims_PA_cff::name, nList_, radLen_, stepLen_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

133  {
134  for (unsigned int ii = 0; ii <= nList_; ++ii) {
135  me100_[ii]->Fill(radLen_[ii]);
136  me200_[ii]->Fill(intLen_[ii]);
137  me300_[ii]->Fill(stepLen_[ii]);
138 #ifdef EDM_ML_DEBUG
139  std::string name("Total");
140  if (ii < nList_)
141  name = listNames_[ii];
142  edm::LogVerbatim("HGCSim") << "HGCalTBMB::Volume[" << ii << "]: " << name << " == Step " << stepLen_[ii] << " RadL "
143  << radLen_[ii] << " IntL " << intLen_[ii];
144 #endif
145  }
146 }
Log< level::Info, true > LogVerbatim
std::vector< double > intLen_
Definition: HGCalTBMB.cc:46
std::vector< TH1D * > me100_
Definition: HGCalTBMB.cc:47
unsigned int nList_
Definition: HGCalTBMB.cc:45
ii
Definition: cuy.py:589
std::vector< TH1D * > me300_
Definition: HGCalTBMB.cc:47
std::vector< TH1D * > me200_
Definition: HGCalTBMB.cc:47
std::vector< double > radLen_
Definition: HGCalTBMB.cc:46
std::vector< std::string > listNames_
Definition: HGCalTBMB.cc:42
std::vector< double > stepLen_
Definition: HGCalTBMB.cc:46

Member Data Documentation

◆ intLen_

std::vector<double> HGCalTBMB::intLen_
private

Definition at line 46 of file HGCalTBMB.cc.

Referenced by update().

◆ listNames_

std::vector<std::string> HGCalTBMB::listNames_
private

Definition at line 42 of file HGCalTBMB.cc.

Referenced by findVolume(), HGCalTBMB(), and update().

◆ me100_

std::vector<TH1D*> HGCalTBMB::me100_
private

Definition at line 47 of file HGCalTBMB.cc.

Referenced by HGCalTBMB(), and update().

◆ me200_

std::vector<TH1D*> HGCalTBMB::me200_
private

Definition at line 47 of file HGCalTBMB.cc.

Referenced by HGCalTBMB(), and update().

◆ me300_

std::vector<TH1D*> HGCalTBMB::me300_
private

Definition at line 47 of file HGCalTBMB.cc.

Referenced by HGCalTBMB(), and update().

◆ nList_

unsigned int HGCalTBMB::nList_
private

Definition at line 45 of file HGCalTBMB.cc.

Referenced by findVolume(), HGCalTBMB(), and update().

◆ radLen_

std::vector<double> HGCalTBMB::radLen_
private

Definition at line 46 of file HGCalTBMB.cc.

Referenced by update().

◆ stepLen_

std::vector<double> HGCalTBMB::stepLen_
private

Definition at line 46 of file HGCalTBMB.cc.

Referenced by update().

◆ stopName_

std::string HGCalTBMB::stopName_
private

Definition at line 43 of file HGCalTBMB.cc.

Referenced by findVolume(), and HGCalTBMB().

◆ stopZ_

double HGCalTBMB::stopZ_
private

Definition at line 44 of file HGCalTBMB.cc.

Referenced by HGCalTBMB(), and stopAfter().