CMS 3D CMS Logo

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