CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalHPDRBXMap.cc
Go to the documentation of this file.
1 //
2 // HcalHPDRBXMap.cc
3 //
4 // description: implementation of HcalHPDRBXMap.
5 //
6 // author: J.P. Chou, Brown
7 //
8 
12 
13 // empty constructor/destructor
16 
17 // returns if the HPD index is valid
18 bool HcalHPDRBXMap::isValidHPD(int index) { return (index >= 0 && index <= NUM_HPDS - 1); }
19 
20 // returns if the RBX index is valid
21 bool HcalHPDRBXMap::isValidRBX(int index) { return (index >= 0 && index <= NUM_RBXS - 1); }
22 
24  if (id.subdet() != HcalBarrel && id.subdet() != HcalEndcap)
25  return false;
26  return isValid(id.ieta(), id.iphi());
27 }
28 
29 bool HcalHPDRBXMap::isValid(int ieta, int iphi) {
30  int absieta = abs(ieta);
31  if (absieta <= 29 && absieta >= 1 && iphi >= 1 && iphi <= 72) {
32  if (absieta <= 20)
33  return true;
34  if (absieta >= 21 && iphi % 2 == 1)
35  return true;
36  }
37  return false;
38 }
39 
40 // returns the subdetector (HE or HE) for an HPD index
42  if (!isValidHPD(index))
44  << " HPD index " << index << " is invalid in HcalHPDRBXMap::subdetHPD().\n";
45 
46  if (index / NUM_HPDS_PER_SUBDET <= 1)
47  return HcalBarrel;
48  else
49  return HcalEndcap;
50 }
51 
52 // returns the subdetector (HE or HE) for an RBX index
54  if (!isValidRBX(index))
56  << " RBX index " << index << " is invalid in HcalHPDRBXMap::subdetRBX().\n";
57 
58  if (index / NUM_RBXS_PER_SUBDET <= 1)
59  return HcalBarrel;
60  else
61  return HcalEndcap;
62 }
63 
64 // returns the zside (1 or -1) given an HPD index
66  if (!isValidHPD(index))
68  << " HPD index " << index << " is invalid in HcalHPDRBXMap::zsideHPD().\n";
69 
70  if (index / NUM_HPDS_PER_SUBDET == 0 || index / NUM_HPDS_PER_SUBDET == 2)
71  return 1;
72  else
73  return -1;
74 }
75 
76 // returns the zside (1 or -1) given an RBX index
78  if (!isValidRBX(index))
80  << " RBX index " << index << " is invalid in HcalHPDRBXMap::zsideRBX().\n";
81 
82  if (index / NUM_RBXS_PER_SUBDET == 0 || index / NUM_RBXS_PER_SUBDET == 2)
83  return 1;
84  else
85  return -1;
86 }
87 
88 // returns the lowest iphi used in an HPD
90  if (!isValidHPD(index))
92  << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphiloHPD().\n";
93 
94  // adjust for offset between iphi and the HPD index
95  // index-->iphi
96  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
97  int iphi = index % NUM_HPDS_PER_SUBDET - 1;
98  if (iphi <= 0)
99  iphi += NUM_HPDS_PER_SUBDET;
100 
101  // HB
102  if (subdetHPD(index) == HcalBarrel)
103  return iphi;
104 
105  // HE
106  if (iphi % 2 == 0)
107  return iphi - 1;
108  else
109  return iphi;
110 }
111 
112 // returns the lowest iphi used in an RBX
114  if (!isValidRBX(index))
116  << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphiloRBX().\n";
117 
118  // get the list of HPD indices in the RBX
119  std::array<int, NUM_HPDS_PER_RBX> arr;
120  indicesHPDfromRBX(index, arr);
121 
122  // return the lowest iphi of the first HPD
123  return iphiloHPD(arr[0]);
124 }
125 
126 // returns the highest iphi used in an HPD
128  if (!isValidHPD(index))
130  << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphihiHPD().\n";
131 
132  // adjust for offset between iphi and the HPD index
133  // index-->iphi
134  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
135  int iphi = index % NUM_HPDS_PER_SUBDET - 1;
136  if (iphi <= 0)
137  iphi += NUM_HPDS_PER_SUBDET;
138 
139  // HB
140  if (subdetHPD(index) == HcalBarrel)
141  return iphi;
142 
143  // HE
144  if (iphi % 2 == 0)
145  return iphi;
146  else
147  return iphi + 1;
148 }
149 
150 // returns the highest iphi used in an RBX
152  if (!isValidRBX(index))
154  << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphihiRBX().\n";
155 
156  // get the list of HPD indices in the RBX
157  std::array<int, NUM_HPDS_PER_RBX> arr;
158  indicesHPDfromRBX(index, arr);
159 
160  // return the highest iphi of the last HPD
161  return iphihiHPD(arr[NUM_HPDS_PER_RBX - 1]);
162 }
163 
164 // returns the list of HPD indices found in a given RBX
165 void HcalHPDRBXMap::indicesHPDfromRBX(int rbxindex, std::array<int, NUM_HPDS_PER_RBX>& hpdindices) {
166  if (!isValidRBX(rbxindex))
168  << " RBX index " << rbxindex << " is invalid in HcalHPDRBXMap::indicesHPD().\n";
169 
170  for (unsigned int i = 0; i < hpdindices.size(); i++)
171  hpdindices[i] = rbxindex * NUM_HPDS_PER_RBX + i;
172 
173  return;
174 }
175 
176 // returns the RBX index given an HPD index
178  if (!isValidHPD(hpdindex))
180  << " HPD index " << hpdindex << " is invalid in HcalHPDRBXMap::indexRBX().\n";
181 
182  return hpdindex / NUM_HPDS_PER_RBX;
183 }
184 
185 // get the HPD index from an HcalDetector id
187  // return bad index if subdetector is invalid
188  if (!isValid(id)) {
190  << " HcalDetId " << id << " is invalid in HcalHPDRBXMap::indexHPD().\n";
191  }
192 
193  // specify the readout module (subdet and number)
194  int subdet = -1;
195  if (id.subdet() == HcalBarrel && id.zside() == 1)
196  subdet = 0;
197  if (id.subdet() == HcalBarrel && id.zside() == -1)
198  subdet = 1;
199  if (id.subdet() == HcalEndcap && id.zside() == 1)
200  subdet = 2;
201  if (id.subdet() == HcalEndcap && id.zside() == -1)
202  subdet = 3;
203 
204  int iphi = id.iphi();
205  int absieta = abs(id.ieta());
206 
207  // adjust for offset between iphi and the HPD index
208  // index-->iphi
209  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
210  int index = iphi + 1;
211  if (index >= NUM_HPDS_PER_SUBDET)
212  index -= NUM_HPDS_PER_SUBDET;
213  index += subdet * NUM_HPDS_PER_SUBDET;
214 
215  // modify the index in the HE
216  if ((subdet == 2 || subdet == 3) && absieta >= 21 && absieta <= 29) {
217  if (iphi % 4 == 3 && absieta % 2 == 1 && absieta != 29)
218  index++;
219  if (iphi % 4 == 3 && absieta == 29 && id.depth() == 2)
220  index++;
221  if (iphi % 4 == 1 && absieta % 2 == 0 && absieta != 29)
222  index++;
223  if (iphi % 4 == 1 && absieta == 29 && id.depth() == 1)
224  index++;
225  }
226  return index;
227 }
228 
230 
231 void HcalHPDRBXMap::indexHPDfromEtaPhi(int ieta, int iphi, std::vector<int>& hpdindices) {
232  // clear the vector
233  hpdindices.clear();
234  int absieta = abs(ieta);
235 
236  if (absieta <= 15) { // HB only, depth doesn't matter
237  hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
238  } else if (absieta == 16) { // HB and HE, depth doesn't matter
239  hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
240  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 3)));
241  } else if (absieta < 29) { // HE only, depth doesn't matter
242  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
243  } else { // HE only, but depth matters
244  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
245  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 2)));
246  }
247 
248  return;
249 }
250 
251 void HcalHPDRBXMap::indexRBXfromEtaPhi(int ieta, int iphi, std::vector<int>& rbxindices) {
252  // clear the vector
253  rbxindices.clear();
254  int absieta = abs(ieta);
255 
256  if (absieta <= 15) { // HB only
257  rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
258  } else if (absieta == 16) { // HB and HE
259  rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
260  rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 3)));
261  } else { // HE only
262  rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 1)));
263  }
264 
265  return;
266 }
static const int NUM_HPDS_PER_RBX
Definition: HcalHPDRBXMap.h:30
static int indexRBXfromHPD(int hpdindex)
static void indicesHPDfromRBX(int rbxindex, std::array< int, NUM_HPDS_PER_RBX > &hpdindices)
static int indexRBX(const HcalDetId &)
static HcalSubdetector subdetHPD(int index)
static void indexHPDfromEtaPhi(int ieta, int iphi, std::vector< int > &hpdindices)
int zside(DetId const &)
static const int NUM_HPDS_PER_SUBDET
Definition: HcalHPDRBXMap.h:28
static int iphiloRBX(int index)
static const int NUM_RBXS
Definition: HcalHPDRBXMap.h:32
static const int NUM_HPDS
Definition: HcalHPDRBXMap.h:26
static int iphiloHPD(int index)
static bool isValidRBX(int index)
static const int NUM_RBXS_PER_SUBDET
Definition: HcalHPDRBXMap.h:34
static void indexRBXfromEtaPhi(int ieta, int iphi, std::vector< int > &rbxindices)
static bool isValidHPD(int index)
static int zsideHPD(int index)
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isValid(const HcalDetId &)
static int iphihiRBX(int index)
static HcalSubdetector subdetRBX(int index)
static int indexHPD(const HcalDetId &)
static int iphihiHPD(int index)
static int zsideRBX(int index)