CMS 3D CMS Logo

HcalNoiseRBXArray.cc
Go to the documentation of this file.
1 //
2 // HcalNoiseRBXArray.cc
3 //
4 // description: implementation of the HcalNoiseRBXArray
5 //
6 // author: J.P. Chou, Brown
7 //
8 //
9 
11 
12 using namespace reco;
13 
14 // constructor sets the idnumbers for the rbx's and the hpd's
16 {
17  for(unsigned int i=0; i<size(); i++) {
18  HcalNoiseRBX& rbx=at(i);
19 
20  // set the rbxnumber here
21  rbx.idnumber_=i;
22 
23  // set the hpdnumber here
24  boost::array<int, HcalHPDRBXMap::NUM_HPDS_PER_RBX> hpdindices;
26  for(int j=0; j<HcalHPDRBXMap::NUM_HPDS_PER_RBX; j++) {
27  rbx.hpds_[j].idnumber_=hpdindices[j];
28  }
29  }
30 }
31 
33 {
34 }
35 
36 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::endHPD(void) const
37 {
38  // the choice of which rbx to use is arbitrary,
39  // as long as we're consistent
40  return at(0).hpds_.end();
41 }
42 
43 // code here should be same as above (modulo 'const'ness)
44 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::endHPD(void)
45 {
46  // the choice of which rbx to use is arbitrary,
47  // as long as we're consistent
48  return at(0).hpds_.end();
49 }
50 
51 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(int hpdindex)
52 {
53  // if the hpdindex is invalid
54  if(!HcalHPDRBXMap::isValidHPD(hpdindex)) return endHPD();
55 
56  int rbxindex=HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
57 
58  // find the HPD in the RBX
59  HcalNoiseRBX& rbx=at(rbxindex);
60  for(std::vector<HcalNoiseHPD>::iterator it=rbx.hpds_.begin(); it!=rbx.hpds_.end(); ++it) {
61  if(it->idnumber_==hpdindex) return it;
62  }
63 
64  // if we're here, this is a bug
66  << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID(). This is a bug.\n";
67  return endHPD();
68 }
69 
70 // code here should be same as above (modulo 'const'ness)
71 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(int hpdindex) const
72 {
73  // if the hpdindex is invalid
74  if(!HcalHPDRBXMap::isValidHPD(hpdindex)) return endHPD();
75 
76  int rbxindex=HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
77 
78  // find the HPD in the RBX
79  const HcalNoiseRBX& rbx=at(rbxindex);
80  for(std::vector<HcalNoiseHPD>::const_iterator it=rbx.hpds_.begin(); it!=rbx.hpds_.end(); ++it) {
81  if(it->idnumber_==hpdindex) return it;
82  }
83 
84  // if we're here, this is a bug
86  << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID(). This is a bug.\n";
87  return endHPD();
88 }
89 
90 HcalNoiseRBXArray::iterator
92 {
93  if(!HcalHPDRBXMap::isValidRBX(rbxindex)) return endRBX();
94  return begin()+rbxindex;
95 }
96 
97 HcalNoiseRBXArray::const_iterator
98 HcalNoiseRBXArray::findRBX(int rbxindex) const
99 {
100  if(!HcalHPDRBXMap::isValidRBX(rbxindex)) return endRBX();
101  return begin()+rbxindex;
102 }
103 
104 std::vector<HcalNoiseHPD>::iterator
106 {
107  if(!HcalHPDRBXMap::isValid(id)) return endHPD();
108  return findHPD(HcalHPDRBXMap::indexHPD(id));
109 }
110 
111 std::vector<HcalNoiseHPD>::const_iterator
113 {
114  if(!HcalHPDRBXMap::isValid(id)) return endHPD();
115  return findHPD(HcalHPDRBXMap::indexHPD(id));
116 }
117 
118 HcalNoiseRBXArray::iterator
120 {
121  if(!HcalHPDRBXMap::isValid(id)) return endRBX();
122  return findRBX(HcalHPDRBXMap::indexRBX(id));
123 }
124 
125 HcalNoiseRBXArray::const_iterator
127 {
128  if(!HcalHPDRBXMap::isValid(id)) return endRBX();
129  return findRBX(HcalHPDRBXMap::indexRBX(id));
130 }
131 
132 std::vector<HcalNoiseHPD>::iterator
134 { return findHPD(f.id()); }
135 
136 std::vector<HcalNoiseHPD>::const_iterator
138 { return findHPD(f.id()); }
139 
140 HcalNoiseRBXArray::iterator
142 { return findRBX(f.id()); }
143 
144 HcalNoiseRBXArray::const_iterator
146 { return findRBX(f.id()); }
147 
148 std::vector<HcalNoiseHPD>::iterator
150 { return findHPD(h.id()); }
151 
152 std::vector<HcalNoiseHPD>::const_iterator
154 { return findHPD(h.id()); }
155 
156 HcalNoiseRBXArray::iterator
158 { return findRBX(h.id()); }
159 
160 HcalNoiseRBXArray::const_iterator
162 { return findRBX(h.id()); }
163 
164 
165 void HcalNoiseRBXArray::findHPD(const CaloTower& tower, std::vector<std::vector<HcalNoiseHPD>::const_iterator>& vec) const
166 {
167  // clear the vector
168  vec.clear();
169 
170  // check if the tower corresponds to a valid HPD/RBX
171  if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
172 
173  // find the HPD indices
174  std::vector<int> hpdindices;
175  HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
176  for(std::vector<int>::const_iterator it=hpdindices.begin(); it!=hpdindices.end(); ++it)
177  vec.push_back(findHPD(*it));
178 
179  return;
180 }
181 
182 void HcalNoiseRBXArray::findHPD(const CaloTower& tower, std::vector<std::vector<HcalNoiseHPD>::iterator>& vec)
183 {
184  // clear the vector
185  vec.clear();
186 
187  // check if the tower corresponds to a valid HPD/RBX
188  if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
189 
190  // find the HPD indices
191  std::vector<int> hpdindices;
192  HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
193  for(std::vector<int>::const_iterator it=hpdindices.begin(); it!=hpdindices.end(); ++it)
194  vec.push_back(findHPD(*it));
195 
196  return;
197 }
198 
199 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::iterator>& vec)
200 {
201  // clear the vector
202  vec.clear();
203 
204  // check if the tower corresponds to a valid HPD/RBX
205  if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
206 
207  // find the RBX indices
208  std::vector<int> rbxindices;
209  HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
210  for(std::vector<int>::const_iterator it=rbxindices.begin(); it!=rbxindices.end(); ++it)
211  vec.push_back(findRBX(*it));
212 
213  return;
214 }
215 
216 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::const_iterator>& vec) const
217 {
218  // clear the vector
219  vec.clear();
220 
221  // check if the tower corresponds to a valid HPD/RBX
222  if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
223 
224  // find the RBX indices
225  std::vector<int> rbxindices;
226  HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
227  for(std::vector<int>::const_iterator it=rbxindices.begin(); it!=rbxindices.end(); ++it)
228  vec.push_back(findRBX(*it));
229 
230  return;
231 }
static const int NUM_HPDS_PER_RBX
Definition: HcalHPDRBXMap.h:32
size
Write out results.
static int indexRBXfromHPD(int hpdindex)
std::vector< HcalNoiseHPD >::iterator endHPD(void)
int ieta() const
Definition: CaloTower.h:185
static int indexRBX(const HcalDetId &)
HcalDetId id() const
get the id
Definition: HBHERecHit.h:25
int iphi() const
Definition: CaloTower.h:187
static void indexHPDfromEtaPhi(int ieta, int iphi, std::vector< int > &hpdindices)
HcalNoiseRBXArray::iterator findRBX(int rbxindex)
static bool isValidRBX(int index)
static void indexRBXfromEtaPhi(int ieta, int iphi, std::vector< int > &rbxindices)
static bool isValidHPD(int index)
std::vector< HcalNoiseHPD > hpds_
Definition: HcalNoiseRBX.h:112
std::vector< HcalNoiseHPD >::iterator findHPD(int hpdindex)
double f[11][100]
HcalNoiseRBXArray::iterator endRBX(void)
static bool isValid(const HcalDetId &)
static void indicesHPDfromRBX(int rbxindex, boost::array< int, NUM_HPDS_PER_RBX > &hpdindices)
fixed size matrix
#define begin
Definition: vmac.h:30
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
static int indexHPD(const HcalDetId &)