CMS 3D CMS Logo

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

Public Member Functions

void beginRun (edm::EventSetup const &) override
 
 MaterialBudgetHcalProducer (const edm::ParameterSet &)
 
 MaterialBudgetHcalProducer (const MaterialBudgetHcalProducer &)=delete
 
const MaterialBudgetHcalProduceroperator= (const MaterialBudgetHcalProducer &)=delete
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void registerConsumes (edm::ConsumesCollector) override
 
 ~MaterialBudgetHcalProducer () 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
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- 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

std::vector< double > getDDDArray (const std::string &str, const DDsvalues_type &sv)
 
std::vector< std::string > getNames (DDFilteredView &fv)
 
std::vector< std::string > getNames (cms::DDFilteredView &fv)
 
bool isItEC (const std::string &)
 
bool isItHF (const G4VTouchable *)
 
bool isSensitive (const std::string &)
 
bool stopAfter (const G4Step *)
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
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

edm::ESGetToken< cms::DDCompactView, IdealGeometryRecordcpvTokenDD4hep_
 
edm::ESGetToken< DDCompactView, IdealGeometryRecordcpvTokenDDD_
 
double eta_
 
double etaMaxP_
 
double etaMinP_
 
bool fromdd4hep_
 
std::vector< int > hfLevels_
 
std::vector< std::string > hfNames_
 
int id_
 
double intLen_
 
std::vector< double > intLength_
 
double intLens_ [maxSet_]
 
int layer_
 
MaterialAccountingCaloCollection matcoll_
 
std::vector< std::string > matList_
 
std::string name_
 
int nlayHB_
 
int nlayHE_
 
int nlayHF_
 
int nlayHO_
 
double phi_
 
bool printSum_
 
double radLen_
 
std::vector< double > radLength_
 
double radLens_ [maxSet_]
 
double rMax_
 
std::vector< std::string > sensitiveEC_
 
std::vector< std::string > sensitives_
 
double stepLen_
 
std::vector< double > stepLength_
 
double stepLens_ [maxSet_]
 
int steps_
 
double zMax_
 

Static Private Attributes

static const int maxSet2_ = 9
 
static const int maxSet_ = 25
 

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 43 of file MaterialBudgetHcalProducer.cc.

Constructor & Destructor Documentation

◆ MaterialBudgetHcalProducer() [1/2]

MaterialBudgetHcalProducer::MaterialBudgetHcalProducer ( const edm::ParameterSet p)

Definition at line 93 of file MaterialBudgetHcalProducer.cc.

References edm::ParameterSet::getUntrackedParameter(), visualization-live-secondInstance_cfg::m, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
94  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("MaterialBudgetHcalProducer");
95  rMax_ = m_p.getUntrackedParameter<double>("RMax", 4.5) * CLHEP::m;
96  zMax_ = m_p.getUntrackedParameter<double>("ZMax", 13.0) * CLHEP::m;
97  etaMinP_ = m_p.getUntrackedParameter<double>("EtaMinP", 5.2);
98  etaMaxP_ = m_p.getUntrackedParameter<double>("EtaMaxP", 0.0);
99  fromdd4hep_ = m_p.getUntrackedParameter<bool>("Fromdd4hep", false);
100  printSum_ = m_p.getUntrackedParameter<bool>("PrintSummary", false);
101  name_ = m_p.getUntrackedParameter<std::string>("Name", "Hcal");
102  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalProducer initialized with rMax " << rMax_ << " mm and zMax "
103  << zMax_ << " mm printSummary is set to " << printSum_ << " and Fromdd4hep to "
104  << fromdd4hep_;
105 
106  produces<MaterialAccountingCaloCollection>(Form("%sMatBCalo", name_.c_str()));
107 }
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const

◆ ~MaterialBudgetHcalProducer()

MaterialBudgetHcalProducer::~MaterialBudgetHcalProducer ( )
overridedefault

◆ MaterialBudgetHcalProducer() [2/2]

MaterialBudgetHcalProducer::MaterialBudgetHcalProducer ( const MaterialBudgetHcalProducer )
delete

Member Function Documentation

◆ beginRun()

void MaterialBudgetHcalProducer::beginRun ( edm::EventSetup const &  es)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 125 of file MaterialBudgetHcalProducer.cc.

