CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsTrackerDetIdBuilder.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 #include <fstream>
8 #include <sstream>
9 #include <string>
10 #include <bitset>
11 
12 CmsTrackerDetIdBuilder::CmsTrackerDetIdBuilder( unsigned int layerNumberPXB )
13  : m_layerNumberPXB( layerNumberPXB )
14 {}
15 
18 {
19  DetId t( DetId::Tracker, 0 );
20  tracker->setGeographicalID( t );
21  iterate( tracker, 0, tracker->geographicalID().rawId() );
22 
23  return tracker;
24 }
25 
26 void
28 {
29  std::bitset<32> binary_ID(ID);
30 
31  // SubDetector (useful to know fron now on, valid only after level 0, where SubDetector is assigned)
32  uint32_t mask = (7<<25);
33  uint32_t iSubDet = ID & mask;
34  iSubDet = iSubDet >> 25;
35  //
36 
37  switch( level )
38  {
39  // level 0
40  case 0:
41  {
42  for( uint32_t i = 0; i<(in)->components().size(); i++ )
43  {
44  GeometricDet* component = in->component(i);
45  uint32_t jSubDet = component->geographicalID().rawId();
46  uint32_t temp = ID;
47  temp |= (jSubDet<<25);
48  component->setGeographicalID(temp);
49 
50  switch( jSubDet )
51  {
52  // PXF
53  case 2:
54  {
55  // SubDetector Side start bit is 23 [3 unused and Side length is 2 bit]
56  if(component->translation().z()<0. )
57  {
58  temp |= (1<<23); // PXF-
59  }
60  else
61  {
62  temp |= (2<<23); // PXF+
63  }
64  break;
65  }
66  // TID
67  case 4:
68  {
69  temp|= (0<<15); // SubDetector Side start bit is 13 [10 unused and Side length is 2 bit]
70  if((component)->components()[0]->translation().z()<0. )
71  {
72  temp |= (1<<13); // TIDB = TID-
73  }
74  else
75  {
76  temp |= (2<<13); // TIDF = TID+
77  }
78  break;
79  }
80  // TEC
81  case 6:
82  {
83  temp |= (0<<20); // SubDetector Side start bit is 18 [5 unused and Side length is 2 bit]
84  if(component->translation().z()<0. )
85  {
86  temp |= (1<<18); // TEC-
87  }
88  else
89  {
90  temp |= (2<<18); // TEC+
91  }
92  break;
93  }
94  // PXB, TIB, TOB (barrel)
95  default:
96  {
97  // do nothing
98  }
99  // SubDetector switch ends
100  }
101 
102  component->setGeographicalID(DetId(temp));
103 
104  // next level
105  iterate(component,level+1,component->geographicalID().rawId());
106  }
107  break;
108  }
109  // level 1
110  case 1:
111  {
112  for( uint32_t i = 0; i < (in)->components().size(); i++ )
113  {
114  auto component = in->component(i);
115  uint32_t temp = ID;
116 
117  switch( iSubDet )
118  {
119  // PXB
120  case 1:
121  {
122  temp |= (component->geographicalID().rawId() << m_layerNumberPXB ); // Layer Number start bit is 16 [5 unused]
123  break;
124  }
125  // PXF
126  case 2:
127  {
128  temp |= (component->geographicalID().rawId() << 16 ); // Disk Number start bit is 16
129  break;
130  }
131  // TIB
132  case 3:
133  {
134  temp |= (component->geographicalID().rawId() << 14); // Layer Number start bit is 14 [8 unused]
135  break;
136  }
137 
138  // TID
139  case 4:
140  {
141  temp |= (component->geographicalID().rawId() << 11); // Disk (Wheel) Number start bit is 11
142  break;
143  }
144 
145  // TOB
146  case 5:
147  {
148  temp |= (component->geographicalID().rawId() << 14); // Layer Number start bit is 14 [8 unused]
149  break;
150  }
151 
152  // TEC
153  case 6:
154  {
155  temp |= (component->geographicalID().rawId() << 14); // Wheel Number start bit is 14
156  break;
157  }
158 
159  // the rest
160  default:
161  {
162  // do nothing
163  }
164 
165  // SubDetector switch ends
166  }
167 
168  component->setGeographicalID( temp );
169 
170  // next level
171  iterate(component,level+1,component->geographicalID().rawId());
172  }
173 
174  break;
175  }
176  // level 2
177  case 2: {
178 
179  for (uint32_t i=0;i<(in)->components().size();i++) {
180  auto component = in->component(i);
181 
182  switch (iSubDet) {
183 
184  // PXB
185  case 1:
186  {
187  uint32_t temp = ID;
188  // Ladder Starting bit = 2 (last unused) + 6 (Module Number) = 8
189  temp |= (component->geographicalID().rawId()<<8);
190  component->setGeographicalID(temp);
191  break;
192  }
193 
194  // PXF
195  case 2:
196  {
197  uint32_t temp = ID;
198  // Blade Starting bit = 1 (last unused) + 5 (Module Number) + 2 (Plaquette part) = 8
199  temp |= (component->geographicalID().rawId()<<8);
200  component->setGeographicalID(temp);
201  break;
202  }
203 
204  // TIB
205  case 3:
206  {
207  uint32_t temp = ID;
208  // Side+Part+String Starting bit = 2 (Module Type) + 2 (Module Number) = 4
209  temp |= (component->geographicalID().rawId()<<4);
210  component->setGeographicalID(temp);
211  break;
212  }
213 
214  // TID
215  case 4:
216  {
217  uint32_t temp = ID;
218  // Ring+Part Starting bit = 2 (Module Type) + 5 (Module Number) + 2 (Disk Part)= 9
219  temp |= (component->geographicalID().rawId()<<9);
220  component->setGeographicalID(DetId(temp));
221  break;
222  }
223 
224  // TOB
225  case 5:
226  {
227  uint32_t temp = ID;
228  // Side+Rod Starting bit = 2 (Module Type) + 3 (Module Number) = 5
229  temp |= (component->geographicalID().rawId()<<5);
230  component->setGeographicalID(temp);
231  break;
232  }
233 
234  // TEC
235  case 6:
236  {
237  uint32_t temp = ID;
238  // Petal+Part Starting bit = 2 (Module Type) + 3 (Module Number) + 3 (Ring Number) = 8
239  temp |= (component->geographicalID().rawId()<<8);
240  component->setGeographicalID(temp);
241  break;
242  }
243 
244  // the rest
245  default:
246  {
247  // do nothing
248  }
249 
250  // SubDetector switch ends
251  }
252 
253  // next level
254  iterate(component,level+1,component->geographicalID().rawId());
255  }
256 
257  break;
258  }
259 
260  // level 3
261  case 3:
262  {
263  for (uint32_t i=0;i<(in)->components().size();i++) {
264  auto component = in->component(i);
265 
266  switch (iSubDet) {
267 
268  // TEC
269  case 6:
270  {
271  // Ring Starting bit = 2 (Module Type) + 3 (Module Number)
272  uint32_t temp = ID;
273  temp |= (component->geographicalID().rawId()<<5);
274  component->setGeographicalID(temp);
275  break;
276  }
277 
278  // the others but TEC
279  default:
280  {
281  uint32_t temp = ID;
282  temp |= (component->geographicalID().rawId()<<2); // Starting bit = 2 (Module Type)
283  component->setGeographicalID(temp);
284  }
285 
286  // SubDetector switch ends
287  }
288 
289  // next level
290  iterate(component,level+1,component->geographicalID().rawId());
291 
292  }
293 
294  break;
295  }
296 
297  // level 4
298  case 4:
299  {
300 
301  for (uint32_t i=0;i<(in)->components().size();i++) {
302 
303  switch (iSubDet) {
304 
305  // TEC
306  case 6:
307  {
308  // Module Number bit = 2 (Module Type)
309  uint32_t temp = ID;
310  auto component = in->component(i);
311  temp |= (component->geographicalID().rawId()<<2);
312  component->setGeographicalID(temp);
313  // next level
314  iterate(component,level+1,component->geographicalID().rawId());
315  break;
316  }
317 
318  // the others stop here!
319  default:
320  {
321  for (uint32_t i=0;i<(in)->components().size();i++) {
322  uint32_t temp = ID;
323  auto component = in->component(i);
324  temp |= (component->geographicalID().rawId());
325  component->setGeographicalID(temp);
326  }
327  }
328 
329  // SubDetector switch ends
330  }
331 
332  }
333 
334  break;
335  }
336 
337  // level 5
338  case 5:
339  {
340  // TEC Module Type (only TEC arrives here)
341  for (uint32_t i=0;i<(in)->components().size();i++) {
342  uint32_t temp = ID;
343  auto component = in->component(i);
344  temp |= (component->geographicalID().rawId());
345  component->setGeographicalID(temp);
346  }
347  break;
348  }
349 
350  // throw exception
351  default:
352  {
353  cms::Exception("LogicError") <<" CmsTrackerDetIdBuilder invalid level "<< level;
354  }
355 
356  // level switch ends
357  }
358 
359  return;
360 
361 }
362 
int i
Definition: DBlmapReader.cc:9
uint32_t ID
Definition: Definitions.h:26
void setGeographicalID(DetId id)
Definition: GeometricDet.h:75
GeometricDet * buildId(GeometricDet *det)
DetId geographicalID() const
Definition: GeometricDet.h:201
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
CmsTrackerDetIdBuilder(unsigned int layerNumberPXB)
DDTranslation const & translation() const
Definition: GeometricDet.h:118
GeometricDet * component(size_t index)
Definition: GeometricDet.h:107
Definition: DetId.h:18
void iterate(GeometricDet *det, int level, unsigned int ID)
tuple level
Definition: testEve_cfg.py:34