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