CMS 3D CMS Logo

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