CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DataFormats/METReco/src/HcalNoiseRBX.cc

Go to the documentation of this file.
00001 //
00002 // HcalNoiseRBX.cc
00003 //
00004 //   description: container class of RBX information for studying the HCAL Noise
00005 //
00006 //   author: J.P. Chou, Brown
00007 //
00008 //
00009 
00010 #include "DataFormats/METReco/interface/HcalNoiseRBX.h"
00011 
00012 
00013 using namespace reco;
00014 
00015 // default constructor
00016 HcalNoiseRBX::HcalNoiseRBX() :
00017   idnumber_(0), hpds_(4),
00018   allCharge_(HBHEDataFrame::MAXSAMPLES, 0.0)
00019 {
00020 }
00021 
00022 // destructor
00023 HcalNoiseRBX::~HcalNoiseRBX()
00024 {
00025 }
00026 
00027 // accessors
00028 int HcalNoiseRBX::idnumber(void) const
00029 {
00030   return idnumber_;
00031 }
00032 
00033 const std::vector<HcalNoiseHPD> HcalNoiseRBX::HPDs(void) const
00034 {
00035   return hpds_;
00036 }
00037 
00038 std::vector<HcalNoiseHPD>::const_iterator HcalNoiseRBX::maxHPD(double threshold) const
00039 {
00040   std::vector<HcalNoiseHPD>::const_iterator maxit=hpds_.end();
00041   double maxenergy=-99999999.;
00042   for(std::vector<HcalNoiseHPD>::const_iterator it=hpds_.begin(); it!=hpds_.end(); ++it) {
00043     double tempenergy=it->recHitEnergy();
00044     if(tempenergy>maxenergy) {
00045       maxenergy=tempenergy;
00046       maxit=it;
00047     }
00048   }
00049   return maxit;
00050 }
00051 
00052 const std::vector<float> HcalNoiseRBX::allCharge(void) const
00053 {
00054   return allCharge_;
00055 }
00056 
00057 float HcalNoiseRBX::allChargeTotal(void) const
00058 {
00059   float total=0;
00060   for(unsigned int i=0; i<allCharge_.size(); i++)
00061     total += allCharge_[i];
00062   return total;
00063 }
00064   
00065 float HcalNoiseRBX::allChargeHighest2TS(unsigned int firstts) const
00066 {
00067   float total=0;
00068   for(unsigned int i=firstts; i<firstts+2 && allCharge_.size(); i++)
00069     total += allCharge_[i];
00070   return total;
00071 }
00072   
00073 float HcalNoiseRBX::allChargeHighest3TS(unsigned int firstts) const
00074 {
00075   float total=0;
00076   for(unsigned int i=firstts; i<firstts+3 && allCharge_.size(); i++)
00077     total += allCharge_[i];
00078   return total;
00079 }
00080   
00081 
00082 int HcalNoiseRBX::totalZeros(void) const
00083 {
00084   int tot=0;
00085   for(unsigned int i=0; i<hpds_.size(); i++)
00086     tot += hpds_[i].totalZeros();
00087   return tot;
00088 }
00089 
00090 int HcalNoiseRBX::maxZeros(void) const
00091 {
00092   int max=0;
00093   for(unsigned int i=0; i<hpds_.size(); i++)
00094     if(hpds_[i].maxZeros()>max)
00095       max=hpds_[i].maxZeros();
00096   return max;
00097 }
00098 
00099 double HcalNoiseRBX::recHitEnergy(double threshold) const
00100 {
00101   double total=0;
00102   for(unsigned int i=0; i<hpds_.size(); i++)
00103     total += hpds_[i].recHitEnergy(threshold);
00104   return total;
00105 }
00106 
00107 double HcalNoiseRBX::minRecHitTime(double threshold) const
00108 {
00109   double mintime=9999999.;
00110   for(unsigned int i=0; i<hpds_.size(); i++) {
00111     double temptime=hpds_[i].minRecHitTime(threshold);
00112     if(temptime<mintime) mintime=temptime;
00113   }
00114   return mintime;
00115 }
00116 
00117 double HcalNoiseRBX::maxRecHitTime(double threshold) const
00118 {
00119   double maxtime=-9999999.;
00120   for(unsigned int i=0; i<hpds_.size(); i++) {
00121     double temptime=hpds_[i].maxRecHitTime(threshold);
00122     if(temptime>maxtime) maxtime=temptime;
00123   }
00124   return maxtime;
00125 }
00126 
00127 int HcalNoiseRBX::numRecHits(double threshold) const
00128 {
00129   int total=0;
00130   for(unsigned int i=0; i<hpds_.size(); i++)
00131     total += hpds_[i].numRecHits(threshold);
00132   return total;
00133 }
00134 
00135 double HcalNoiseRBX::caloTowerHadE(void) const
00136 {
00137   double h=0;
00138   towerset_t twrs;
00139   uniqueTowers(twrs);
00140   for(towerset_t::const_iterator it=twrs.begin(); it!=twrs.end(); ++it) {
00141     h += it->hadEnergy();
00142   }
00143   return h;
00144 }
00145 
00146 double HcalNoiseRBX::caloTowerEmE(void) const
00147 {
00148   double e=0;
00149   towerset_t twrs;
00150   uniqueTowers(twrs);
00151   for(towerset_t::const_iterator it=twrs.begin(); it!=twrs.end(); ++it) {
00152     e += it->emEnergy();
00153   }
00154   return e;
00155 }
00156 
00157 double HcalNoiseRBX::caloTowerTotalE(void) const
00158 {
00159   double e=0;
00160   towerset_t twrs;
00161   uniqueTowers(twrs);
00162   for(towerset_t::const_iterator it=twrs.begin(); it!=twrs.end(); ++it) {
00163     e += it->hadEnergy() + it->emEnergy();
00164   }
00165   return e;
00166 }
00167 
00168 double HcalNoiseRBX::caloTowerEmFraction(void) const
00169 {
00170   double e=0, h=0;
00171   towerset_t twrs;
00172   uniqueTowers(twrs);
00173   for(towerset_t::const_iterator it=twrs.begin(); it!=twrs.end(); ++it) {
00174     h += it->hadEnergy();
00175     e += it->emEnergy();
00176   }
00177   return (e+h)==0 ? 999 : e/(e+h);
00178 }
00179 
00180 void HcalNoiseRBX::uniqueTowers(towerset_t& twrs_) const
00181 {
00182   twrs_.clear();
00183   for(std::vector<HcalNoiseHPD>::const_iterator it1=hpds_.begin(); it1!=hpds_.end(); ++it1) {
00184     edm::RefVector<CaloTowerCollection> twrsref=it1->caloTowers();
00185     for(edm::RefVector<CaloTowerCollection>::const_iterator it2=twrsref.begin(); it2!=twrsref.end(); ++it2) {
00186       CaloTower twr=**it2;
00187       twrs_.insert(twr);
00188     }
00189   }
00190   return;
00191 }