CMS 3D CMS Logo

MuonOffsetFromDD.cc
Go to the documentation of this file.
8 #include <iostream>
9 #include <iomanip>
10 #include <sstream>
11 
12 //#define EDM_ML_DEBUG
13 
14 MuonOffsetFromDD::MuonOffsetFromDD(std::vector<std::string> name) : 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 }
23 
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();
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 }
48 
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 }
75 
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 }
87 
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 }
MuonOffsetFromDD::getNumber
int getNumber(const std::string &, const DDsvalues_type &)
Definition: MuonOffsetFromDD.cc:88
MuonOffsetFromDD::specpars_
const std::vector< std::string > specpars_
Definition: MuonOffsetFromDD.h:24
MuonOffsetMap.h
MuonOffsetFromDD.h
MuonOffsetFromDD::build
bool build(const DDCompactView *, MuonOffsetMap &)
Definition: MuonOffsetFromDD.cc:24
MuonOffsetFromDD::debugParameters
bool debugParameters(const MuonOffsetMap &)
Definition: MuonOffsetFromDD.cc:76
DDFilteredView::mergedSpecifics
DDsvalues_type mergedSpecifics() const
Definition: DDFilteredView.cc:42
DDFilteredView::logicalPart
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
Definition: DDFilteredView.cc:16
cms::DDFilteredView
Definition: DDFilteredView.h:70
MuonOffsetFromDD::nset_
const unsigned int nset_
Definition: MuonOffsetFromDD.h:25
MuonOffsetMap
Definition: MuonOffsetMap.h:9
cms::DDFilteredView::name
std::string_view name() const
Definition: DDFilteredView.cc:857
cms::DDFilteredView::get
T get(const std::string &)
extract attribute value
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDFilteredView.h
cms::DDFilter
Definition: DDFilteredView.h:59
DDFilteredView::next
bool next()
set current node to the next node in the filtered tree
Definition: DDFilteredView.cc:67
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
DDBase::name
const N & name() const
Definition: DDBase.h:59
str
#define str(s)
Definition: TestProcessor.cc:53
cms::DDFilteredView::firstChild
bool firstChild()
set the current node to the first child
Definition: DDFilteredView.cc:268
DDfetch
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:79
DDFilteredView.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
DDValue.h
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
DDutils.h
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
MuonOffsetFromDD::MuonOffsetFromDD
MuonOffsetFromDD(std::vector< std::string > names)
Definition: MuonOffsetFromDD.cc:14
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:60
DDFilter.h
value
Definition: value.py:1
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDValue
Definition: DDValue.h:22
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::DDCompactView
Definition: DDCompactView.h:31
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSpecificsMatchesValueFilter
Definition: DDFilter.h:70
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
unpackBuffers-CaloStage1.offsets
offsets
Definition: unpackBuffers-CaloStage1.py:127
DDFilteredView
Definition: DDFilteredView.h:20
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
MuonOffsetMap::muonMap_
std::unordered_map< std::string, std::pair< int, int > > muonMap_
Definition: MuonOffsetMap.h:14
DDsvalues_type
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
Definition: DDsvalues.h:12
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443