CMS 3D CMS Logo

MuonOffsetFromDD.cc
Go to the documentation of this file.
8 #include <iostream>
9 #include <iomanip>
10 
11 //#define EDM_ML_DEBUG
12 
13 MuonOffsetFromDD::MuonOffsetFromDD(std::vector<std::string> name) : specpars_(name), nset_(name.size()) {
14 #ifdef EDM_ML_DEBUG
15  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD initialized with " << nset_ << " specpars";
16 #endif
17 }
18 
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("MuonGeom") << "Inside MuonOffsetFromDD::build(const DDCompactView*, MuonOffsetMap&)";
22 #endif
23 
24  // Loop over all the sets
25  std::string attribute = "OnlyForMuonNumbering";
27  for (unsigned int k = 0; k < nset_; ++k) {
28  name = "muonstep" + std::to_string(k);
30  DDFilteredView fv(*cpv, filter);
31  bool dodet = fv.firstChild();
33  int offset = getNumber("CopyNoOffset", sv);
34  int tag = getNumber("CopyNoTag", sv);
35  while (dodet) {
36  name = fv.logicalPart().name().name();
37  php.muonMap_[name] = std::make_pair(offset, tag);
38  dodet = fv.next();
39  }
40  }
41  return this->debugParameters(php);
42 }
43 
45  edm::LogVerbatim("MuonGeom") << "Inside MuonOffsetFromDD::build(const cms::DDCompactView*, MuonOffsetMap&)";
46 
47  // Get the offsets and tags first
48  int offsets[nset_], tags[nset_];
49  cms::DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
50  for (unsigned int k = 0; k < nset_; ++k) {
51  std::vector<int> off = fv.get<std::vector<int>>(specpars_[k], "CopyNoOffset");
52  offsets[k] = (!off.empty()) ? off[0] : 0;
53  std::vector<int> tag = fv.get<std::vector<int>>(specpars_[k], "CopyNoTag");
54  tags[k] = (!tag.empty()) ? tag[0] : 0;
55  }
56  // Now loop over the detectors
57  std::string attribute = "OnlyForMuonNumbering";
59  for (unsigned int k = 0; k < nset_; ++k) {
60  name = "muonstep" + std::to_string(k);
61  const cms::DDFilter filter(attribute, name);
62  cms::DDFilteredView fv((*cpv), filter);
63  while (fv.firstChild()) {
64  name = static_cast<std::string>(fv.name());
65  php.muonMap_[name] = std::make_pair(offsets[k], tags[k]);
66  }
67  }
68  return this->debugParameters(php);
69 }
70 
72  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD: Finds " << php.muonMap_.size() << " entries in the map";
73 #ifdef EDM_ML_DEBUG
74  unsigned int k(0);
75  for (auto itr = php.muonMap_.begin(); itr != php.muonMap_.end(); ++itr, ++k) {
76  edm::LogVerbatim("MuonGeom") << "[" << k << "] " << itr->first << ": (" << (itr->second).first << ", "
77  << (itr->second).second << ")";
78  }
79 #endif
80  return true;
81 }
82 
84 #ifdef EDM_ML_DEBUG
85  edm::LogVerbatim("MuonGeom") << "MuonOffsetFromDD::getNumbers called for " << str;
86 #endif
87  DDValue value(str);
88  if (DDfetch(&sv, value)) {
89  const std::vector<double>& fvec = value.doubles();
90  int nval = (!fvec.empty()) ? static_cast<int>(fvec[0]) : 0;
91  return nval;
92  } else {
93  return 0;
94  }
95 }
MuonOffsetFromDD::getNumber
int getNumber(const std::string &, const DDsvalues_type &)
Definition: MuonOffsetFromDD.cc:83
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:19
MuonOffsetFromDD::debugParameters
bool debugParameters(const MuonOffsetMap &)
Definition: MuonOffsetFromDD.cc:71
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:854
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
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
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:52
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:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDutils.h
MuonOffsetFromDD::MuonOffsetFromDD
MuonOffsetFromDD(std::vector< std::string > names)
Definition: MuonOffsetFromDD.cc:13
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:48
DDFilter.h
value
Definition: value.py:1
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDValue
Definition: DDValue.h:21
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