CMS 3D CMS Logo

DD4hep_RPCNumberingScheme.cc
Go to the documentation of this file.
1 
7 #include <cassert>
8 
9 using namespace cms;
10 
11 RPCNumberingScheme::RPCNumberingScheme(const MuonConstants& muonConstants) { initMe(muonConstants); }
12 
13 void RPCNumberingScheme::initMe(const MuonConstants& muonConstants) {
14  int levelPart = get("level", muonConstants);
15 
16  assert(levelPart != 0);
17  theRegionLevel = get("mr_region", muonConstants) / levelPart;
18  theBWheelLevel = get("mr_bwheel", muonConstants) / levelPart;
19  theBStationLevel = get("mr_bstation", muonConstants) / levelPart;
20  theBPlaneLevel = get("mr_bplane", muonConstants) / levelPart;
21  theBChamberLevel = get("mr_bchamber", muonConstants) / levelPart;
22  theEPlaneLevel = get("mr_eplane", muonConstants) / levelPart;
23  theESectorLevel = get("mr_esector", muonConstants) / levelPart;
24  theERollLevel = get("mr_eroll", muonConstants) / levelPart;
25 }
26 
28  const int barrel = num.getSuperNo(theRegionLevel);
29 
30  bool barrel_muon = (barrel == 1);
31  int maxLevel;
32  if (barrel_muon) {
33  maxLevel = theBChamberLevel;
34  } else {
35  maxLevel = theERollLevel;
36  }
37  if (num.getLevels() != maxLevel) {
38  throw cms::Exception("DD4hep_RPCNumberingScheme", "num.getLevels() != maxLevel");
39  }
40 
41  int plane_id = 0;
42  int sector_id = 0;
43  int copy_id = 0;
44  int roll_id = 0;
45  int eta_id = 0;
46  int rr12_id = 0;
47  bool forward = false;
48  int sector_copy = 0;
49 
50  for (int level = 1; level <= maxLevel; level++) {
51  if (level == theRegionLevel) {
52  if (barrel_muon) {
53  roll_id = 0;
54  } else {
55  copy_id = 1;
56  }
57  }
58  if (barrel_muon) {
59  if (level == theBWheelLevel) {
60  const int copyno = num.getBaseNo(level);
61  eta_id = 4 + copyno;
62  } else if (level == theBStationLevel) {
63  const int copyno = num.getBaseNo(level);
64  sector_id = copyno + 1;
65  if (sector_id == 13) {
66  sector_id = 4;
67  sector_copy = 1;
68  } else if (sector_id == 14) {
69  sector_id = 10;
70  sector_copy = 1;
71  }
72  sector_id *= 3;
73  } else if (level == theBPlaneLevel) {
74  const int plane_tag = num.getSuperNo(level);
75  if (plane_tag == 1) {
76  plane_id = 1;
77  } else if (plane_tag == 2) {
78  plane_id = 5;
79  } else if (plane_tag == 3) {
80  plane_id = 2;
81  } else if (plane_tag == 4) {
82  plane_id = 6;
83  } else if (plane_tag == 5) {
84  plane_id = 3;
85  } else {
86  plane_id = 4;
87  }
88  } else if (level == theBChamberLevel) {
89  const int copyno = num.getBaseNo(level);
90  if ((plane_id == 4) && (sector_id == 4 * 3)) {
91  copy_id = sector_copy * 2 + copyno + 1;
92  } else if ((plane_id == 4) && (sector_id == 10 * 3)) {
93  copy_id = sector_copy + 1;
94  } else {
95  copy_id = copyno + 1;
96  }
97  const int rollno = num.getSuperNo(level);
98  roll_id = rollno;
99  }
100  } else {
101  if (level == theRegionLevel) {
102  const int copyno = num.getBaseNo(level);
103  forward = (copyno == 0);
104  } else if (level == theEPlaneLevel) {
105  const int plane_tag = num.getSuperNo(level);
106  const int rr12_tag = num.getBaseNo(level);
107  plane_id = plane_tag;
108  rr12_id = rr12_tag;
109  } else if (level == theESectorLevel) {
110  const int copyno = num.getBaseNo(level);
111  sector_id = copyno + 1;
112  if (rr12_id == 1) {
113  sector_id = sector_id * 2 - 1;
114  } else if (rr12_id == 2) {
115  sector_id = sector_id * 2;
116  }
117  } else if (level == theERollLevel) {
118  const int copyno = num.getBaseNo(level);
119  const int eta_tag = num.getSuperNo(level);
120  if ((eta_tag == 1) || (eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
121  eta_id = 1;
122  } else if ((eta_tag == 2) || (eta_tag == 5)) {
123  eta_id = 2;
124  } else if ((eta_tag == 3) || (eta_tag == 6)) {
125  eta_id = 3;
126  }
127  if (forward)
128  eta_id = 12 - eta_id;
129  if ((eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
130  sector_id *= 2;
131  }
132  roll_id = copyno + 1;
133  }
134  }
135  }
136  int trIndex = (eta_id * 10000 + plane_id * 1000 + sector_id * 10 + copy_id) * 10 + roll_id;
137  RPCDetId id;
138  id.buildfromTrIndex(trIndex);
139  setDetId(id.rawId());
140 }
141 
142 const int RPCNumberingScheme::get(const char* key, const MuonConstants& muonConstants) const {
143  int result(0);
144  auto const& it = (muonConstants.find(key));
145  if (it != end(muonConstants))
146  result = it->second;
147  return result;
148 }
RPCNumberingScheme(const MuonConstants &muonConstants)
int getBaseNo(int level) const
std::unordered_map< std::string_view, int > MuonConstants
void initMe(const MuonConstants &muonConstants)
#define end
Definition: vmac.h:39
Namespace of DDCMS conversion namespace.
int getLevels() const
int getSuperNo(int level) const
void baseNumberToUnitNumber(const MuonBaseNumber &)
const int get(const char *, const MuonConstants &) const