CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoMET/METAlgorithms/src/HcalNoiseRBXArray.cc

Go to the documentation of this file.
00001 //
00002 // HcalNoiseRBXArray.cc
00003 //
00004 //   description: implementation of the HcalNoiseRBXArray
00005 //
00006 //   author: J.P. Chou, Brown
00007 //
00008 //
00009 
00010 #include "RecoMET/METAlgorithms/interface/HcalNoiseRBXArray.h"
00011 
00012 using namespace reco;
00013 
00014 // constructor sets the idnumbers for the rbx's and the hpd's
00015 HcalNoiseRBXArray::HcalNoiseRBXArray()
00016 {
00017   for(unsigned int i=0; i<size(); i++) {
00018     HcalNoiseRBX& rbx=at(i);
00019     
00020     // set the rbxnumber here
00021     rbx.idnumber_=i;
00022 
00023     // set the hpdnumber here
00024     boost::array<int, HcalHPDRBXMap::NUM_HPDS_PER_RBX> hpdindices;
00025     HcalHPDRBXMap::indicesHPDfromRBX(i, hpdindices);
00026     for(int j=0; j<HcalHPDRBXMap::NUM_HPDS_PER_RBX; j++) {
00027       rbx.hpds_[j].idnumber_=hpdindices[j];
00028     }
00029   }
00030 }
00031 
00032 HcalNoiseRBXArray::~HcalNoiseRBXArray()
00033 {
00034 }
00035 
00036 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::endHPD(void) const
00037 {
00038   // the choice of which rbx to use is arbitrary,
00039   // as long as we're consistent
00040   return at(0).hpds_.end();
00041 }
00042 
00043 // code here should be same as above (modulo 'const'ness)
00044 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::endHPD(void)
00045 {
00046   // the choice of which rbx to use is arbitrary,
00047   // as long as we're consistent
00048   return at(0).hpds_.end();
00049 }
00050 
00051 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(int hpdindex)
00052 {
00053   // if the hpdindex is invalid
00054   if(!HcalHPDRBXMap::isValidHPD(hpdindex)) return endHPD();
00055   
00056   int rbxindex=HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
00057   
00058   // find the HPD in the RBX
00059   HcalNoiseRBX& rbx=at(rbxindex);
00060   for(std::vector<HcalNoiseHPD>::iterator it=rbx.hpds_.begin(); it!=rbx.hpds_.end(); ++it) {
00061     if(it->idnumber_==hpdindex) return it;
00062   }
00063   
00064   // if we're here, this is a bug
00065   throw edm::Exception(edm::errors::LogicError)
00066     << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID().  This is a bug.\n";
00067   return endHPD();
00068 }
00069 
00070 // code here should be same as above (modulo 'const'ness)
00071 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(int hpdindex) const
00072 {
00073   // if the hpdindex is invalid
00074   if(!HcalHPDRBXMap::isValidHPD(hpdindex)) return endHPD();
00075   
00076   int rbxindex=HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
00077   
00078   // find the HPD in the RBX
00079   const HcalNoiseRBX& rbx=at(rbxindex);
00080   for(std::vector<HcalNoiseHPD>::const_iterator it=rbx.hpds_.begin(); it!=rbx.hpds_.end(); ++it) {
00081     if(it->idnumber_==hpdindex) return it;
00082   }
00083   
00084   // if we're here, this is a bug
00085   throw edm::Exception(edm::errors::LogicError)
00086     << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID().  This is a bug.\n";
00087   return endHPD();
00088 }
00089 
00090 HcalNoiseRBXArray::iterator
00091 HcalNoiseRBXArray::findRBX(int rbxindex)
00092 {
00093   if(!HcalHPDRBXMap::isValidRBX(rbxindex)) return endRBX();
00094   return begin()+rbxindex;
00095 }
00096 
00097 HcalNoiseRBXArray::const_iterator
00098 HcalNoiseRBXArray::findRBX(int rbxindex) const
00099 {
00100   if(!HcalHPDRBXMap::isValidRBX(rbxindex)) return endRBX();
00101   return begin()+rbxindex;
00102 }
00103 
00104 std::vector<HcalNoiseHPD>::iterator
00105 HcalNoiseRBXArray::findHPD(const HcalDetId& id)
00106 {
00107   if(!HcalHPDRBXMap::isValid(id)) return endHPD();
00108   return findHPD(HcalHPDRBXMap::indexHPD(id));
00109 }
00110 
00111 std::vector<HcalNoiseHPD>::const_iterator
00112 HcalNoiseRBXArray::findHPD(const HcalDetId& id) const
00113 {
00114   if(!HcalHPDRBXMap::isValid(id)) return endHPD();
00115   return findHPD(HcalHPDRBXMap::indexHPD(id));
00116 }
00117 
00118 HcalNoiseRBXArray::iterator
00119 HcalNoiseRBXArray::findRBX(const HcalDetId& id)
00120 {
00121   if(!HcalHPDRBXMap::isValid(id)) return endRBX();
00122   return findRBX(HcalHPDRBXMap::indexRBX(id));
00123 }
00124 
00125 HcalNoiseRBXArray::const_iterator
00126 HcalNoiseRBXArray::findRBX(const HcalDetId& id) const
00127 {
00128   if(!HcalHPDRBXMap::isValid(id)) return endRBX();
00129   return findRBX(HcalHPDRBXMap::indexRBX(id));
00130 }
00131 
00132 std::vector<HcalNoiseHPD>::iterator
00133 HcalNoiseRBXArray::findHPD(const HBHEDataFrame& f)
00134 { return findHPD(f.id()); }
00135 
00136 std::vector<HcalNoiseHPD>::const_iterator
00137 HcalNoiseRBXArray::findHPD(const HBHEDataFrame& f) const
00138 { return findHPD(f.id()); }
00139 
00140 HcalNoiseRBXArray::iterator
00141 HcalNoiseRBXArray::findRBX(const HBHEDataFrame& f)
00142 { return findRBX(f.id()); }
00143 
00144 HcalNoiseRBXArray::const_iterator
00145 HcalNoiseRBXArray::findRBX(const HBHEDataFrame& f) const
00146 { return findRBX(f.id()); }
00147 
00148 std::vector<HcalNoiseHPD>::iterator
00149 HcalNoiseRBXArray::findHPD(const HBHERecHit& h)
00150 { return findHPD(h.id()); }
00151 
00152 std::vector<HcalNoiseHPD>::const_iterator
00153 HcalNoiseRBXArray::findHPD(const HBHERecHit& h) const
00154 { return findHPD(h.id()); }
00155 
00156 HcalNoiseRBXArray::iterator
00157 HcalNoiseRBXArray::findRBX(const HBHERecHit& h)
00158 { return findRBX(h.id()); }
00159 
00160 HcalNoiseRBXArray::const_iterator
00161 HcalNoiseRBXArray::findRBX(const HBHERecHit& h) const
00162 { return findRBX(h.id()); }
00163 
00164 
00165 void HcalNoiseRBXArray::findHPD(const CaloTower& tower, std::vector<std::vector<HcalNoiseHPD>::const_iterator>& vec) const
00166 {
00167   // clear the vector
00168   vec.clear();
00169 
00170   // check if the tower corresponds to a valid HPD/RBX
00171   if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
00172 
00173   // find the HPD indices
00174   std::vector<int> hpdindices;
00175   HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
00176   for(std::vector<int>::const_iterator it=hpdindices.begin(); it!=hpdindices.end(); ++it)
00177     vec.push_back(findHPD(*it));
00178 
00179   return;
00180 }
00181 
00182 void HcalNoiseRBXArray::findHPD(const CaloTower& tower, std::vector<std::vector<HcalNoiseHPD>::iterator>& vec)
00183 {
00184   // clear the vector
00185   vec.clear();
00186 
00187   // check if the tower corresponds to a valid HPD/RBX
00188   if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
00189 
00190   // find the HPD indices
00191   std::vector<int> hpdindices;
00192   HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
00193   for(std::vector<int>::const_iterator it=hpdindices.begin(); it!=hpdindices.end(); ++it)
00194     vec.push_back(findHPD(*it));
00195 
00196   return;
00197 }
00198 
00199 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::iterator>& vec)
00200 {
00201   // clear the vector
00202   vec.clear();
00203 
00204   // check if the tower corresponds to a valid HPD/RBX
00205   if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
00206 
00207   // find the RBX indices
00208   std::vector<int> rbxindices;
00209   HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
00210   for(std::vector<int>::const_iterator it=rbxindices.begin(); it!=rbxindices.end(); ++it)
00211     vec.push_back(findRBX(*it));
00212 
00213   return;
00214 }
00215 
00216 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::const_iterator>& vec) const
00217 {
00218   // clear the vector
00219   vec.clear();
00220 
00221   // check if the tower corresponds to a valid HPD/RBX
00222   if(!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi())) return;
00223 
00224   // find the RBX indices
00225   std::vector<int> rbxindices;
00226   HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
00227   for(std::vector<int>::const_iterator it=rbxindices.begin(); it!=rbxindices.end(); ++it)
00228     vec.push_back(findRBX(*it));
00229 
00230   return;
00231 }