Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:41

0001 //
0002 // HcalNoiseRBXArray.cc
0003 //
0004 //   description: implementation of the HcalNoiseRBXArray
0005 //
0006 //   author: J.P. Chou, Brown
0007 //
0008 //
0009 
0010 #include "RecoMET/METAlgorithms/interface/HcalNoiseRBXArray.h"
0011 
0012 using namespace reco;
0013 
0014 // constructor sets the idnumbers for the rbx's and the hpd's
0015 HcalNoiseRBXArray::HcalNoiseRBXArray() {
0016   for (unsigned int i = 0; i < size(); i++) {
0017     HcalNoiseRBX& rbx = at(i);
0018 
0019     // set the rbxnumber here
0020     rbx.idnumber_ = i;
0021 
0022     // set the hpdnumber here
0023     std::array<int, HcalHPDRBXMap::NUM_HPDS_PER_RBX> hpdindices;
0024     HcalHPDRBXMap::indicesHPDfromRBX(i, hpdindices);
0025     for (int j = 0; j < HcalHPDRBXMap::NUM_HPDS_PER_RBX; j++) {
0026       rbx.hpds_[j].idnumber_ = hpdindices[j];
0027     }
0028   }
0029 }
0030 
0031 HcalNoiseRBXArray::~HcalNoiseRBXArray() {}
0032 
0033 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::endHPD(void) const {
0034   // the choice of which rbx to use is arbitrary,
0035   // as long as we're consistent
0036   return at(0).hpds_.end();
0037 }
0038 
0039 // code here should be same as above (modulo 'const'ness)
0040 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::endHPD(void) {
0041   // the choice of which rbx to use is arbitrary,
0042   // as long as we're consistent
0043   return at(0).hpds_.end();
0044 }
0045 
0046 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(int hpdindex) {
0047   // if the hpdindex is invalid
0048   if (!HcalHPDRBXMap::isValidHPD(hpdindex))
0049     return endHPD();
0050 
0051   int rbxindex = HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
0052 
0053   // find the HPD in the RBX
0054   HcalNoiseRBX& rbx = at(rbxindex);
0055   for (std::vector<HcalNoiseHPD>::iterator it = rbx.hpds_.begin(); it != rbx.hpds_.end(); ++it) {
0056     if (it->idnumber_ == hpdindex)
0057       return it;
0058   }
0059 
0060   // if we're here, this is a bug
0061   throw edm::Exception(edm::errors::LogicError)
0062       << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID().  This is a bug.\n";
0063   return endHPD();
0064 }
0065 
0066 // code here should be same as above (modulo 'const'ness)
0067 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(int hpdindex) const {
0068   // if the hpdindex is invalid
0069   if (!HcalHPDRBXMap::isValidHPD(hpdindex))
0070     return endHPD();
0071 
0072   int rbxindex = HcalHPDRBXMap::indexRBXfromHPD(hpdindex);
0073 
0074   // find the HPD in the RBX
0075   const HcalNoiseRBX& rbx = at(rbxindex);
0076   for (std::vector<HcalNoiseHPD>::const_iterator it = rbx.hpds_.begin(); it != rbx.hpds_.end(); ++it) {
0077     if (it->idnumber_ == hpdindex)
0078       return it;
0079   }
0080 
0081   // if we're here, this is a bug
0082   throw edm::Exception(edm::errors::LogicError)
0083       << "Could not find hpdindex " << hpdindex << " in HcalNoiseRBXArray::findHPDfromDetID().  This is a bug.\n";
0084   return endHPD();
0085 }
0086 
0087 HcalNoiseRBXArray::iterator HcalNoiseRBXArray::findRBX(int rbxindex) {
0088   if (!HcalHPDRBXMap::isValidRBX(rbxindex))
0089     return endRBX();
0090   return begin() + rbxindex;
0091 }
0092 
0093 HcalNoiseRBXArray::const_iterator HcalNoiseRBXArray::findRBX(int rbxindex) const {
0094   if (!HcalHPDRBXMap::isValidRBX(rbxindex))
0095     return endRBX();
0096   return begin() + rbxindex;
0097 }
0098 
0099 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(const HcalDetId& id) {
0100   if (!HcalHPDRBXMap::isValid(id))
0101     return endHPD();
0102   return findHPD(HcalHPDRBXMap::indexHPD(id));
0103 }
0104 
0105 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(const HcalDetId& id) const {
0106   if (!HcalHPDRBXMap::isValid(id))
0107     return endHPD();
0108   return findHPD(HcalHPDRBXMap::indexHPD(id));
0109 }
0110 
0111 HcalNoiseRBXArray::iterator HcalNoiseRBXArray::findRBX(const HcalDetId& id) {
0112   if (!HcalHPDRBXMap::isValid(id))
0113     return endRBX();
0114   return findRBX(HcalHPDRBXMap::indexRBX(id));
0115 }
0116 
0117 HcalNoiseRBXArray::const_iterator HcalNoiseRBXArray::findRBX(const HcalDetId& id) const {
0118   if (!HcalHPDRBXMap::isValid(id))
0119     return endRBX();
0120   return findRBX(HcalHPDRBXMap::indexRBX(id));
0121 }
0122 
0123 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(const HBHEDataFrame& f) { return findHPD(f.id()); }
0124 
0125 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(const HBHEDataFrame& f) const {
0126   return findHPD(f.id());
0127 }
0128 
0129 HcalNoiseRBXArray::iterator HcalNoiseRBXArray::findRBX(const HBHEDataFrame& f) { return findRBX(f.id()); }
0130 
0131 HcalNoiseRBXArray::const_iterator HcalNoiseRBXArray::findRBX(const HBHEDataFrame& f) const { return findRBX(f.id()); }
0132 
0133 std::vector<HcalNoiseHPD>::iterator HcalNoiseRBXArray::findHPD(const HBHERecHit& h) { return findHPD(h.id()); }
0134 
0135 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBXArray::findHPD(const HBHERecHit& h) const {
0136   return findHPD(h.id());
0137 }
0138 
0139 HcalNoiseRBXArray::iterator HcalNoiseRBXArray::findRBX(const HBHERecHit& h) { return findRBX(h.id()); }
0140 
0141 HcalNoiseRBXArray::const_iterator HcalNoiseRBXArray::findRBX(const HBHERecHit& h) const { return findRBX(h.id()); }
0142 
0143 void HcalNoiseRBXArray::findHPD(const CaloTower& tower,
0144                                 std::vector<std::vector<HcalNoiseHPD>::const_iterator>& vec) const {
0145   // clear the vector
0146   vec.clear();
0147 
0148   // check if the tower corresponds to a valid HPD/RBX
0149   if (!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi()))
0150     return;
0151 
0152   // find the HPD indices
0153   std::vector<int> hpdindices;
0154   HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
0155   for (std::vector<int>::const_iterator it = hpdindices.begin(); it != hpdindices.end(); ++it)
0156     vec.push_back(findHPD(*it));
0157 
0158   return;
0159 }
0160 
0161 void HcalNoiseRBXArray::findHPD(const CaloTower& tower, std::vector<std::vector<HcalNoiseHPD>::iterator>& vec) {
0162   // clear the vector
0163   vec.clear();
0164 
0165   // check if the tower corresponds to a valid HPD/RBX
0166   if (!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi()))
0167     return;
0168 
0169   // find the HPD indices
0170   std::vector<int> hpdindices;
0171   HcalHPDRBXMap::indexHPDfromEtaPhi(tower.ieta(), tower.iphi(), hpdindices);
0172   for (std::vector<int>::const_iterator it = hpdindices.begin(); it != hpdindices.end(); ++it)
0173     vec.push_back(findHPD(*it));
0174 
0175   return;
0176 }
0177 
0178 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::iterator>& vec) {
0179   // clear the vector
0180   vec.clear();
0181 
0182   // check if the tower corresponds to a valid HPD/RBX
0183   if (!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi()))
0184     return;
0185 
0186   // find the RBX indices
0187   std::vector<int> rbxindices;
0188   HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
0189   for (std::vector<int>::const_iterator it = rbxindices.begin(); it != rbxindices.end(); ++it)
0190     vec.push_back(findRBX(*it));
0191 
0192   return;
0193 }
0194 
0195 void HcalNoiseRBXArray::findRBX(const CaloTower& tower, std::vector<HcalNoiseRBXArray::const_iterator>& vec) const {
0196   // clear the vector
0197   vec.clear();
0198 
0199   // check if the tower corresponds to a valid HPD/RBX
0200   if (!HcalHPDRBXMap::isValid(tower.ieta(), tower.iphi()))
0201     return;
0202 
0203   // find the RBX indices
0204   std::vector<int> rbxindices;
0205   HcalHPDRBXMap::indexRBXfromEtaPhi(tower.ieta(), tower.iphi(), rbxindices);
0206   for (std::vector<int>::const_iterator it = rbxindices.begin(); it != rbxindices.end(); ++it)
0207     vec.push_back(findRBX(*it));
0208 
0209   return;
0210 }