CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalTBMBProducer Class Reference
Inheritance diagram for HGCalTBMBProducer:
SimProducer Observer< const BeginOfTrack * > Observer< const G4Step * > Observer< const EndOfTrack * > SimWatcher

Public Member Functions

 HGCalTBMBProducer (const edm::ParameterSet &)
 
 HGCalTBMBProducer (const HGCalTBMBProducer &)=delete
 
const HGCalTBMBProduceroperator= (const HGCalTBMBProducer &)=delete
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HGCalTBMBProducer () override=default
 
- Public Member Functions inherited from SimProducer
const SimProduceroperator= (const SimProducer &)=delete
 
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
 SimProducer (const SimProducer &)=delete
 
- 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_
 
MaterialAccountingCaloCollection matcoll_
 
unsigned int nList_
 
std::vector< double > radLen_
 
std::vector< double > stepLen_
 
std::string stopName_
 
double stopZ_
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 
- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 23 of file HGCalTBMBProducer.cc.

Constructor & Destructor Documentation

HGCalTBMBProducer::HGCalTBMBProducer ( const edm::ParameterSet p)

Definition at line 51 of file HGCalTBMBProducer.cc.

References edm::ParameterSet::getParameter(), isotrackApplyRegressor::k, listNames_, nList_, stopName_, stopZ_, and AlCaHLTBitMon_QueryRunRegistry::string.

51  {
52  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("HGCalTBMB");
53  listNames_ = m_p.getParameter<std::vector<std::string> >("DetectorNames");
54  stopName_ = m_p.getParameter<std::string>("StopName");
55  stopZ_ = m_p.getParameter<double>("MaximumZ");
56  nList_ = listNames_.size();
57  edm::LogVerbatim("HGCSim") << "HGCalTBMBProducer initialized for " << nList_ << " volumes";
58  for (unsigned int k = 0; k < nList_; ++k)
59  edm::LogVerbatim("HGCSim") << " [" << k << "] " << listNames_[k];
60  edm::LogVerbatim("HGCSim") << "Stop after " << stopZ_ << " or reaching volume " << stopName_;
61 
62  produces<MaterialAccountingCaloCollection>("HGCalTBMB");
63 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > listNames_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGCalTBMBProducer::HGCalTBMBProducer ( const HGCalTBMBProducer )
delete
HGCalTBMBProducer::~HGCalTBMBProducer ( )
overridedefault

Member Function Documentation

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

Definition at line 153 of file HGCalTBMBProducer.cc.

References cuy::ii, isotrackApplyRegressor::k, testEve_cfg::level, listNames_, mergeVDriftHistosByStation::name, nList_, stopName_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by stopAfter(), and update().

153  {
154  int ivol = -1;
155  int level = (touch->GetHistoryDepth()) + 1;
156  for (int ii = 0; ii < level; ii++) {
157  std::string name = touch->GetVolume(ii)->GetName();
158  if (stop) {
159  if (strcmp(name.c_str(), stopName_.c_str()) == 0)
160  ivol = 0;
161  } else {
162  for (unsigned int k = 0; k < nList_; ++k) {
163  if (strcmp(name.c_str(), listNames_[k].c_str()) == 0) {
164  ivol = k;
165  break;
166  }
167  }
168  }
169  if (ivol >= 0)
170  break;
171  }
172  return ivol;
173 }
std::vector< std::string > listNames_
int ii
Definition: cuy.py:589
tuple level
Definition: testEve_cfg.py:47
const HGCalTBMBProducer& HGCalTBMBProducer::operator= ( const HGCalTBMBProducer )
delete
void HGCalTBMBProducer::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 65 of file HGCalTBMBProducer.cc.

References matcoll_, eostools::move(), and edm::Event::put().

65  {
66  std::unique_ptr<MaterialAccountingCaloCollection> hgc(new MaterialAccountingCaloCollection);
67  for (auto const& mbc : matcoll_) {
68  hgc->emplace_back(mbc);
69  }
70  e.put(std::move(hgc), "HGCalTBMB");
71 }
MaterialAccountingCaloCollection matcoll_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< MaterialAccountingCalo > MaterialAccountingCaloCollection
def move
Definition: eostools.py:511
bool HGCalTBMBProducer::stopAfter ( const G4Step *  aStep)
private

Definition at line 136 of file HGCalTBMBProducer.cc.

References findVolume(), and stopZ_.

Referenced by update().

136  {
137  bool flag(false);
138  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
139  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
140  if (aStep->GetPostStepPoint() != nullptr)
141  hitPoint = aStep->GetPostStepPoint()->GetPosition();
142  double zz = hitPoint.z();
143 
144  if ((findVolume(touch, true) == 0) || (zz > stopZ_))
145  flag = true;
146 #ifdef EDM_ML_DEBUG
147  edm::LogVerbatim("HGCSim") << " HGCalTBMBProducer::Name " << touch->GetVolume(0)->GetName() << " z " << zz << " Flag"
148  << flag;
149 #endif
150  return flag;
151 }
Log< level::Info, true > LogVerbatim
int findVolume(const G4VTouchable *touch, bool stop) const
void HGCalTBMBProducer::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 73 of file HGCalTBMBProducer.cc.

References GeV, intLen_, nList_, radLen_, and stepLen_.

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

73  {
74  radLen_ = std::vector<double>(nList_ + 1, 0);
75  intLen_ = std::vector<double>(nList_ + 1, 0);
76  stepLen_ = std::vector<double>(nList_ + 1, 0);
77 
78 #ifdef EDM_ML_DEBUG
79  const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted
80  const G4ThreeVector& mom = aTrack->GetMomentum();
81  double theEnergy = aTrack->GetTotalEnergy();
82  int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding());
83  edm::LogVerbatim("HGCSim") << "HGCalTBMBProducer: Track " << aTrack->GetTrackID() << " Code " << theID << " Energy "
84  << theEnergy / CLHEP::GeV << " GeV; Momentum " << mom;
85 #endif
86 }
Log< level::Info, true > LogVerbatim
const double GeV
Definition: MathUtil.h:16
std::vector< double > radLen_
std::vector< double > stepLen_
std::vector< double > intLen_
void HGCalTBMBProducer::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 88 of file HGCalTBMBProducer.cc.

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

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

