CMS 3D CMS Logo

DD4hep_DTNumberingScheme.cc
Go to the documentation of this file.
5 #include <cassert>
6 
7 using namespace cms;
8 
9 DTNumberingScheme::DTNumberingScheme(const MuonConstants& muonConstants) { initMe(muonConstants); }
10 
11 void DTNumberingScheme::initMe(const MuonConstants& muonConstants) {
12  int levelPart = get("level", muonConstants);
13  assert(levelPart != 0);
14  theRegionLevel = get("mb_region", muonConstants) / levelPart;
15  theWheelLevel = get("mb_wheel", muonConstants) / levelPart;
16  theStationLevel = get("mb_station", muonConstants) / levelPart;
17  theSuperLayerLevel = get("mb_superlayer", muonConstants) / levelPart;
18  theLayerLevel = get("mb_layer", muonConstants) / levelPart;
19  theWireLevel = get("mb_wire", muonConstants) / levelPart;
20 }
21 
23  int wire_id(0);
24  int layer_id(0);
25  int superlayer_id(0);
26  int sector_id(0);
27  int station_id(0);
28  int wheel_id(0);
29 
30  //decode significant barrel levels
31  decode(num, wire_id, layer_id, superlayer_id, sector_id, station_id, wheel_id);
32 
33  DTWireId id(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id);
34 
35  return id.rawId();
36 }
37 
39  int& wire_id,
40  int& layer_id,
41  int& superlayer_id,
42  int& sector_id,
43  int& station_id,
44  int& wheel_id) const {
45  for (int level = 1; level <= num.getLevels(); ++level) {
46  //decode
47  if (level == theWheelLevel) {
48  const int copyno = num.getBaseNo(level);
49  wheel_id = copyno - 2;
50 
51  } else if (level == theStationLevel) {
52  const int station_tag = num.getSuperNo(level);
53  const int copyno = num.getBaseNo(level);
54  station_id = station_tag;
55  sector_id = copyno + 1;
56  } else if (level == theSuperLayerLevel) {
57  const int copyno = num.getBaseNo(level);
58  superlayer_id = copyno + 1;
59  } else if (level == theLayerLevel) {
60  const int copyno = num.getBaseNo(level);
61  layer_id = copyno + 1;
62  } else if (level == theWireLevel) {
63  const int copyno = num.getBaseNo(level);
64  wire_id = copyno + 1;
65  }
66  }
67 }
68 
69 const int DTNumberingScheme::get(const char* key, const MuonConstants& muonConstants) const {
70  int result(0);
71  auto const& it = muonConstants.find(key);
72  if (it != end(muonConstants))
73  result = it->second;
74  return result;
75 }
int getBaseNo(int level) const
std::unordered_map< std::string_view, int > MuonConstants
DTNumberingScheme(const MuonConstants &)
void initMe(const MuonConstants &)
#define end
Definition: vmac.h:39
Namespace of DDCMS conversion namespace.
const int get(const char *, const MuonConstants &) const
void decode(const MuonBaseNumber &num, int &wire_id, int &layer_id, int &superlayer_id, int &sector_id, int &station_id, int &wheel_id) const
int getLevels() const
int getSuperNo(int level) const
int getDetId(const MuonBaseNumber &) const