CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
108  // std::cout<<" KONTROLA w RPCNumberingScheme: eta_id: "<<eta_id<<", plane_tag: "<<plane_tag<<", plane_id: "<<plane_id<<std::endl;
109  } else if (plane_tag == 4) {
110  // if(copyno == 1) {
111  // if(eta_id == 4 || eta_id == 8) {
112  // plane_id=2;
113  //} else {
114  plane_id = 6;
115  //}
116  // std::cout<<" KONTROLA w RPCNumberingScheme: eta_id: "<<eta_id<<", plane_tag: "<<plane_tag<<", plane_id: "<<plane_id<<std::endl;
117  } else if (plane_tag == 5) {
118  plane_id = 3;
119  } else {
120  plane_id = 4;
121  }
122 
123  } else if (level == theBChamberLevel) {
124  const int copyno = num.getBaseNo(level);
125  if ((plane_id == 4) && (sector_id == 4 * 3)) {
126  copy_id = sector_copy * 2 + copyno + 1;
127  } else if ((plane_id == 4) && (sector_id == 10 * 3)) {
128  copy_id = sector_copy + 1;
129  } else {
130  copy_id = copyno + 1;
131  }
132  const int rollno = num.getSuperNo(level);
133  roll_id = rollno;
134  }
135 
136  } else {
137  if (level == theRegionLevel) {
138  const int copyno = num.getBaseNo(level);
139  forward = (copyno == 0);
140  } else if (level == theEPlaneLevel) {
141  const int plane_tag = num.getSuperNo(level);
142  const int rr12_tag = num.getBaseNo(level);
143  plane_id = plane_tag;
144  rr12_id = rr12_tag;
145  } else if (level == theESectorLevel) {
146  const int copyno = num.getBaseNo(level);
147  sector_id = copyno + 1;
148  if (rr12_id == 1) {
149  sector_id = sector_id * 2 - 1;
150  } else if (rr12_id == 2) {
151  sector_id = sector_id * 2;
152  }
153  } else if (level == theERollLevel) {
154  const int copyno = num.getBaseNo(level);
155  const int eta_tag = num.getSuperNo(level);
156 
157  if ((eta_tag == 1) || (eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
158  eta_id = 1;
159  } else if ((eta_tag == 2) || (eta_tag == 5)) {
160  eta_id = 2;
161  } else if ((eta_tag == 3) || (eta_tag == 6)) {
162  eta_id = 3;
163  }
164 
165  if (forward)
166  eta_id = 12 - eta_id;
167 
168  // increase sector id for 20 degree chambers
169 
170  if ((eta_tag == 4) || (eta_tag == 7) || (eta_tag == 8)) {
171  sector_id *= 2;
172  }
173 
174  roll_id = copyno + 1;
175  }
176  }
177  }
178 
179  // collect all info
180 
181  int trIndex = (eta_id * 10000 + plane_id * 1000 + sector_id * 10 + copy_id) * 10 + roll_id;
182 
183 #ifdef EDM_ML_DEBUG
184  if (barrel_muon) {
185  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (barrel): ";
186  } else {
187  if (forward) {
188  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (forward): ";
189  } else {
190  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme (backward): ";
191  }
192  }
193  edm::LogVerbatim("MuonGeom") << " roll " << roll_id << " copy " << copy_id << " sector " << sector_id << " plane "
194  << plane_id << " eta " << eta_id << " rr12 " << rr12_id;
195 #endif
196 
197  // Build the actual numbering
198  RPCDetId id;
199  id.buildfromTrIndex(trIndex);
200 
201 #ifdef EDM_ML_DEBUG
202  edm::LogVerbatim("MuonGeom") << "RPCNumberingScheme:: DetId " << id;
203 #endif
204 
205  return id.rawId();
206 }
Log< level::Info, true > LogVerbatim
int getValue(const std::string &name) const
uint16_t *__restrict__ id
int getBaseNo(int level) const
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
void initMe(const MuonGeometryConstants &muonConstants)
RPCNumberingScheme(const MuonGeometryConstants &muonConstants)
int getLevels() const
int getSuperNo(int level) const
tuple level
Definition: testEve_cfg.py:47
Log< level::Warning, false > LogWarning