88  {
89  G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
90  double step = aStep->GetStepLength();
91  double radl = material->GetRadlen();
92  double intl = material->GetNuclearInterLength();
93 
94  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
95  int indx = findVolume(touch, false);
96 
97  if (indx >= 0) {
98  stepLen_[indx] += step;
99  radLen_[indx] += (step / radl);
100  intLen_[indx] += (step / intl);
101  }
102  stepLen_[nList_] += step;
103  radLen_[nList_] += (step / radl);
104  intLen_[nList_] += (step / intl);
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("HGCSim") << "HGCalTBMBProducer::Step in " << touch->GetVolume(0)->GetLogicalVolume()->GetName()
107  << " Index " << indx << " Step " << step << " RadL " << step / radl << " IntL "
108  << step / intl;
109 #endif
110 
111  if (stopAfter(aStep)) {
112  G4Track* track = aStep->GetTrack();
113  track->SetTrackStatus(fStopAndKill);
114  }
115 }
Log< level::Info, true > LogVerbatim
std::vector< double > radLen_
int findVolume(const G4VTouchable *touch, bool stop) const
std::vector< double > stepLen_
std::vector< double > intLen_
step
Definition: StallMonitor.cc:94
bool stopAfter(const G4Step *)
void HGCalTBMBProducer::update ( const EndOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 117 of file HGCalTBMBProducer.cc.

References cuy::ii, intLen_, listNames_, MaterialAccountingCalo::m_eta, MaterialAccountingCalo::m_intLen, MaterialAccountingCalo::m_phi, MaterialAccountingCalo::m_radLen, MaterialAccountingCalo::m_stepLen, matcoll_, mergeVDriftHistosByStation::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().

117  {
118  MaterialAccountingCalo matCalo;
119  matCalo.m_eta = 0;
120  matCalo.m_phi = 0;
121  for (unsigned int ii = 0; ii <= nList_; ++ii) {
122  matCalo.m_stepLen.emplace_back(stepLen_[ii]);
123  matCalo.m_radLen.emplace_back(radLen_[ii]);
124  matCalo.m_intLen.emplace_back(intLen_[ii]);
125 #ifdef EDM_ML_DEBUG
126  std::string name("Total");
127  if (ii < nList_)
128  name = listNames_[ii];
129  edm::LogVerbatim("HGCSim") << "HGCalTBMBProducer::Volume[" << ii << "]: " << name << " == Step " << stepLen_[ii]
130  << " RadL " << radLen_[ii] << " IntL " << intLen_[ii];
131 #endif
132  }
133  matcoll_.emplace_back(matCalo);
134 }
Log< level::Info, true > LogVerbatim
MaterialAccountingCaloCollection matcoll_
std::vector< std::string > listNames_
std::vector< double > m_radLen
std::vector< double > radLen_
int ii
Definition: cuy.py:589
std::vector< double > stepLen_
std::vector< double > m_intLen
std::vector< double > intLen_
std::vector< double > m_stepLen

Member Data Documentation

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

Definition at line 48 of file HGCalTBMBProducer.cc.

Referenced by update().

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

Definition at line 43 of file HGCalTBMBProducer.cc.

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

MaterialAccountingCaloCollection HGCalTBMBProducer::matcoll_
private

Definition at line 47 of file HGCalTBMBProducer.cc.

Referenced by produce(), and update().

unsigned int HGCalTBMBProducer::nList_
private

Definition at line 46 of file HGCalTBMBProducer.cc.

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

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

Definition at line 48 of file HGCalTBMBProducer.cc.

Referenced by update().

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

Definition at line 48 of file HGCalTBMBProducer.cc.

Referenced by update().

std::string HGCalTBMBProducer::stopName_
private

Definition at line 44 of file HGCalTBMBProducer.cc.

Referenced by findVolume(), and HGCalTBMBProducer().

double HGCalTBMBProducer::stopZ_
private

Definition at line 45 of file HGCalTBMBProducer.cc.

Referenced by HGCalTBMBProducer(), and stopAfter().