CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // static class member declaration
15 
16 
17 // empty constructor/destructor
20 
21 // returns if the HPD index is valid
23 {
24  return (index>=0 && index<=NUM_HPDS-1);
25 }
26 
27 // returns if the RBX index is valid
29 {
30  return (index>=0 && index<=NUM_RBXS-1);
31 }
32 
34 {
35  if(id.subdet()!=HcalBarrel && id.subdet()!=HcalEndcap) return false;
36  if(theTopology_.valid(id)) return true;
37  else return false;
38 }
39 
40 bool HcalHPDRBXMap::isValid(int ieta, int iphi)
41 {
42  int absieta=abs(ieta);
43  if(absieta<=29 && absieta>=1 && iphi>=1 && iphi<=72) {
44  if(absieta<=20) return true;
45  if(absieta>=21 && iphi%2==1) return true;
46  }
47  return false;
48 }
49 
50 // returns the subdetector (HE or HE) for an HPD index
52 {
53  if(!isValidHPD(index))
55  << " HPD index " << index << " is invalid in HcalHPDRBXMap::subdetHPD().\n";
56 
57  if(index/NUM_HPDS_PER_SUBDET<=1) return HcalBarrel;
58  else return HcalEndcap;
59 }
60 
61 // returns the subdetector (HE or HE) for an RBX index
63 {
64  if(!isValidRBX(index))
66  << " RBX index " << index << " is invalid in HcalHPDRBXMap::subdetRBX().\n";
67 
68  if(index/NUM_RBXS_PER_SUBDET<=1) return HcalBarrel;
69  else return HcalEndcap;
70 }
71 
72 // returns the zside (1 or -1) given an HPD index
74 {
75  if(!isValidHPD(index))
77  << " HPD index " << index << " is invalid in HcalHPDRBXMap::zsideHPD().\n";
78 
79  if(index/NUM_HPDS_PER_SUBDET==0 || index/NUM_HPDS_PER_SUBDET==2) return 1;
80  else return -1;
81 }
82 
83 // returns the zside (1 or -1) given an RBX index
85 {
86  if(!isValidRBX(index))
88  << " RBX index " << index << " is invalid in HcalHPDRBXMap::zsideRBX().\n";
89 
90  if(index/NUM_RBXS_PER_SUBDET==0 || index/NUM_RBXS_PER_SUBDET==2) return 1;
91  else return -1;
92 }
93 
94 // returns the lowest iphi used in an HPD
96 {
97  if(!isValidHPD(index))
99  << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphiloHPD().\n";
100 
101  // adjust for offset between iphi and the HPD index
102  // index-->iphi
103  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
104  int iphi=index%NUM_HPDS_PER_SUBDET-1;
105  if(iphi<=0) iphi+=NUM_HPDS_PER_SUBDET;
106 
107  // HB
108  if(subdetHPD(index)==HcalBarrel) return iphi;
109 
110  // HE
111  if(iphi%2==0) return iphi-1;
112  else return iphi;
113 }
114 
115 // returns the lowest iphi used in an RBX
117 {
118  if(!isValidRBX(index))
120  << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphiloRBX().\n";
121 
122  // get the list of HPD indices in the RBX
123  boost::array<int, NUM_HPDS_PER_RBX> arr;
124  indicesHPDfromRBX(index, arr);
125 
126  // return the lowest iphi of the first HPD
127  return iphiloHPD(arr[0]);
128 }
129 
130 // returns the highest iphi used in an HPD
132 {
133  if(!isValidHPD(index))
135  << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphihiHPD().\n";
136 
137  // adjust for offset between iphi and the HPD index
138  // index-->iphi
139  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
140  int iphi=index%NUM_HPDS_PER_SUBDET-1;
141  if(iphi<=0) iphi+=NUM_HPDS_PER_SUBDET;
142 
143  // HB
144  if(subdetHPD(index)==HcalBarrel) return iphi;
145 
146  // HE
147  if(iphi%2==0) return iphi;
148  else return iphi+1;
149 }
150 
151 // returns the highest iphi used in an RBX
153 {
154  if(!isValidRBX(index))
156  << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphihiRBX().\n";
157 
158  // get the list of HPD indices in the RBX
159  boost::array<int, NUM_HPDS_PER_RBX> arr;
160  indicesHPDfromRBX(index, arr);
161 
162  // return the highest iphi of the last HPD
163  return iphihiHPD(arr[NUM_HPDS_PER_RBX-1]);
164 }
165 
166 
167 // returns the list of HPD indices found in a given RBX
168 void HcalHPDRBXMap::indicesHPDfromRBX(int rbxindex, boost::array<int, NUM_HPDS_PER_RBX>& hpdindices)
169 {
170  if(!isValidRBX(rbxindex))
172  << " RBX index " << rbxindex << " is invalid in HcalHPDRBXMap::indicesHPD().\n";
173 
174  for(unsigned int i=0; i<hpdindices.size(); i++)
175  hpdindices[i]=rbxindex*NUM_HPDS_PER_RBX+i;
176 
177  return;
178 }
179 
180 // returns the RBX index given an HPD index
182 {
183  if(!isValidHPD(hpdindex))
185  << " HPD index " << hpdindex << " is invalid in HcalHPDRBXMap::indexRBX().\n";
186 
187  return hpdindex/NUM_HPDS_PER_RBX;
188 }
189 
190 
191 // get the HPD index from an HcalDetector id
193 {
194  // return bad index if subdetector is invalid
195  if(!isValid(id)) {
197  << " HcalDetId " << id << " is invalid in HcalHPDRBXMap::indexHPD().\n";
198  }
199 
200  // specify the readout module (subdet and number)
201  int subdet=-1;
202  if(id.subdet()==HcalBarrel && id.zside()==1) subdet=0;
203  if(id.subdet()==HcalBarrel && id.zside()==-1) subdet=1;
204  if(id.subdet()==HcalEndcap && id.zside()==1) subdet=2;
205  if(id.subdet()==HcalEndcap && id.zside()==-1) subdet=3;
206 
207  int iphi=id.iphi();
208  int absieta=abs(id.ieta());
209 
210  // adjust for offset between iphi and the HPD index
211  // index-->iphi
212  // 0-->71, 1-->72, 2-->1, 3-->2, 4-->3, ..., 70-->69, 71-->70
213  int index=iphi+1;
214  if(index>=NUM_HPDS_PER_SUBDET) index-=NUM_HPDS_PER_SUBDET;
215  index+=subdet*NUM_HPDS_PER_SUBDET;
216 
217  // modify the index in the HE
218  if((subdet==2 || subdet==3) && absieta>=21 && absieta<=29) {
219  if(iphi%4==3 && absieta%2==1 && absieta!=29) index++;
220  if(iphi%4==3 && absieta==29 && id.depth()==2) index++;
221  if(iphi%4==1 && absieta%2==0 && absieta!=29) index++;
222  if(iphi%4==1 && absieta==29 && id.depth()==1) index++;
223  }
224  return index;
225 }
226 
228 {
229  return indexRBXfromHPD(indexHPD(id));
230 }
231 
232 void HcalHPDRBXMap::indexHPDfromEtaPhi(int ieta, int iphi, std::vector<int>& hpdindices)
233 {
234  // clear the vector
235  hpdindices.clear();
236  int absieta=abs(ieta);
237 
238  if(absieta<=15) { // HB only, depth doesn't matter
239  hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
240  } else if(absieta==16) { // HB and HE, depth doesn't matter
241  hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
242  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 3)));
243  } else if(absieta<29) { // HE only, depth doesn't matter
244  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
245  } else { // HE only, but depth matters
246  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
247  hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 2)));
248  }
249 
250  return;
251 }
252 
253 void HcalHPDRBXMap::indexRBXfromEtaPhi(int ieta, int iphi, std::vector<int>& rbxindices)
254 {
255  // clear the vector
256  rbxindices.clear();
257  int absieta=abs(ieta);
258 
259  if(absieta<=15) { // HB only
260  rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
261  } else if(absieta==16) { // HB and HE
262  rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
263  rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 3)));
264  } else { // HE only
265  rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 1)));
266  }
267 
268  return;
269 }
static const int NUM_HPDS_PER_RBX
Definition: HcalHPDRBXMap.h:33
int i
Definition: DBlmapReader.cc:9
static int indexRBXfromHPD(int hpdindex)
virtual bool valid(const HcalDetId &id) const
Definition: HcalTopology.cc:32
static int indexRBX(const HcalDetId &)
static HcalSubdetector subdetHPD(int index)
#define abs(x)
Definition: mlp_lapack.h:159
static void indexHPDfromEtaPhi(int ieta, int iphi, std::vector< int > &hpdindices)
static const int NUM_HPDS_PER_SUBDET
Definition: HcalHPDRBXMap.h:31
static int iphiloRBX(int index)
static const int NUM_RBXS
Definition: HcalHPDRBXMap.h:35
static const int NUM_HPDS
Definition: HcalHPDRBXMap.h:29
static int iphiloHPD(int index)
static bool isValidRBX(int index)
static const int NUM_RBXS_PER_SUBDET
Definition: HcalHPDRBXMap.h:37
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:32
static bool isValid(const HcalDetId &)
static int iphihiRBX(int index)
static void indicesHPDfromRBX(int rbxindex, boost::array< int, NUM_HPDS_PER_RBX > &hpdindices)
static HcalSubdetector subdetRBX(int index)
static int indexHPD(const HcalDetId &)
static HcalTopology theTopology_
Definition: HcalHPDRBXMap.h:93
static int iphihiHPD(int index)
static int zsideRBX(int index)