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