CMS 3D CMS Logo

L1CaloRegionDetId.cc
Go to the documentation of this file.
1 
2 
4 
5 // default constructor - null DetId
7 
8 // construct from raw id
9 L1CaloRegionDetId::L1CaloRegionDetId(uint32_t rawid) : DetId(rawid) {}
10 
11 // construct from ieta, iphi indices
12 // ieta runs from 0 (at -z) to 21 (at +z)
14  id_ |= (ieta & 0x1f) | ((iphi & 0x1f) << 5);
15 }
16 
17 // construct from RCT crate, card, region IDs
18 L1CaloRegionDetId::L1CaloRegionDetId(unsigned icrate, unsigned icard, unsigned irgn) : DetId(Calo, 2) {
19  int ieta = 0;
20  int iphi = 0;
21 
22  // Calculate iphi
23  int phi_index = icrate % 9;
24  if ((icard == 0) || (icard == 2) || (icard == 4))
25  phi_index = phi_index * 2;
26  else if ((icard == 1) || (icard == 3) || (icard == 5))
27  phi_index = phi_index * 2 + 1;
28  else if (icard == 6)
29  phi_index = phi_index * 2 + irgn;
30  // for HF
31  else if (icard == 999)
32  phi_index = phi_index * 2 + (irgn / 4);
33  iphi = (22 - phi_index) % 18;
34 
35  // Calculate ieta
36  int eta_index = 0;
37  if (icard < 6)
38  eta_index = (icard / 2) * 2 + irgn;
39  else if (icard == 6)
40  eta_index = 6;
41  // HF
42  else if (icard == 999)
43  eta_index = (irgn % 4) + 7;
44 
45  if (icrate < 9)
46  ieta = 10 - eta_index;
47  else if (icrate >= 9)
48  ieta = 11 + eta_index;
49 
51  id_ |= (ieta & 0x1f) | ((iphi & 0x1f) << 5);
52 }
53 
54 // return RCT crate ID
55 unsigned L1CaloRegionDetId::rctCrate() const { // TODO - check this is correct!
56  unsigned phiCrate = ((N_PHI + 4 - iphi()) % N_PHI) / 2;
57  return (ieta() < (N_ETA / 2) ? phiCrate : phiCrate + N_PHI / 2);
58 }
59 
60 // return RCT card number
61 unsigned L1CaloRegionDetId::rctCard() const {
62  unsigned card = 999;
63  unsigned rct_phi_index = (22 - iphi()) % 18;
64  if ((ieta() == 4) || (ieta() == 17)) {
65  card = 6;
66  } else if ((ieta() > 4) && (ieta() <= 10)) {
67  unsigned index = (ieta() - 5) / 2;
68  card = ((2 - index) * 2) + (rct_phi_index % 2);
69  } else if ((ieta() >= 11) && (ieta() < 17)) {
70  unsigned index = (ieta() - 11) / 2;
71  card = (index * 2) + (rct_phi_index % 2);
72  }
73  return card;
74 }
75 
76 // return RCT region number
77 unsigned L1CaloRegionDetId::rctRegion() const {
78  unsigned rgn = 999;
79  unsigned rct_phi_index = (22 - iphi()) % 18;
80  if (ieta() < 4) {
81  rgn = (3 - ieta()) + 4 * (rct_phi_index % 2);
82  } else if (ieta() > 17) {
83  rgn = (ieta() - 18) + 4 * (rct_phi_index % 2);
84  } else if ((ieta() == 4) || (ieta() == 17)) {
85  rgn = (rct_phi_index % 2);
86  } else if ((ieta() > 4) && (ieta() <= 10)) {
87  rgn = (ieta() % 2);
88  } else if ((ieta() >= 11) && (ieta() < 17)) {
89  rgn = ((ieta() - 1) % 2);
90  }
91  return rgn;
92 }
unsigned ieta() const
global eta index (0-21)
static const unsigned N_ETA
unsigned rctRegion() const
return RCT region index (0-1 for barrel, 0-7 for HF)
Definition: DetId.h:17
uint32_t id_
Definition: DetId.h:69
unsigned rctCard() const
return RCT card number (0-6)
L1CaloRegionDetId()
create null id
unsigned rctCrate() const
return RCT crate number (0-17)
unsigned iphi() const
global phi index (0-17)
static const unsigned N_PHI