CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonOffsetFromDD Class Reference

#include <MuonOffsetFromDD.h>

Public Member Functions

bool build (const DDCompactView *, MuonOffsetMap &)
 
bool build (const cms::DDCompactView *, MuonOffsetMap &)
 
 MuonOffsetFromDD (std::vector< std::string > names)
 

Private Member Functions

bool debugParameters (const MuonOffsetMap &)
 
int getNumber (const std::string &, const DDsvalues_type &)
 

Private Attributes

const unsigned int nset_
 
const std::vector< std::string > specpars_
 

Detailed Description

Definition at line 14 of file MuonOffsetFromDD.h.

Constructor & Destructor Documentation

◆ MuonOffsetFromDD()

MuonOffsetFromDD::MuonOffsetFromDD ( std::vector< std::string >  names)

Definition at line 14 of file MuonOffsetFromDD.cc.

References Skims_PA_cff::name, nset_, and specpars_.

14  : specpars_(name), nset_(name.size()) {
15 #ifdef EDM_ML_DEBUG
16  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD initialized with " << nset_ << " specpars";
17  std::ostringstream st1;
18  for (const auto& name : specpars_)
19  st1 << " " << name;
20  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD::SpecPars:" << st1.str();
21 #endif
22 }
Log< level::Info, true > LogVerbatim
const unsigned int nset_
const std::vector< std::string > specpars_

Member Function Documentation

◆ build() [1/2]

bool MuonOffsetFromDD::build ( const DDCompactView cpv,
MuonOffsetMap php 
)

Definition at line 24 of file MuonOffsetFromDD.cc.

References debugParameters(), ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), getNumber(), dqmdumpme::k, DDFilteredView::logicalPart(), DDFilteredView::mergedSpecifics(), MuonOffsetMap::muonMap_, Skims_PA_cff::name, DDName::name(), DDBase< N, C >::name(), DDFilteredView::next(), nset_, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, makeGlobalPositionRcd_cfg::tag, and to_string().

24  {
25 #ifdef EDM_ML_DEBUG
26  edm::LogVerbatim("MuonGeom") << "Inside MuonOffsetFromDD::build(const DDCompactView*, MuonOffsetMap&)";
27 #endif
28 
29  // Loop over all the sets
30  std::string attribute = "OnlyForMuonNumbering";
32  for (unsigned int k = 0; k < nset_; ++k) {
33  name = "muonstep" + std::to_string(k);
35  DDFilteredView fv(*cpv, filter);
36  bool dodet = fv.firstChild();
37  DDsvalues_type sv(fv.mergedSpecifics());
38  int offset = getNumber("CopyNoOffset", sv);
39  int tag = getNumber("CopyNoTag", sv);
40  while (dodet) {
41  name = fv.logicalPart().name().name();
42  php.muonMap_[name] = std::make_pair(offset, tag);
43  dodet = fv.next();
44  }
45  }
46  return this->debugParameters(php);
47 }
Log< level::Info, true > LogVerbatim
static std::string to_string(const XMLCh *ch)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
const unsigned int nset_
bool debugParameters(const MuonOffsetMap &)
int getNumber(const std::string &, const DDsvalues_type &)
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14

◆ build() [2/2]

bool MuonOffsetFromDD::build ( const cms::DDCompactView cpv,
MuonOffsetMap php 
)

Definition at line 49 of file MuonOffsetFromDD.cc.

References debugParameters(), cms::DDCompactView::detector(), ALCARECOTkAlBeamHalo_cff::filter, cms::DDFilteredView::firstChild(), cms::DDFilteredView::get(), dqmdumpme::k, MuonOffsetMap::muonMap_, Skims_PA_cff::name, cms::DDFilteredView::name(), nset_, unpackBuffers-CaloStage1::offsets, specpars_, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, triggerMatcherToHLTDebug_cfi::tags, to_string(), and cms::DDDetector::worldVolume().

49  {
50  edm::LogVerbatim("MuonGeom") << "Inside MuonOffsetFromDD::build(const cms::DDCompactView*, MuonOffsetMap&)";
51 
52  // Get the offsets and tags first
53  int offsets[nset_], tags[nset_];
54  cms::DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
55  for (unsigned int k = 0; k < nset_; ++k) {
56  std::vector<int> off = fv.get<std::vector<int>>(specpars_[k], "CopyNoOffset");
57  offsets[k] = (!off.empty()) ? off[0] : 0;
58  std::vector<int> tag = fv.get<std::vector<int>>(specpars_[k], "CopyNoTag");
59  tags[k] = (!tag.empty()) ? tag[0] : 0;
60  }
61  // Now loop over the detectors
62  std::string attribute = "OnlyForMuonNumbering";
64  for (unsigned int k = 0; k < nset_; ++k) {
65  name = "muonstep" + std::to_string(k);
66  const cms::DDFilter filter(attribute, name);
67  cms::DDFilteredView fv((*cpv), filter);
68  while (fv.firstChild()) {
69  name = static_cast<std::string>(fv.name());
70  php.muonMap_[name] = std::make_pair(offsets[k], tags[k]);
71  }
72  }
73  return this->debugParameters(php);
74 }
Log< level::Info, true > LogVerbatim
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
static std::string to_string(const XMLCh *ch)
const unsigned int nset_
T get(const std::string &)
extract attribute value
const std::vector< std::string > specpars_
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:67
bool debugParameters(const MuonOffsetMap &)
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14

◆ debugParameters()

bool MuonOffsetFromDD::debugParameters ( const MuonOffsetMap php)
private

Definition at line 76 of file MuonOffsetFromDD.cc.

References dqmdumpme::first, dqmdumpme::k, and MuonOffsetMap::muonMap_.

Referenced by build().

76  {
77  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD: Finds " << php.muonMap_.size() << " entries in the map";
78 #ifdef EDM_ML_DEBUG
79  unsigned int k(0);
80  for (auto itr = php.muonMap_.begin(); itr != php.muonMap_.end(); ++itr, ++k) {
81  edm::LogVerbatim("MuonGeom") << "[" << k << "] " << itr->first << ": (" << (itr->second).first << ", "
82  << (itr->second).second << ")";
83  }
84 #endif
85  return true;
86 }
Log< level::Info, true > LogVerbatim
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14

◆ getNumber()

int MuonOffsetFromDD::getNumber ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 88 of file MuonOffsetFromDD.cc.

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

Referenced by build().

88  {
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD::getNumbers called for " << str;
91 #endif
92  DDValue value(str);
93  if (DDfetch(&sv, value)) {
94  const std::vector<double>& fvec = value.doubles();
95  int nval = (!fvec.empty()) ? static_cast<int>(fvec[0]) : 0;
96  return nval;
97  } else {
98  return 0;
99  }
100 }
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)

Member Data Documentation

◆ nset_

const unsigned int MuonOffsetFromDD::nset_
private

Definition at line 25 of file MuonOffsetFromDD.h.

Referenced by build(), and MuonOffsetFromDD().

◆ specpars_

const std::vector<std::string> MuonOffsetFromDD::specpars_
private

Definition at line 24 of file MuonOffsetFromDD.h.

Referenced by build(), and MuonOffsetFromDD().