CMS 3D CMS Logo

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