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