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