CMS 3D CMS Logo

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 
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 
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 
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)
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)
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)
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 }
HcalHPDRBXMap::zsideHPD
static int zsideHPD(int index)
Definition: HcalHPDRBXMap.cc:65
HcalHPDRBXMap::indicesHPDfromRBX
static void indicesHPDfromRBX(int rbxindex, std::array< int, NUM_HPDS_PER_RBX > &hpdindices)
Definition: HcalHPDRBXMap.cc:165
mps_fire.i
i
Definition: mps_fire.py:428
HcalHPDRBXMap::iphiloHPD
static int iphiloHPD(int index)
Definition: HcalHPDRBXMap.cc:89
edm::errors::LogicError
Definition: EDMException.h:37
HcalHPDRBXMap::NUM_HPDS_PER_RBX
const static int NUM_HPDS_PER_RBX
Definition: HcalHPDRBXMap.h:30
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
HcalHPDRBXMap::NUM_HPDS
const static int NUM_HPDS
Definition: HcalHPDRBXMap.h:26
HcalHPDRBXMap::subdetRBX
static HcalSubdetector subdetRBX(int index)
Definition: HcalHPDRBXMap.cc:53
HcalHPDRBXMap::iphihiRBX
static int iphihiRBX(int index)
Definition: HcalHPDRBXMap.cc:151
HcalHPDRBXMap.h
HcalHPDRBXMap::iphihiHPD
static int iphihiHPD(int index)
Definition: HcalHPDRBXMap.cc:127
HcalHPDRBXMap::iphiloRBX
static int iphiloRBX(int index)
Definition: HcalHPDRBXMap.cc:113
HcalHPDRBXMap::zsideRBX
static int zsideRBX(int index)
Definition: HcalHPDRBXMap.cc:77
HcalBarrel
Definition: HcalAssistant.h:33
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EDMException.h
HcalHPDRBXMap::subdetHPD
static HcalSubdetector subdetHPD(int index)
Definition: HcalHPDRBXMap.cc:41
HcalHPDRBXMap::isValidHPD
static bool isValidHPD(int index)
Definition: HcalHPDRBXMap.cc:18
HcalHPDRBXMap::HcalHPDRBXMap
HcalHPDRBXMap()
Definition: HcalHPDRBXMap.cc:14
HcalHPDRBXMap::indexRBX
static int indexRBX(const HcalDetId &)
Definition: HcalHPDRBXMap.cc:229
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalHPDRBXMap::indexRBXfromEtaPhi
static void indexRBXfromEtaPhi(int ieta, int iphi, std::vector< int > &rbxindices)
Definition: HcalHPDRBXMap.cc:251
HcalHPDRBXMap::indexHPDfromEtaPhi
static void indexHPDfromEtaPhi(int ieta, int iphi, std::vector< int > &hpdindices)
Definition: HcalHPDRBXMap.cc:231
HcalHPDRBXMap::NUM_RBXS_PER_SUBDET
const static int NUM_RBXS_PER_SUBDET
Definition: HcalHPDRBXMap.h:34
HcalDetId
Definition: HcalDetId.h:12
HcalSubdetector.h
HcalHPDRBXMap::NUM_HPDS_PER_SUBDET
const static int NUM_HPDS_PER_SUBDET
Definition: HcalHPDRBXMap.h:28
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalHPDRBXMap::~HcalHPDRBXMap
~HcalHPDRBXMap()
Definition: HcalHPDRBXMap.cc:15
HcalHPDRBXMap::isValid
static bool isValid(const HcalDetId &)
Definition: HcalHPDRBXMap.cc:23
HcalEndcap
Definition: HcalAssistant.h:34
Exception
Definition: hltDiff.cc:246
HcalHPDRBXMap::NUM_RBXS
const static int NUM_RBXS
Definition: HcalHPDRBXMap.h:32
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalHPDRBXMap::indexRBXfromHPD
static int indexRBXfromHPD(int hpdindex)
Definition: HcalHPDRBXMap.cc:177
HcalHPDRBXMap::isValidRBX
static bool isValidRBX(int index)
Definition: HcalHPDRBXMap.cc:21
HcalHPDRBXMap::indexHPD
static int indexHPD(const HcalDetId &)
Definition: HcalHPDRBXMap.cc:186