References ALCARECOTkAlBeamHalo_cff::filter, spr::find(), DDFilteredView::firstChild(), cms::DDFilteredView::get(), edm::EventSetup::getData(), MsgTools::getNames(), mps_fire::i, dqmdumpme::k, personalPlayback::level, DDFilteredView::mergedSpecifics(), Skims_PA_cff::name, names, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, and groupFilesInBlocks::temp.

125  {
126  //----- Check that selected volumes are indeed part of the geometry
127  // Numbering From DDD
128  if (fromdd4hep_) {
129  const cms::DDCompactView cpv = es.getData(cpvTokenDD4hep_);
130  constexpr int32_t addLevel = 1;
131  std::string attribute = "ReadOutName";
132  std::string value = "HcalHits";
133  const cms::DDFilter filter1(attribute, value);
134  cms::DDFilteredView fv1(cpv, filter1);
135  std::vector<std::string> names = getNames(fv1);
136  for (auto& name : names) {
137  std::string namx = (name.find('_') == std::string::npos) ? name : name.substr(0, name.find('_'));
138  if (std::find(sensitives_.begin(), sensitives_.end(), namx) == sensitives_.end())
139  sensitives_.emplace_back(namx);
140  }
141  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
142  << " = " << value << " has " << sensitives_.size() << " elements";
143  for (unsigned int i = 0; i < sensitives_.size(); i++)
144  edm::LogVerbatim("MaterialBudgetFull")
145  << "MaterialBudgetHcalProducer: sensitives[" << i << "] = " << sensitives_[i];
146  attribute = "Volume";
147  value = "HF";
148  const cms::DDFilter filter2(attribute, value);
149  cms::DDFilteredView fv2(cpv, filter2);
150  std::vector<int> temp = fv2.get<std::vector<int> >("hf", "Levels");
151  hfNames_ = getNames(fv2);
152  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
153  << " = " << value << " has " << hfNames_.size() << " elements";
154  for (unsigned int i = 0; i < hfNames_.size(); i++) {
155  hfLevels_.push_back(temp[i] + addLevel);
156  edm::LogVerbatim("MaterialBudgetFull")
157  << "MaterialBudgetHcalProducer: HF[" << i << "] = " << hfNames_[i] << " at level " << hfLevels_[i];
158  }
159 
160  const std::string ecalRO[2] = {"EcalHitsEB", "EcalHitsEE"};
161  attribute = "ReadOutName";
162  for (int k = 0; k < 2; k++) {
163  value = ecalRO[k];
164  const cms::DDFilter filter(attribute, value);
165  cms::DDFilteredView fv(cpv, filter);
166  std::vector<std::string> senstmp = getNames(fv);
167  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
168  << " = " << value << " has " << senstmp.size() << " elements";
169  for (unsigned int i = 0; i < senstmp.size(); i++) {
170  std::string name = senstmp[i].substr(0, 4);
171  if (std::find(sensitiveEC_.begin(), sensitiveEC_.end(), name) == sensitiveEC_.end())
172  sensitiveEC_.push_back(name);
173  }
174  }
175  for (unsigned int i = 0; i < sensitiveEC_.size(); i++)
176  edm::LogVerbatim("MaterialBudgetFull")
177  << "MaterialBudgetHcalProducer:sensitiveEC[" << i << "] = " << sensitiveEC_[i];
178  } else { // if not from dd4hep --> ddd
179  const DDCompactView& cpv = es.getData(cpvTokenDDD_);
180  constexpr int32_t addLevel = 0;
181  std::string attribute = "ReadOutName";
182  std::string value = "HcalHits";
183  DDSpecificsMatchesValueFilter filter1{DDValue(attribute, value, 0)};
184  DDFilteredView fv1(cpv, filter1);
185  std::vector<std::string> names = getNames(fv1);
186  for (auto& name : names) {
187  std::string namx = (name.find('_') == std::string::npos) ? name : name.substr(0, name.find('_'));
188  if (std::find(sensitives_.begin(), sensitives_.end(), namx) == sensitives_.end())
189  sensitives_.emplace_back(namx);
190  }
191  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
192  << " = " << value << " has " << sensitives_.size() << " elements";
193  for (unsigned int i = 0; i < sensitives_.size(); i++)
194  edm::LogVerbatim("MaterialBudgetFull")
195  << "MaterialBudgetHcalProducer: sensitives[" << i << "] = " << sensitives_[i];
196  attribute = "Volume";
197  value = "HF";
198  DDSpecificsMatchesValueFilter filter2{DDValue(attribute, value, 0)};
199  DDFilteredView fv2(cpv, filter2);
200  hfNames_ = getNames(fv2);
201  fv2.firstChild();
202  DDsvalues_type sv(fv2.mergedSpecifics());
203  std::vector<double> temp = getDDDArray("Levels", sv);
204  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
205  << " = " << value << " has " << hfNames_.size() << " elements";
206  for (unsigned int i = 0; i < hfNames_.size(); i++) {
207  int level = static_cast<int>(temp[i]);
208  hfLevels_.push_back(level + addLevel);
209  edm::LogVerbatim("MaterialBudgetFull")
210  << "MaterialBudgetHcalProducer: HF[" << i << "] = " << hfNames_[i] << " at level " << hfLevels_[i];
211  }
212 
213  const std::string ecalRO[2] = {"EcalHitsEB", "EcalHitsEE"};
214  attribute = "ReadOutName";
215  for (int k = 0; k < 2; k++) {
216  value = ecalRO[k];
217  DDSpecificsMatchesValueFilter filter3{DDValue(attribute, value, 0)};
218  DDFilteredView fv3(cpv, filter3);
219  std::vector<std::string> senstmp = getNames(fv3);
220  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Names to be tested for " << attribute
221  << " = " << value << " has " << senstmp.size() << " elements";
222  for (unsigned int i = 0; i < senstmp.size(); i++) {
223  std::string name = senstmp[i].substr(0, 4);
224  if (std::find(sensitiveEC_.begin(), sensitiveEC_.end(), name) == sensitiveEC_.end())
225  sensitiveEC_.push_back(name);
226  }
227  }
228  for (unsigned int i = 0; i < sensitiveEC_.size(); i++)
229  edm::LogVerbatim("MaterialBudgetFull")
230  << "MaterialBudgetHcalProducer:sensitiveEC[" << i << "] = " << sensitiveEC_[i];
231  }
232 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > sensitiveEC_
std::vector< std::string > hfNames_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvTokenDDD_
std::vector< double > getDDDArray(const std::string &str, const DDsvalues_type &sv)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokenDD4hep_
const std::string names[nVars_]
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
Definition: value.py:1
std::vector< std::string > sensitives_
std::vector< std::string > getNames(DDFilteredView &fv)

◆ getDDDArray()

std::vector< double > MaterialBudgetHcalProducer::getDDDArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 457 of file MaterialBudgetHcalProducer.cc.

References DDfetch(), Exception, str, pfDeepBoostedJetPreprocessParams_cfi::sv, and relativeConstraints::value.

457  {
458  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer:getDDDArray called for " << str;
459  DDValue value(str);
460  if (DDfetch(&sv, value)) {
461  edm::LogVerbatim("MaterialBudgetFull") << value;
462  const std::vector<double>& fvec = value.doubles();
463  int nval = fvec.size();
464  if (nval < 1) {
465  throw cms::Exception("MaterialBudgetHcalProducer") << "nval = " << nval << " < 1 for array " << str << "\n";
466  }
467 
468  return fvec;
469  } else {
470  throw cms::Exception("MaterialBudgetHcalProducer") << "cannot get array " << str << "\n";
471  }
472 }
Log< level::Info, true > LogVerbatim
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
Definition: value.py:1
#define str(s)

◆ getNames() [1/2]

std::vector< std::string > MaterialBudgetHcalProducer::getNames ( DDFilteredView fv)
private

Definition at line 428 of file MaterialBudgetHcalProducer.cc.

References spr::find(), DDFilteredView::firstChild(), dqm-mbProfile::log, DDFilteredView::logicalPart(), DDFilteredView::next(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

428  {
429  std::vector<std::string> tmp;
430  bool dodet = fv.firstChild();
431  while (dodet) {
432  const DDLogicalPart& log = fv.logicalPart();
433  std::string namx = log.name().name();
434  if (std::find(tmp.begin(), tmp.end(), namx) == tmp.end())
435  tmp.push_back(namx);
436  dodet = fv.next();
437  }
438  return tmp;
439 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
bool next()
set current node to the next node in the filtered tree
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
bool firstChild()
set the current node to the first child ...
tmp
align.sh
Definition: createJobs.py:716

◆ getNames() [2/2]

std::vector< std::string > MaterialBudgetHcalProducer::getNames ( cms::DDFilteredView fv)
private

Definition at line 441 of file MaterialBudgetHcalProducer.cc.

References spr::find(), cms::DDFilteredView::firstChild(), dqmiodumpmetadata::n, cms::DDFilteredView::name(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

441  {
442  std::vector<std::string> tmp;
443  const std::vector<std::string> notIn = {
444  "CALO", "HCal", "MBBTL", "MBBTR", "MBBTC", "MBAT", "MBBT_R1M", "MBBT_R1P", "MBBT_R1MX", "MBBT_R1PX", "VCAL"};
445  while (fv.firstChild()) {
446  const std::string n{fv.name().data(), fv.name().size()};
447  if (std::find(notIn.begin(), notIn.end(), n) == notIn.end()) {
448  std::string::size_type pos = n.find(':');
449  const std::string namx = (pos == std::string::npos) ? n : std::string(n, pos + 1, n.size() - 1);
450  if (std::find(tmp.begin(), tmp.end(), namx) == tmp.end())
451  tmp.push_back(namx);
452  }
453  }
454  return tmp;
455 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
uint16_t size_type
std::string_view name() const
bool firstChild()
set the current node to the first child
tmp
align.sh
Definition: createJobs.py:716

◆ isItEC()

bool MaterialBudgetHcalProducer::isItEC ( const std::string &  name)
private

Definition at line 499 of file MaterialBudgetHcalProducer.cc.

References Skims_PA_cff::name.

499  {
500  std::vector<std::string>::const_iterator it = sensitiveEC_.begin();
501  std::vector<std::string>::const_iterator itEnd = sensitiveEC_.end();
502  for (; it != itEnd; ++it)
503  if (name.substr(0, 4) == *it)
504  return true;
505  return false;
506 }
std::vector< std::string > sensitiveEC_

◆ isItHF()

bool MaterialBudgetHcalProducer::isItHF ( const G4VTouchable *  touch)
private

Definition at line 484 of file MaterialBudgetHcalProducer.cc.

References GCP_tree_cfg::levels, Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

484  {
485  int levels = ((touch->GetHistoryDepth()) + 1);
486  for (unsigned int it = 0; it < hfNames_.size(); it++) {
487  if (levels >= hfLevels_[it]) {
488  std::string name =
489  (static_cast<std::string>(dd4hep::dd::noNamespace(touch->GetVolume(levels - hfLevels_[it])->GetName())))
490  .substr(0, 4);
491  if (name == hfNames_[it]) {
492  return true;
493  }
494  }
495  }
496  return false;
497 }
std::vector< std::string > hfNames_

◆ isSensitive()

bool MaterialBudgetHcalProducer::isSensitive ( const std::string &  name)
private

Definition at line 474 of file MaterialBudgetHcalProducer.cc.

References Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

474  {
475  std::vector<std::string>::const_iterator it = sensitives_.begin();
476  std::vector<std::string>::const_iterator itEnd = sensitives_.end();
477  std::string namx = (name.find('_') == std::string::npos) ? name : name.substr(0, name.find('_'));
478  for (; it != itEnd; ++it)
479  if (namx == *it)
480  return true;
481  return false;
482 }
std::vector< std::string > sensitives_

◆ operator=()

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

◆ produce()

void MaterialBudgetHcalProducer::produce ( edm::Event e,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 117 of file MaterialBudgetHcalProducer.cc.

References MillePedeFileConverter_cfg::e, caloTruthProducer_cfi::hgc, and eostools::move().

117  {
118  std::unique_ptr<MaterialAccountingCaloCollection> hgc(new MaterialAccountingCaloCollection);
119  for (auto const& mbc : matcoll_) {
120  hgc->emplace_back(mbc);
121  }
122  e.put(std::move(hgc), Form("%sMatBCalo", name_.c_str()));
123 }
std::vector< MaterialAccountingCalo > MaterialAccountingCaloCollection
MaterialAccountingCaloCollection matcoll_
def move(src, dest)
Definition: eostools.py:511

◆ registerConsumes()

void MaterialBudgetHcalProducer::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 109 of file MaterialBudgetHcalProducer.cc.

References edm::BeginRun, and gpuPixelDoublets::cc.

109  {
110  if (fromdd4hep_)
112  else
113  cpvTokenDDD_ = cc.esConsumes<edm::Transition::BeginRun>();
114  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalProducer: Initialize the token for CompactView";
115 }
Log< level::Info, true > LogVerbatim
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvTokenDDD_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > cpvTokenDD4hep_

◆ stopAfter()

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

Definition at line 415 of file MaterialBudgetHcalProducer.cc.

References funct::abs(), findQualityFiles::rr, and geometryCSVtoXML::zz.

415  {
416  G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
417  double rr = hitPoint.perp();
418  double zz = std::abs(hitPoint.z());
419 
420  if (rr > rMax_ || zz > zMax_) {
421  edm::LogVerbatim("MaterialBudget") << " MaterialBudgetHcalProducer::StopAfter R = " << rr << " and Z = " << zz;
422  return true;
423  } else {
424  return false;
425  }
426 }
Log< level::Info, true > LogVerbatim
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ update() [1/4]

void MaterialBudgetHcalProducer::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent *>.

Definition at line 234 of file MaterialBudgetHcalProducer.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

234 { matcoll_.clear(); }
MaterialAccountingCaloCollection matcoll_

◆ update() [2/4]

void MaterialBudgetHcalProducer::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack *>.

Definition at line 236 of file MaterialBudgetHcalProducer.cc.

References DeadROC_duringRun::dir, mps_fire::i, and sistrip::layer_.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

236  {
237  const G4Track* aTrack = (*trk)(); // recover G4 pointer if wanted
238 
239  id_ = layer_ = steps_ = 0;
240  radLen_ = intLen_ = stepLen_ = 0;
241  nlayHB_ = nlayHE_ = nlayHF_ = nlayHO_ = 0;
242  for (int i = 0; i < maxSet_; ++i)
243  stepLens_[i] = radLens_[i] = intLens_[i] = 0;
244 
245  const G4ThreeVector& dir = aTrack->GetMomentum();
246  if (dir.theta() != 0) {
247  eta_ = dir.eta();
248  } else {
249  eta_ = -99;
250  }
251  phi_ = dir.phi();
252  edm::LogVerbatim("MaterialBudget") << "Start track with (eta, phi) = (" << eta_ << ", " << phi_ << " Energy "
253  << aTrack->GetTotalEnergy() << " and ID "
254  << (aTrack->GetDefinition()->GetPDGEncoding());
255 
256  if (printSum_) {
257  matList_.clear();
258  stepLength_.clear();
259  radLength_.clear();
260  intLength_.clear();
261  }
262 }
Log< level::Info, true > LogVerbatim
std::vector< std::string > matList_

◆ update() [3/4]

void MaterialBudgetHcalProducer::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 264 of file MaterialBudgetHcalProducer.cc.

References funct::abs(), angle_units::operators::convertRadToDeg(), geant_units::operators::convertUnitsTo(), fastSimProducer_cff::density, newFWLiteAna::found, cuy::ii, sistrip::layer_, Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and HLT_2023v12_cff::track.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

264  {
265  //---------- each step
266  G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
267  double step = aStep->GetStepLength();
268  double radl = material->GetRadlen();
269  double intl = material->GetNuclearInterLength();
270  double density = convertUnitsTo(1._g_per_cm3, material->GetDensity());
271 
272  int idOld = id_;
273  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
274  std::string name = (static_cast<std::string>(dd4hep::dd::noNamespace(touch->GetVolume(0)->GetName())));
275  std::string matName = (static_cast<std::string>(dd4hep::dd::noNamespace(material->GetName())));
276  if (printSum_) {
277  bool found = false;
278  for (unsigned int ii = 0; ii < matList_.size(); ii++) {
279  if (matList_[ii] == matName) {
280  stepLength_[ii] += step;
281  radLength_[ii] += (step / radl);
282  intLength_[ii] += (step / intl);
283  found = true;
284  break;
285  }
286  }
287  if (!found) {
288  matList_.push_back(matName);
289  stepLength_.push_back(step);
290  radLength_.push_back(step / radl);
291  intLength_.push_back(step / intl);
292  }
293  if ((std::abs(eta_) >= etaMinP_) && (std::abs(eta_) <= etaMaxP_))
294  edm::LogVerbatim("MaterialBudget") << "Volume " << name << " id " << id_ << ":" << idOld << " Step " << step
295  << " Material " << matName << " Old Length " << stepLen_ << " X0 "
296  << step / radl << ":" << radLen_ << " Lambda " << step / intl << ":"
297  << intLen_;
298  } else {
299  if ((std::abs(eta_) >= etaMinP_) && (std::abs(eta_) <= etaMaxP_))
300  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalProducer: Step at " << name << " id " << id_ << ":"
301  << idOld << " Length " << step << " in " << matName << " of density "
302  << density << " g/cc; Radiation Length " << radl << " mm; Interaction Length "
303  << intl << " mm\n Position "
304  << aStep->GetPreStepPoint()->GetPosition() << " Cylindrical R "
305  << aStep->GetPreStepPoint()->GetPosition().perp() << " Length (so far) "
306  << stepLen_ << " L/X0 " << step / radl << "/" << radLen_ << " L/Lambda "
307  << step / intl << "/" << intLen_;
308  }
309 
310  int det = 0, lay = 0;
311  double abseta = std::abs(eta_);
312  edm::LogVerbatim("MaterialBudgetFull") << "Volume " << name << ":" << matName << " EC:Sensitive:HF " << isItEC(name)
313  << ":" << isSensitive(name) << ":" << isItHF(touch) << " Eta " << abseta
314  << " HC " << ((touch->GetReplicaNumber(1)) / 1000) << ":"
315  << ((touch->GetReplicaNumber(0) / 10) % 100 + 3) << " X0 "
316  << (radLen_ + (step / radl)) << " Lambda " << (intLen_ + (step / intl));
317 
318  if (isItEC(name)) {
319  det = 1;
320  lay = 1;
321  } else {
322  if (isSensitive(name)) {
323  if (isItHF(touch)) {
324  det = 5;
325  lay = 21;
326  if (lay != layer_)
327  ++nlayHF_;
328  } else {
329  det = (touch->GetReplicaNumber(1)) / 1000;
330  lay = (touch->GetReplicaNumber(0) / 10) % 100 + 3;
331  if (det == 4) {
332  if (abseta < 1.479)
333  lay = layer_ + 1;
334  else
335  lay--;
336  if (lay < 3)
337  lay = 3;
338  if (lay == layer_)
339  lay++;
340  if (lay > 20)
341  lay = 20;
342  if (lay != layer_)
343  ++nlayHE_;
344  } else if (lay != layer_) {
345  if (lay >= 20)
346  ++nlayHO_;
347  else
348  ++nlayHB_;
349  }
350  }
351  edm::LogVerbatim("MaterialBudgetFull") << "MaterialBudgetHcalProducer: Det " << det << " Layer " << lay << " Eta "
352  << eta_ << " Phi " << convertRadToDeg(phi_);
353  } else if (layer_ == 1) {
354  det = -1;
355  lay = 2;
356  }
357  }
358  if (det != 0) {
359  if (lay != layer_) {
360  id_ = lay;
361  layer_ = lay;
362  }
363  }
364 
365  if (id_ > idOld) {
366  if ((abseta >= etaMinP_) && (abseta <= etaMaxP_))
367  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalProducer: Step at " << name << " calls filHisto with "
368  << (id_ - 1);
369  stepLens_[id_ - 1] = stepLen_;
370  radLens_[id_ - 1] = radLen_;
371  intLens_[id_ - 1] = intLen_;
372  }
373 
374  stepLen_ += step;
375  radLen_ += (step / radl);
376  intLen_ += (step / intl);
377  if (id_ == 21) {
378  if (!isItHF(aStep->GetPostStepPoint()->GetTouchable())) {
379  if ((abseta >= etaMinP_) && (abseta <= etaMaxP_))
380  edm::LogVerbatim("MaterialBudget") << "MaterialBudgetHcalProducer: After HF in " << name << ":"
381  << static_cast<std::string>(dd4hep::dd::noNamespace(
382  aStep->GetPostStepPoint()->GetTouchable()->GetVolume(0)->GetName()))
383  << " calls fillHisto with " << id_;
384  stepLens_[idOld] = stepLen_;
385  radLens_[idOld] = radLen_;
386  intLens_[idOld] = intLen_;
387  ++id_;
388  layer_ = 0;
389  }
390  }
391 
392  //----- Stop tracking after selected position
393  if (stopAfter(aStep)) {
394  G4Track* track = aStep->GetTrack();
395  track->SetTrackStatus(fStopAndKill);
396  }
397 }
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
bool isSensitive(const std::string &)
constexpr NumType convertUnitsTo(double desiredUnits, NumType val)
Definition: GeantUnits.h:73
bool isItHF(const G4VTouchable *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ii
Definition: cuy.py:589
std::vector< std::string > matList_
step
Definition: StallMonitor.cc:83

◆ update() [4/4]

void MaterialBudgetHcalProducer::update ( const EndOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack *>.

Definition at line 399 of file MaterialBudgetHcalProducer.cc.

References dqmdumpme::k, MaterialAccountingCalo::m_eta, MaterialAccountingCalo::m_intLen, MaterialAccountingCalo::m_layers, MaterialAccountingCalo::m_phi, MaterialAccountingCalo::m_radLen, and MaterialAccountingCalo::m_stepLen.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

399  {
400  MaterialAccountingCalo matCalo;
401  matCalo.m_eta = eta_;
402  matCalo.m_phi = phi_;
403  for (int k = 0; k < maxSet_; ++k) {
404  matCalo.m_stepLen.emplace_back(stepLens_[k]);
405  matCalo.m_radLen.emplace_back(radLens_[k]);
406  matCalo.m_intLen.emplace_back(intLens_[k]);
407  }
408  matCalo.m_layers.emplace_back(nlayHB_);
409  matCalo.m_layers.emplace_back(nlayHE_);
410  matCalo.m_layers.emplace_back(nlayHO_);
411  matCalo.m_layers.emplace_back(nlayHF_);
412  matcoll_.emplace_back(matCalo);
413 }
std::vector< double > m_radLen
MaterialAccountingCaloCollection matcoll_
std::vector< double > m_intLen
std::vector< double > m_stepLen

Member Data Documentation

◆ cpvTokenDD4hep_

edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> MaterialBudgetHcalProducer::cpvTokenDD4hep_
private

Definition at line 79 of file MaterialBudgetHcalProducer.cc.

◆ cpvTokenDDD_

edm::ESGetToken<DDCompactView, IdealGeometryRecord> MaterialBudgetHcalProducer::cpvTokenDDD_
private

Definition at line 78 of file MaterialBudgetHcalProducer.cc.

◆ eta_

double MaterialBudgetHcalProducer::eta_
private

Definition at line 89 of file MaterialBudgetHcalProducer.cc.

◆ etaMaxP_

double MaterialBudgetHcalProducer::etaMaxP_
private

Definition at line 74 of file MaterialBudgetHcalProducer.cc.

◆ etaMinP_

double MaterialBudgetHcalProducer::etaMinP_
private

Definition at line 74 of file MaterialBudgetHcalProducer.cc.

◆ fromdd4hep_

bool MaterialBudgetHcalProducer::fromdd4hep_
private

Definition at line 75 of file MaterialBudgetHcalProducer.cc.

◆ hfLevels_

std::vector<int> MaterialBudgetHcalProducer::hfLevels_
private

Definition at line 82 of file MaterialBudgetHcalProducer.cc.

◆ hfNames_

std::vector<std::string> MaterialBudgetHcalProducer::hfNames_
private

Definition at line 81 of file MaterialBudgetHcalProducer.cc.

◆ id_

int MaterialBudgetHcalProducer::id_
private

Definition at line 87 of file MaterialBudgetHcalProducer.cc.

◆ intLen_

double MaterialBudgetHcalProducer::intLen_
private

Definition at line 88 of file MaterialBudgetHcalProducer.cc.

◆ intLength_

std::vector<double> MaterialBudgetHcalProducer::intLength_
private

Definition at line 86 of file MaterialBudgetHcalProducer.cc.

◆ intLens_

double MaterialBudgetHcalProducer::intLens_[maxSet_]
private

Definition at line 84 of file MaterialBudgetHcalProducer.cc.

◆ layer_

int MaterialBudgetHcalProducer::layer_
private

Definition at line 87 of file MaterialBudgetHcalProducer.cc.

◆ matcoll_

MaterialAccountingCaloCollection MaterialBudgetHcalProducer::matcoll_
private

Definition at line 83 of file MaterialBudgetHcalProducer.cc.

◆ matList_

std::vector<std::string> MaterialBudgetHcalProducer::matList_
private

Definition at line 85 of file MaterialBudgetHcalProducer.cc.

◆ maxSet2_

const int MaterialBudgetHcalProducer::maxSet2_ = 9
staticprivate

Definition at line 73 of file MaterialBudgetHcalProducer.cc.

◆ maxSet_

const int MaterialBudgetHcalProducer::maxSet_ = 25
staticprivate

Definition at line 73 of file MaterialBudgetHcalProducer.cc.

◆ name_

std::string MaterialBudgetHcalProducer::name_
private

Definition at line 76 of file MaterialBudgetHcalProducer.cc.

◆ nlayHB_

int MaterialBudgetHcalProducer::nlayHB_
private

Definition at line 90 of file MaterialBudgetHcalProducer.cc.

◆ nlayHE_

int MaterialBudgetHcalProducer::nlayHE_
private

Definition at line 90 of file MaterialBudgetHcalProducer.cc.

◆ nlayHF_

int MaterialBudgetHcalProducer::nlayHF_
private

Definition at line 90 of file MaterialBudgetHcalProducer.cc.

◆ nlayHO_

int MaterialBudgetHcalProducer::nlayHO_
private

Definition at line 90 of file MaterialBudgetHcalProducer.cc.

◆ phi_

double MaterialBudgetHcalProducer::phi_
private

Definition at line 89 of file MaterialBudgetHcalProducer.cc.

◆ printSum_

bool MaterialBudgetHcalProducer::printSum_
private

Definition at line 75 of file MaterialBudgetHcalProducer.cc.

◆ radLen_

double MaterialBudgetHcalProducer::radLen_
private

Definition at line 88 of file MaterialBudgetHcalProducer.cc.

◆ radLength_

std::vector<double> MaterialBudgetHcalProducer::radLength_
private

Definition at line 86 of file MaterialBudgetHcalProducer.cc.

◆ radLens_

double MaterialBudgetHcalProducer::radLens_[maxSet_]
private

Definition at line 84 of file MaterialBudgetHcalProducer.cc.

◆ rMax_

double MaterialBudgetHcalProducer::rMax_
private

Definition at line 74 of file MaterialBudgetHcalProducer.cc.

◆ sensitiveEC_

std::vector<std::string> MaterialBudgetHcalProducer::sensitiveEC_
private

Definition at line 81 of file MaterialBudgetHcalProducer.cc.

◆ sensitives_

std::vector<std::string> MaterialBudgetHcalProducer::sensitives_
private

Definition at line 81 of file MaterialBudgetHcalProducer.cc.

◆ stepLen_

double MaterialBudgetHcalProducer::stepLen_
private

Definition at line 88 of file MaterialBudgetHcalProducer.cc.

◆ stepLength_

std::vector<double> MaterialBudgetHcalProducer::stepLength_
private

Definition at line 86 of file MaterialBudgetHcalProducer.cc.

◆ stepLens_

double MaterialBudgetHcalProducer::stepLens_[maxSet_]
private

Definition at line 84 of file MaterialBudgetHcalProducer.cc.

◆ steps_

int MaterialBudgetHcalProducer::steps_
private

Definition at line 87 of file MaterialBudgetHcalProducer.cc.

◆ zMax_

double MaterialBudgetHcalProducer::zMax_
private

Definition at line 74 of file MaterialBudgetHcalProducer.cc.