CMS 3D CMS Logo

RPCNumberingScheme.cc
Go to the documentation of this file.
6 
7 //#define EDM_ML_DEBUG
8 
9 RPCNumberingScheme::RPCNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
10 
12  int theLevelPart = muonConstants.getValue("level");
13  theRegionLevel = muonConstants.getValue("mr_region") / theLevelPart;
14  theBWheelLevel = muonConstants.getValue("mr_bwheel") / theLevelPart;
15  theBStationLevel = muonConstants.getValue("mr_bstation") / theLevelPart;
16  theBPlaneLevel = muonConstants.getValue("mr_bplane") / theLevelPart;
17  theBChamberLevel = muonConstants.getValue("mr_bchamber") / theLevelPart;
18  theEPlaneLevel = muonConstants.getValue("mr_eplane") / theLevelPart;
19  theESectorLevel = muonConstants.getValue("mr_esector") / theLevelPart;
20  theERollLevel = muonConstants.getValue("mr_eroll") / theLevelPart;
21 #ifdef EDM_ML_DEBUG
22  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme::theRegionLevel " << theRegionLevel << "\ntheBWheelLevel "
23  << theBWheelLevel << "\ntheBStationLevel " << theBStationLevel << "\ntheBPlaneLevel "
24  << theBPlaneLevel << "\ntheBChamberLevel " << theBChamberLevel << "\ntheEPlaneLevel "
25  << theEPlaneLevel << "\ntheESectorLevel " << theESectorLevel << "\ntheERollLevel "
26  << theERollLevel;
27 #endif
28 }
29 
31 #ifdef EDM_ML_DEBUG
32  edm::LogVerbatim("MuonGeom") << "RPCNumbering " << num.getLevels();
33  for (int level = 1; level <= num.getLevels(); level++) {
34  edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
35  }
36 #endif
37 
38  const int barrel = num.getSuperNo(theRegionLevel);
39  bool barrel_muon = (barrel == 1);
40  int maxLevel;
41  if (barrel_muon) {
42  maxLevel = theBChamberLevel;
43  } else {
44  maxLevel = theERollLevel;
45  }
46 
47  if (num.getLevels() != maxLevel) {
48  edm::LogWarning("MuonGeom") << "RPCNumberingScheme::BNToUN: BaseNumber has " << num.getLevels() << " levels, need "
49  << maxLevel;
50  return 0;
51  }
52 
53  int plane_id = 0;
54  int sector_id = 0;
55  int copy_id = 0;
56  int roll_id = 0;
57  int eta_id = 0;
58  int rr12_id = 0;
59  bool forward = false;
60 
61  int sector_copy = 0;
62 
63  //decode significant rpc levels
64 
65  for (int level = 1; level <= maxLevel; level++) {
66  //decode
67  if (level == theRegionLevel) {
68  if (barrel_muon) {
69  roll_id = 0;
70  } else {
71  copy_id = 1;
72  }
73  }
74  if (barrel_muon) {
75  if (level == theBWheelLevel) {
76  const int copyno = num.getBaseNo(level);
77  eta_id = 4 + copyno; //copyno= [0,4]
78  } else if (level == theBStationLevel) {
79  //- const int station_tag = num.getSuperNo(level);
80  const int copyno = num.getBaseNo(level);
81 
82  sector_id = copyno + 1;
83  if (sector_id == 13) {
84  sector_id = 4;
85  sector_copy = 1;
86  } else if (sector_id == 14) {
87  sector_id = 10;
88  sector_copy = 1;
89  }
90  // mltiply by 3 to merge with endcaps
91  sector_id *= 3;
92 
93  } else if (level == theBPlaneLevel) {
94  const int plane_tag = num.getSuperNo(level);
95  // const int copyno = num.getBaseNo(level);
96  if (plane_tag == 1) {
97  plane_id = 1;
98  } else if (plane_tag == 2) {
99  plane_id = 5;
100  } else if (plane_tag == 3) {
101  // if(copyno == 1) {
102  //if(eta_id == 4 || eta_id == 8) {
103  // plane_id=6;
104 
105  plane_id = 2;
106  // }
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("MuonNumbering") << " KONTROLA w RPCNumberingScheme: eta_id: " << eta_id
109  << ", plane_tag: " << plane_tag << ", plane_id: " << plane_id;
110 #endif
111  } else if (plane_tag == 4) {
112  // if(copyno == 1) {
113  // if(eta_id == 4 || eta_id == 8) {
114  // plane_id=2;
115  //} else {
116  plane_id = 6;
117  //}
118 #ifdef EDM_ML_DEBUG
119  edm::LogVerbatim("MuonNumbering") << " KONTROLA w RPCNumberingScheme: eta_id: " << eta_id
120  << ", plane_tag: " << plane_tag << ", plane_id: " << plane_id;
121 #endif
122  } else if (plane_tag == 5) {
123  plane_id = 3;
124  } else {
125  plane_id = 4;
126  }
127 
128  } else if (level == theBChamberLevel) {
129  const int copyno = num.getBaseNo(level);
130  if ((plane_id == 4) && (sector_id == 4 * 3)) {
131  copy_id = sector_copy * 2 + copyno + 1;
132  } else if ((plane_id == 4) && (sector_id == 10 * 3)) {
133  copy_id = sector_copy + 1;
134  } else {
135  copy_id = copyno + 1;
136  }
137  const int rollno = num.getSuperNo(level);
138  roll_id = rollno;
139  }
140 
141  } else {
142  if (level == theRegionLevel) {
143  const int copyno = num.getBaseNo(level);
144  forward = (copyno == 0);
145  } else if (level == theEPlaneLevel) {
146  const int plane_tag = num.getSuperNo(level);
147  const int rr12_tag = num.getBaseNo(level);
148  plane_id = plane_tag;
149  rr12_id = rr12_tag;
150  } else if (level == theESectorLevel) {
151  const int copyno = num.getBaseNo(level);
152  sector_id = copyno + 1;
153  if (rr12_id == 1) {
154  sector_id = sector_id * 2 - 1;
155  } else if (rr12_id == 2) {
156  sector_id = sector_id * 2;
157  }
158  } else if (level == theERollLevel) {
159  const int copyno = num.getBaseNo(level);
160  const int eta_tag = num.getSuperNo(level);
161 
162  if ((eta_tag == 1) || (eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
163  eta_id = 1;
164  } else if ((eta_tag == 2) || (eta_tag == 5)) {
165  eta_id = 2;
166  } else if ((eta_tag == 3) || (eta_tag == 6)) {
167  eta_id = 3;
168  }
169 
170  if (forward)
171  eta_id = 12 - eta_id;
172 
173  // increase sector id for 20 degree chambers
174 
175  if ((eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
176  sector_id *= 2;
177  }
178 
179  roll_id = copyno + 1;
180  }
181  }
182  }
183 
184  // collect all info
185 
186  int trIndex = (eta_id * 10000 + plane_id * 1000 + sector_id * 10 + copy_id) * 10 + roll_id;
187 
188 #ifdef EDM_ML_DEBUG
189  if (barrel_muon) {
190  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (barrel): ";
191  } else {
192  if (forward) {
193  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (forward): ";
194  } else {
195  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (backward): ";
196  }
197  }
198  edm::LogVerbatim("MuonGeom") << " roll " << roll_id << " copy " << copy_id << " sector " << sector_id << " plane "
199  << plane_id << " eta " << eta_id << " rr12 " << rr12_id;
200 #endif
201 
202  // Build the actual numbering
203  RPCDetId id;
204  id.buildfromTrIndex(trIndex);
205 
206 #ifdef EDM_ML_DEBUG
207  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme:: DetId " << id;
208 #endif
209 
210  return id.rawId();
211 }
int getValue(const std::string &name) const
Log< level::Info, true > LogVerbatim
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
void initMe(const MuonGeometryConstants &muonConstants)
RPCNumberingScheme(const MuonGeometryConstants &muonConstants)
Log< level::Warning, false > LogWarning