Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //
0002 // HcalNoiseHPD.cc
0003 //
0004 //   description: container class of HPD information for analyzing HCAL Noise
0005 //
0006 //   author: J.P. Chou, Brown
0007 //
0008 //
0009 
0010 #include "DataFormats/METReco/interface/HcalNoiseHPD.h"
0011 
0012 using namespace reco;
0013 
0014 // default constructor
0015 HcalNoiseHPD::HcalNoiseHPD()
0016     : idnumber_(0),
0017       totalZeros_(0),
0018       maxZeros_(0),
0019       bigCharge_(HBHEDataFrame::MAXSAMPLES, 0.0),
0020       big5Charge_(HBHEDataFrame::MAXSAMPLES, 0.0) {
0021   // reserve some space, so that there's no reallocation issues
0022   rechits_.reserve(19);
0023   calotowers_.reserve(19);
0024 }
0025 
0026 // destructor
0027 HcalNoiseHPD::~HcalNoiseHPD() {}
0028 
0029 // accessors
0030 int HcalNoiseHPD::idnumber(void) const { return idnumber_; }
0031 
0032 const std::vector<float> HcalNoiseHPD::bigCharge(void) const { return bigCharge_; }
0033 
0034 float HcalNoiseHPD::bigChargeTotal(void) const {
0035   float total = 0;
0036   for (unsigned int i = 0; i < bigCharge_.size(); i++) {
0037     total += bigCharge_[i];
0038   }
0039   return total;
0040 }
0041 
0042 float HcalNoiseHPD::bigChargeHighest2TS(unsigned int firstts) const {
0043   float total = 0;
0044   for (unsigned int i = firstts; i < firstts + 2 && i < bigCharge_.size(); i++)
0045     total += bigCharge_[i];
0046   return total;
0047 }
0048 
0049 float HcalNoiseHPD::bigChargeHighest3TS(unsigned int firstts) const {
0050   float total = 0;
0051   for (unsigned int i = firstts; i < firstts + 3 && i < bigCharge_.size(); i++)
0052     total += bigCharge_[i];
0053   return total;
0054 }
0055 
0056 const std::vector<float> HcalNoiseHPD::big5Charge(void) const { return big5Charge_; }
0057 
0058 float HcalNoiseHPD::big5ChargeTotal(void) const {
0059   float total = 0;
0060   for (unsigned int i = 0; i < big5Charge_.size(); i++) {
0061     total += big5Charge_[i];
0062   }
0063   return total;
0064 }
0065 
0066 float HcalNoiseHPD::big5ChargeHighest2TS(unsigned int firstts) const {
0067   float total = 0;
0068   for (unsigned int i = firstts; i < firstts + 2 && i < big5Charge_.size(); i++)
0069     total += big5Charge_[i];
0070   return total;
0071 }
0072 
0073 float HcalNoiseHPD::big5ChargeHighest3TS(unsigned int firstts) const {
0074   float total = 0;
0075   for (unsigned int i = firstts; i < firstts + 2 && i < big5Charge_.size(); i++)
0076     total += big5Charge_[i];
0077   return total;
0078 }
0079 
0080 int HcalNoiseHPD::totalZeros(void) const { return totalZeros_; }
0081 
0082 int HcalNoiseHPD::maxZeros(void) const { return maxZeros_; }
0083 
0084 const edm::RefVector<HBHERecHitCollection> HcalNoiseHPD::recHits(void) const { return rechits_; }
0085 
0086 float HcalNoiseHPD::recHitEnergy(const float threshold) const {
0087   double total = 0.0;
0088   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it) {
0089     const float energy = (*it)->eraw();
0090     if (energy >= threshold)
0091       total += energy;
0092   }
0093   return total;
0094 }
0095 
0096 float HcalNoiseHPD::recHitEnergyFailR45(const float threshold) const {
0097   double total = 0.0;
0098   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it) {
0099     const float energy = (*it)->eraw();
0100     if ((*it)->flagField(HcalCaloFlagLabels::HBHETS4TS5Noise) && !(*it)->flagField(HcalCaloFlagLabels::HBHEOOTPU))
0101       if (energy >= threshold)
0102         total += energy;
0103   }
0104   return total;
0105 }
0106 
0107 float HcalNoiseHPD::minRecHitTime(const float threshold) const {
0108   float mintime = 9999999;
0109   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it) {
0110     if ((*it)->energy() < threshold)
0111       continue;
0112     float time = (*it)->time();
0113     if (mintime > time)
0114       mintime = time;
0115   }
0116   return mintime;
0117 }
0118 
0119 float HcalNoiseHPD::maxRecHitTime(const float threshold) const {
0120   float maxtime = -9999999;
0121   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it) {
0122     if ((*it)->energy() < threshold)
0123       continue;
0124     float time = (*it)->time();
0125     if (maxtime < time)
0126       maxtime = time;
0127   }
0128   return maxtime;
0129 }
0130 
0131 int HcalNoiseHPD::numRecHits(const float threshold) const {
0132   int count = 0;
0133   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it) {
0134     // Exclude uncollapsed QIE11 channels
0135     if (CaloRecHitAuxSetter::getBit((*it)->auxPhase1(), HBHERecHitAuxSetter::OFF_TDC_TIME) &&
0136         !CaloRecHitAuxSetter::getBit((*it)->auxPhase1(), HBHERecHitAuxSetter::OFF_COMBINED))
0137       continue;
0138     if ((*it)->eraw() >= threshold)
0139       ++count;
0140   }
0141   return count;
0142 }
0143 
0144 int HcalNoiseHPD::numRecHitsFailR45(const float threshold) const {
0145   int count = 0;
0146   for (edm::RefVector<HBHERecHitCollection>::const_iterator it = rechits_.begin(); it != rechits_.end(); ++it)
0147     if ((*it)->flagField(HcalCaloFlagLabels::HBHETS4TS5Noise) && !(*it)->flagField(HcalCaloFlagLabels::HBHEOOTPU))
0148       if ((*it)->eraw() >= threshold)
0149         ++count;
0150   return count;
0151 }
0152 
0153 const edm::RefVector<CaloTowerCollection> HcalNoiseHPD::caloTowers(void) const { return calotowers_; }
0154 
0155 double HcalNoiseHPD::caloTowerHadE(void) const {
0156   double total = 0;
0157   for (edm::RefVector<CaloTowerCollection>::const_iterator it = calotowers_.begin(); it != calotowers_.end(); ++it)
0158     total += (*it)->hadEnergy();
0159   return total;
0160 }
0161 
0162 double HcalNoiseHPD::caloTowerEmE(void) const {
0163   double total = 0;
0164   for (edm::RefVector<CaloTowerCollection>::const_iterator it = calotowers_.begin(); it != calotowers_.end(); ++it)
0165     total += (*it)->emEnergy();
0166   return total;
0167 }
0168 
0169 double HcalNoiseHPD::caloTowerTotalE(void) const {
0170   double total = 0;
0171   for (edm::RefVector<CaloTowerCollection>::const_iterator it = calotowers_.begin(); it != calotowers_.end(); ++it)
0172     total += (*it)->emEnergy() + (*it)->hadEnergy();
0173   return total;
0174 }
0175 
0176 double HcalNoiseHPD::caloTowerEmFraction(void) const {
0177   double h = 0, e = 0;
0178   for (edm::RefVector<CaloTowerCollection>::const_iterator it = calotowers_.begin(); it != calotowers_.end(); ++it) {
0179     e += (*it)->emEnergy();
0180     h += (*it)->hadEnergy();
0181   }
0182   return (e + h) != 0 ? e / (e + h) : 999.;
0183 }