Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:07

0001 //
0002 // HcalNoiseRBX.cc
0003 //
0004 //   description: container class of RBX information for studying the HCAL Noise
0005 //
0006 //   author: J.P. Chou, Brown
0007 //
0008 //
0009 
0010 #include "DataFormats/METReco/interface/HcalNoiseRBX.h"
0011 
0012 using namespace reco;
0013 
0014 // default constructor
0015 HcalNoiseRBX::HcalNoiseRBX() : idnumber_(0), hpds_(4), allCharge_(HBHEDataFrame::MAXSAMPLES, 0.0) {}
0016 
0017 // destructor
0018 HcalNoiseRBX::~HcalNoiseRBX() {}
0019 
0020 // accessors
0021 int HcalNoiseRBX::idnumber(void) const { return idnumber_; }
0022 
0023 const std::vector<HcalNoiseHPD> HcalNoiseRBX::HPDs(void) const { return hpds_; }
0024 
0025 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBX::maxHPD(double threshold) const {
0026   std::vector<HcalNoiseHPD>::const_iterator maxit = hpds_.end();
0027   double maxenergy = -99999999.;
0028   for (std::vector<HcalNoiseHPD>::const_iterator it = hpds_.begin(); it != hpds_.end(); ++it) {
0029     double tempenergy = it->recHitEnergy();
0030     if (tempenergy > maxenergy) {
0031       maxenergy = tempenergy;
0032       maxit = it;
0033     }
0034   }
0035   return maxit;
0036 }
0037 
0038 const std::vector<float> HcalNoiseRBX::allCharge(void) const { return allCharge_; }
0039 
0040 float HcalNoiseRBX::allChargeTotal(void) const {
0041   float total = 0;
0042   for (unsigned int i = 0; i < allCharge_.size(); i++)
0043     total += allCharge_[i];
0044   return total;
0045 }
0046 
0047 float HcalNoiseRBX::allChargeHighest2TS(unsigned int firstts) const {
0048   float total = 0;
0049   for (unsigned int i = firstts; i < firstts + 2 && !allCharge_.empty(); i++)
0050     total += allCharge_[i];
0051   return total;
0052 }
0053 
0054 float HcalNoiseRBX::allChargeHighest3TS(unsigned int firstts) const {
0055   float total = 0;
0056   for (unsigned int i = firstts; i < firstts + 3 && !allCharge_.empty(); i++)
0057     total += allCharge_[i];
0058   return total;
0059 }
0060 
0061 int HcalNoiseRBX::totalZeros(void) const {
0062   int tot = 0;
0063   for (unsigned int i = 0; i < hpds_.size(); i++)
0064     tot += hpds_[i].totalZeros();
0065   return tot;
0066 }
0067 
0068 int HcalNoiseRBX::maxZeros(void) const {
0069   int max = 0;
0070   for (unsigned int i = 0; i < hpds_.size(); i++)
0071     if (hpds_[i].maxZeros() > max)
0072       max = hpds_[i].maxZeros();
0073   return max;
0074 }
0075 
0076 double HcalNoiseRBX::recHitEnergy(double threshold) const {
0077   double total = 0;
0078   for (unsigned int i = 0; i < hpds_.size(); i++)
0079     total += hpds_[i].recHitEnergy(threshold);
0080   return total;
0081 }
0082 
0083 double HcalNoiseRBX::recHitEnergyFailR45(double threshold) const {
0084   double total = 0;
0085   for (unsigned int i = 0; i < hpds_.size(); i++)
0086     total += hpds_[i].recHitEnergyFailR45(threshold);
0087   return total;
0088 }
0089 
0090 double HcalNoiseRBX::minRecHitTime(double threshold) const {
0091   double mintime = 9999999.;
0092   for (unsigned int i = 0; i < hpds_.size(); i++) {
0093     double temptime = hpds_[i].minRecHitTime(threshold);
0094     if (temptime < mintime)
0095       mintime = temptime;
0096   }
0097   return mintime;
0098 }
0099 
0100 double HcalNoiseRBX::maxRecHitTime(double threshold) const {
0101   double maxtime = -9999999.;
0102   for (unsigned int i = 0; i < hpds_.size(); i++) {
0103     double temptime = hpds_[i].maxRecHitTime(threshold);
0104     if (temptime > maxtime)
0105       maxtime = temptime;
0106   }
0107   return maxtime;
0108 }
0109 
0110 int HcalNoiseRBX::numRecHits(double threshold) const {
0111   int total = 0;
0112   for (unsigned int i = 0; i < hpds_.size(); i++)
0113     total += hpds_[i].numRecHits(threshold);
0114   return total;
0115 }
0116 
0117 int HcalNoiseRBX::numRecHitsFailR45(double threshold) const {
0118   int total = 0;
0119   for (unsigned int i = 0; i < hpds_.size(); i++)
0120     total += hpds_[i].numRecHitsFailR45(threshold);
0121   return total;
0122 }
0123 
0124 double HcalNoiseRBX::caloTowerHadE(void) const {
0125   double h = 0;
0126   towerset_t twrs;
0127   uniqueTowers(twrs);
0128   for (towerset_t::const_iterator it = twrs.begin(); it != twrs.end(); ++it) {
0129     h += it->hadEnergy();
0130   }
0131   return h;
0132 }
0133 
0134 double HcalNoiseRBX::caloTowerEmE(void) const {
0135   double e = 0;
0136   towerset_t twrs;
0137   uniqueTowers(twrs);
0138   for (towerset_t::const_iterator it = twrs.begin(); it != twrs.end(); ++it) {
0139     e += it->emEnergy();
0140   }
0141   return e;
0142 }
0143 
0144 double HcalNoiseRBX::caloTowerTotalE(void) const {
0145   double e = 0;
0146   towerset_t twrs;
0147   uniqueTowers(twrs);
0148   for (towerset_t::const_iterator it = twrs.begin(); it != twrs.end(); ++it) {
0149     e += it->hadEnergy() + it->emEnergy();
0150   }
0151   return e;
0152 }
0153 
0154 double HcalNoiseRBX::caloTowerEmFraction(void) const {
0155   double e = 0, h = 0;
0156   towerset_t twrs;
0157   uniqueTowers(twrs);
0158   for (towerset_t::const_iterator it = twrs.begin(); it != twrs.end(); ++it) {
0159     h += it->hadEnergy();
0160     e += it->emEnergy();
0161   }
0162   return (e + h) == 0 ? 999 : e / (e + h);
0163 }
0164 
0165 void HcalNoiseRBX::uniqueTowers(towerset_t& twrs_) const {
0166   twrs_.clear();
0167   for (std::vector<HcalNoiseHPD>::const_iterator it1 = hpds_.begin(); it1 != hpds_.end(); ++it1) {
0168     edm::RefVector<CaloTowerCollection> twrsref = it1->caloTowers();
0169     for (edm::RefVector<CaloTowerCollection>::const_iterator it2 = twrsref.begin(); it2 != twrsref.end(); ++it2) {
0170       CaloTower twr = **it2;
0171       twrs_.insert(twr);
0172     }
0173   }
0174   return;
0175 }