CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalGenericDetId.cc
Go to the documentation of this file.
1 
12 #include <iostream>
13 #include <cstdlib>
14 
17  return HcalOtherSubdetector ((rawId()>>20)&0x1F);
18 }
19 
21  if (null()) return HcalGenEmpty;
22  switch (det()) {
23  case Calo :
24  switch (subdetId()) {
27  default: return HcalGenUnknown;
28  }
29  case Hcal :
30  switch (HcalSubdetector(subdetId())) {
31  case 0: return HcalGenEmpty;
32  case HcalBarrel: return HcalGenBarrel;
33  case HcalEndcap: return HcalGenEndcap;
34  case HcalOuter: return HcalGenOuter;
35  case HcalForward: return HcalGenForward;
37  case HcalOther:
38  switch (otherSubdet ()) {
40  default: return HcalGenUnknown;
41  }
42  default: return HcalGenUnknown;
43  }
44  default: return HcalGenUnknown;
45  }
46  return HcalGenUnknown;
47 }
48 
51  return subdet == HcalGenBarrel || subdet == HcalGenEndcap || subdet == HcalGenOuter || subdet == HcalGenForward;
52 }
53 
56  return subdet == HcalGenCalibration;
57 }
58 
61  return subdet == HcalGenTriggerTower;
62 }
63 
66  return subdet == HcalGenZDC;
67 }
68 
71  return subdet == HcalGenCastor;
72 }
73 
74 std::ostream& operator<<(std::ostream& s,const HcalGenericDetId& id) {
75  if (id.null()) s << "(Null Id)";
76  else
77  switch (id.genericSubdet()) {
81  case HcalGenericDetId::HcalGenForward: s << HcalDetId(id); break;
83  case HcalGenericDetId::HcalGenZDC: s << HcalZDCDetId(id); break;
86  default: s << "(Hcal Unknown Id: 0x" << std::hex << id.rawId() << std::dec << ')';
87  }
88  return s;
89 }
90 
91 int HcalGenericDetId::hashedId(bool h2mode_) const {
92  int index = -1;
93 
94  int zside=0, ietaAbs=0, ieta=0, iphi=0, depth=0, channel=0, sector=0, module=0;
95 
96  switch (genericSubdet()) {
97  // HB valid DetIds: phi=1-72,eta=1-14,depth=1; phi=1-72,eta=15-16,depth=1-2
99  {
100  HcalDetId tid(rawId() );
101  zside = tid.zside();
102  ietaAbs = tid.ietaAbs();
103  iphi = tid.iphi();
104  depth = tid.depth();
105 
106  // if (ietaAbs < 16) index = (iphi - 1)*18 + (ietaAbs - 1) + (depth - 1);
107  // if (ietaAbs == 16) index = (iphi - 1)*18 + ietaAbs + (depth - 1);
108 
109  index = (iphi - 1)*18 + ietaAbs + depth - 2;
110  if (ietaAbs == 16) ++index;
111 
112  if (zside == -1) index += HBhalf;
113  }
114  break;
115  // HE valid DetIds: phi=1-72,eta=16-17,depth=1; phi=1-72,eta=18-20,depth=1-2;
116  // phi=1-71(in steps of 2),eta=21-26,depth=1-2; phi=1-71(in steps of 2),eta=27-28,depth=1-3
117  // phi=1-71(in steps of 2),eta=29,depth=1-2
119  {
120  HcalDetId tid(rawId() );
121  zside = tid.zside();
122  ietaAbs = tid.ietaAbs();
123  iphi = tid.iphi();
124  depth = tid.depth();
125 
126  if (!h2mode_)
127  {
128  if (ietaAbs == 16 || ietaAbs == 17) index = (iphi - 1)*8 + (iphi/2)*20 + (ietaAbs - 16);
129  if (ietaAbs >= 18 && ietaAbs <= 20) index = (iphi - 1)*8 + (iphi/2)*20 + 2 + 2*(ietaAbs-18) + (depth - 1);
130  if (ietaAbs >= 21 && ietaAbs <= 26) index = (iphi - 1)*8 + (iphi/2)*20 + 8 + 2*(ietaAbs-21) + (depth - 1);
131  if (ietaAbs >= 27 && ietaAbs <= 28) index = (iphi - 1)*8 + (iphi/2)*20 + 20 + 3*(ietaAbs-27) + (depth - 1);
132  if (ietaAbs == 29) index = (iphi - 1)*8 + (iphi/2)*20 + 26 + 2*(ietaAbs-29) + (depth - 1);
133  }
134  else
135  {
136  // make as general as possible, don't care about tight packing for the moment
137  // index = (iphi-1)*(4*14) + (ietaAbs - 16)*4 + (depth - 1);
138  index = 4*( 14*(iphi-1) + (ietaAbs - 16)) + (depth - 1);
139 
140  // if (ietaAbs == 16) index = (iphi - 1)*11 + (iphi/2)*20 + (ietaAbs - 16);
141  // if (ietaAbs == 17) index = (iphi - 1)*11 + (iphi/2)*20 + 1 + (ietaAbs - 17) + (depth - 1);
142  // if (ietaAbs >= 18 && ietaAbs <= 20) index = (iphi - 1)*11 + (iphi/2)*20 + 5 + 2*(ietaAbs-18) + (depth - 1);
143  // if (ietaAbs >= 21 && ietaAbs <= 26) index = (iphi - 1)*11 + (iphi/2)*20 + 11 + 2*(ietaAbs-21) + (depth - 1);
144  // if (ietaAbs >= 27 && ietaAbs <= 28) index = (iphi - 1)*11 + (iphi/2)*20 + 23 + 3*(ietaAbs-27) + (depth - 1);
145  // if (ietaAbs == 29) index = (iphi - 1)*11 + (iphi/2)*20 + 29 + 2*(ietaAbs-29) + (depth - 1);
146  }
147  if (zside == -1) index += HEhalf;
148 
149  }
150  break;
151  // HO valid DetIds: phi=1-72,eta=1-15,depth=4!
153  {
154  HcalDetId tid(rawId() );
155  zside = tid.zside();
156  ietaAbs = tid.ietaAbs();
157  iphi = tid.iphi();
158  depth = tid.depth();
159 
160  index = (iphi - 1)*15 + (ietaAbs - 1);
161 
162  if (zside == -1) index += HOhalf;
163  }
164  break;
165  // HF valid DetIds: phi=1-71(in steps of 2),eta=29-39,depth=1-2; phi=3-71(in steps of 4),eta=40-41,depth=1-2
167  {
168  HcalDetId tid(rawId() );
169  zside = tid.zside();
170  ietaAbs = tid.ietaAbs();
171  iphi = tid.iphi();
172  depth = tid.depth();
173 
174  index = ((iphi-1)/4)*4 + ((iphi-1)/2)*22 + 2*(ietaAbs-29) + (depth - 1);
175 
176  if (zside == -1) index += HFhalf;
177  }
178  break;
179  // TriggerTower:
181  {
182  HcalTrigTowerDetId tid(rawId() );
183  zside = tid.zside();
184  ietaAbs = tid.ietaAbs();
185  iphi = tid.iphi();
186 
187  if ((iphi-1)%4==0) index = (iphi-1)*32 + (ietaAbs-1) - (12*((iphi-1)/4));
188  else index = (iphi-1)*28 + (ietaAbs-1) + (4*(((iphi-1)/4)+1));
189 
190  if (zside == -1) index += HThalf;
191  // ieta = ietaAbs*zside;
192  }
193  break;
194  // ZDC: ZDC_EM: 1 to 5, ZDC_HAD: 1 to 4, ZDC_LUM: 1,2, eta = +1, -1
196  {
197  HcalZDCDetId tid(rawId() );
198  zside = tid.zside();
199  channel = tid.channel();
200  //depth = tid.depth();//depth is not unique, channel is
201 
202  switch (tid.section() ) {
203  case HcalZDCDetId::EM: index = (channel-1); break;
204  case HcalZDCDetId::HAD: index = 5 + (channel-1); break;
205  case HcalZDCDetId::LUM: index = 9 + (channel-1); break;
206  default: break;
207  }
208  if (zside == -1) index += ZDChalf;
209  }
210  break;
211  // Castor: zside +-1, sector (phi-segmentation) 1..16, module (z segm.) 1..14
212  // total: 14*16=224 per zside
214  {
215  HcalCastorDetId tid(rawId() );
216  zside = tid.zside();
217  sector = tid.sector();
218  module = tid.module();
219 
220  index = 14*(sector-1) + (module-1);
221  if (zside == -1) index += CASTORhalf;
222 
223  }
224  break;
225  // Calibration channels: no zside=-1 ! with current naming convention
227  {
228  HcalCalibDetId tid(rawId() );
229  channel = tid.cboxChannel();
230  ieta = tid.ieta();
231  iphi = tid.iphi();
232  zside = tid.zside();
233 
234 
236 
237  HcalSubdetector subDet = tid.hcalSubdet();
238 
239  if (subDet==HcalBarrel) {
240  //std::cout<<"CALIB_HB: ";
241  //dphi = 4 (18 phi values), 3 channel types (0,1,2), eta = -1 or 1
242  //total of 18*3*2=108 channels
243  index = ((iphi+1)/4-1) + 18*channel + 27*(ieta+1);
244  }
245  else if (subDet==HcalEndcap) {
246  //std::cout<<"CALIB_HE: ";
247  //dphi = 4 (18 phi values), 6 channel types (0,1,3,4,5,6), eta = -1 or 1
248  //total of 18*6*2=216 channels
249  if (channel>2) channel-=1;
250  index = ((iphi+1)/4-1) + 18*channel + 54*(ieta+1) + 108;
251  }
252  else if (subDet==HcalForward) {
253  //std::cout<<"CALIB_HF: ";
254  //dphi = 18 (4 phi values), 3 channel types (0,1,8), eta = -1 or 1
255  if (channel==8) channel = 2;
256  //total channels 4*3*2=24
257  index = (iphi-1)/18 + 4*channel + 6*(ieta+1) + 324;
258  }
259  else if (subDet==HcalOuter) {
260  //std::cout<<"CALIB_HO: ";
261  //there are 5 special calib crosstalk channels, one in each ring
262  if (channel==7) {
263  channel = 2;
264  index = (ieta+2) + 420;
265  }
266  //for HOM/HOP dphi = 6 (12 phi values), 2 channel types (0,1), eta = -2,-1 or 1,2
267  //for HO0/YB0 dphi = 12 (6 phi values), 2 channel types (0,1), eta = 0
268  else{
269  if (ieta<0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 348;
270  else if (ieta>0) index = ((iphi+1)/12-1) + 36*channel + 6*(ieta+2) + 6 + 348;
271  else index = ((iphi+1)/6-1) + 36*channel + 6*(ieta+2) + 348;
272  }
273  }
274  else {
275  std::cout << "HCAL Det Id not valid!" << std::endl;
276  index = 0;
277  }
278 
279  }
280  else if (tid.calibFlavor()==HcalCalibDetId::HOCrosstalk) {
281  //std::cout<<"HX: ";
282  //for YB0/HO0 phi is grouped in 6 groups of 6 with dphi=2 but the transitions are 1 or 3
283  // in such a way that the %36 operation yeilds unique values for every iphi
284  if (abs(ieta)==4) index = ((iphi-1)%36) + (((zside+1)*36)/2) + 72 + 425; //ieta = 1 YB0/HO0;
285  else index = (iphi-1) + (36*(zside+1)*2) + 425; //ieta = 0 for HO2M/HO1M ieta=2 for HO1P/HO2P;
286  }
287  //std::cout << " " << ieta << " " << zside << " " << iphi << " " << depth << " " << index << std::endl;
288  }
289  //std::cout << "eta: " << ieta << " side: " << zside << " phi: " << iphi << " depth: " << depth << " index: " << index << std::endl;
290 
291  break;
292  default: break;
293 
294  } // end switch
295 
296  return index;
297 }
int zside() const
get the z-side of the tower (1/-1)
bool isHcalZDCDetId() const
int hashedId(bool h2mode_=false) const
int sector() const
get the sector (1-16)
CalibDetType calibFlavor() const
get the flavor of this calibration detid
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:34
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:36
#define abs(x)
Definition: mlp_lapack.h:159
int module() const
get the module (1-2 for EM, 1-12 for HAD)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
int ieta() const
get the rbx name (if relevant)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int depth() const
get the tower depth
Definition: HcalDetId.h:42
bool isHcalTrigTowerDetId() const
HcalOtherSubdetector
Definition: HcalAssistant.h:33
HcalSubdetector
Definition: HcalAssistant.h:32
int zside() const
get the z-side of the cell (1/-1)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
static const int SubdetectorId
Section section() const
get the section
Definition: HcalZDCDetId.h:38
bool isHcalDetId() const
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:36
int iphi() const
get the low-edge iphi (if relevant)
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int zside() const
get the sign of ieta (+/-1)
static const int SubdetectorId
Definition: HcalZDCDetId.h:22
bool null() const
is this a null id ?
Definition: DetId.h:47
HcalOtherSubdetector otherSubdet() const
int channel() const
get the channel
Definition: HcalZDCDetId.h:42
int cboxChannel() const
get the calibration box channel (if relevant)
bool isHcalCalibDetId() const
tuple cout
Definition: gather_cfg.py:121
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
bool isHcalCastorDetId() const
HcalGenericSubdetector genericSubdet() const
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
Definition: vlib.h:209
int ietaAbs() const
get the absolute value of the tower ieta
int iphi() const
get the tower iphi