#include <RecoLocalCalo/EcalRecProducers/interface/EcalRecHitProducer.h>
Public Member Functions | |
EcalRecHitProducer (const edm::ParameterSet &ps) | |
virtual void | produce (edm::Event &evt, const edm::EventSetup &es) |
~EcalRecHitProducer () | |
Private Attributes | |
EcalRecHitAbsAlgo * | EBalgo_ |
std::string | EBrechitCollection_ |
edm::InputTag | EBuncalibRecHitCollection_ |
EcalRecHitAbsAlgo * | EEalgo_ |
std::string | EErechitCollection_ |
edm::InputTag | EEuncalibRecHitCollection_ |
std::vector< int > | v_chstatus_ |
Definition at line 21 of file EcalRecHitProducer.h.
EcalRecHitProducer::EcalRecHitProducer | ( | const edm::ParameterSet & | ps | ) | [explicit] |
Definition at line 40 of file EcalRecHitProducer.cc.
References EBalgo_, EBrechitCollection_, EBuncalibRecHitCollection_, EEalgo_, EErechitCollection_, EEuncalibRecHitCollection_, edm::ParameterSet::getParameter(), and v_chstatus_.
00040 { 00041 00042 EBuncalibRecHitCollection_ = ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"); 00043 EEuncalibRecHitCollection_ = ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"); 00044 EBrechitCollection_ = ps.getParameter<std::string>("EBrechitCollection"); 00045 EErechitCollection_ = ps.getParameter<std::string>("EErechitCollection"); 00046 // nMaxPrintout_ = ps.getUntrackedParameter<int>("nMaxPrintout",10); 00047 00048 EBalgo_ = new EcalRecHitSimpleAlgo(); 00049 EEalgo_ = new EcalRecHitSimpleAlgo(); 00050 00051 produces< EBRecHitCollection >(EBrechitCollection_); 00052 produces< EERecHitCollection >(EErechitCollection_); 00053 00054 v_chstatus_ = ps.getParameter<std::vector<int> >("ChannelStatusToBeExcluded"); 00055 // nEvt_ = 0; // reset local event counter 00056 }
EcalRecHitProducer::~EcalRecHitProducer | ( | ) |
void EcalRecHitProducer::produce | ( | edm::Event & | evt, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 66 of file EcalRecHitProducer.cc.
References edm::SortedCollection< T, SORT >::begin(), EBalgo_, EBrechitCollection_, EBuncalibRecHitCollection_, EEalgo_, EErechitCollection_, EEuncalibRecHitCollection_, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), find(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalADCToGeVConstant::getEBValue(), EcalADCToGeVConstant::getEEValue(), EcalCondObjectContainer< T >::getMap(), EcalChannelStatusCode::getStatusCode(), edm::InputTag::instance(), it, edm::InputTag::label(), LogDebug, EcalRecHitAbsAlgo::makeRecHit(), edm::ESHandle< T >::product(), edm::Event::put(), res, EcalRecHitAbsAlgo::setADCToGeVConstant(), edm::SortedCollection< T, SORT >::size(), edm::Event::time(), and v_chstatus_.
00066 { 00067 00068 using namespace edm; 00069 00070 // nEvt_++; 00071 00072 Handle< EBUncalibratedRecHitCollection > pEBUncalibRecHits; 00073 Handle< EEUncalibratedRecHitCollection > pEEUncalibRecHits; 00074 00075 const EBUncalibratedRecHitCollection* EBuncalibRecHits = 0; 00076 const EEUncalibratedRecHitCollection* EEuncalibRecHits = 0; 00077 00078 if ( EBuncalibRecHitCollection_.label() != "" && EBuncalibRecHitCollection_.instance() != "" ) { 00079 evt.getByLabel( EBuncalibRecHitCollection_, pEBUncalibRecHits); 00080 if ( pEBUncalibRecHits.isValid() ) { 00081 EBuncalibRecHits = pEBUncalibRecHits.product(); // get a ptr to the product 00082 #ifdef DEBUG 00083 LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << EBuncalibRecHits->size(); 00084 #endif 00085 } else { 00086 edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBuncalibRecHitCollection_; 00087 } 00088 } 00089 00090 if ( EEuncalibRecHitCollection_.label() != "" && EEuncalibRecHitCollection_.instance() != "" ) { 00091 evt.getByLabel( EEuncalibRecHitCollection_, pEEUncalibRecHits); 00092 if ( pEEUncalibRecHits.isValid() ) { 00093 EEuncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product 00094 #ifdef DEBUG 00095 LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << EEuncalibRecHits->size(); 00096 #endif 00097 } else { 00098 edm::LogError("EcalRecHitError") << "Error! can't get the product " << EEuncalibRecHitCollection_; 00099 } 00100 } 00101 00102 // collection of rechits to put in the event 00103 std::auto_ptr< EBRecHitCollection > EBrechits( new EBRecHitCollection ); 00104 std::auto_ptr< EERecHitCollection > EErechits( new EERecHitCollection ); 00105 00106 // now fetch all conditions we nEEd to make rechits 00107 edm::ESHandle<EcalADCToGeVConstant> pAgc; 00108 es.get<EcalADCToGeVConstantRcd>().get(pAgc); 00109 const EcalADCToGeVConstant* agc = pAgc.product(); 00110 // 00111 // use this value in the algorithm 00112 EBalgo_->setADCToGeVConstant(float(agc->getEBValue())); 00113 EEalgo_->setADCToGeVConstant(float(agc->getEEValue())); 00114 // Intercalib constants 00115 edm::ESHandle<EcalIntercalibConstants> pIcal; 00116 es.get<EcalIntercalibConstantsRcd>().get(pIcal); 00117 const EcalIntercalibConstants* ical = pIcal.product(); 00118 const EcalIntercalibConstantMap& icalMap=ical->getMap(); 00119 #ifdef DEBUG 00120 LogDebug("EcalRecHitDebug") << "Global EB ADC->GeV scale: " << agc->getEBValue() << " GeV/ADC count" ; 00121 #endif 00122 // ADC -> GeV Scale 00123 00124 edm::ESHandle<EcalLaserDbService> pLaser; 00125 es.get<EcalLaserDbRecord>().get( pLaser ); 00126 00127 // channel status map 00128 edm::ESHandle<EcalChannelStatus> pChStatus; 00129 es.get<EcalChannelStatusRcd>().get( pChStatus ); 00130 const EcalChannelStatus* chStatus = pChStatus.product(); 00131 00132 if (EBuncalibRecHits) 00133 { 00134 00135 // loop over uncalibrated rechits to make calibrated ones 00136 for(EBUncalibratedRecHitCollection::const_iterator it = EBuncalibRecHits->begin(); it != EBuncalibRecHits->end(); ++it) { 00137 00138 // check if status flag is valid -- FIXME: specialize flags 00139 EcalChannelStatusMap::const_iterator chit = chStatus->find(it->id()); 00140 EcalChannelStatusCode chStatusCode = 1; 00141 if ( chit != chStatus->end() ) { 00142 chStatusCode = *chit; 00143 } else { 00144 edm::LogError("EcalRecHitError") << "No channel status found for xtal " << EBDetId(it->id()) << "! something wrong with EcalChannelStatus in your DB? "; 00145 } 00146 if ( v_chstatus_.size() > 0) { 00147 std::vector<int>::const_iterator res = std::find( v_chstatus_.begin(), v_chstatus_.end(), chStatusCode.getStatusCode() ); 00148 if ( res != v_chstatus_.end() ) { 00149 continue; 00150 } 00151 } 00152 00153 // find intercalib constant for this xtal 00154 EcalIntercalibConstantMap::const_iterator icalit=icalMap.find(it->id()); 00155 EcalIntercalibConstant icalconst = 1; 00156 if( icalit!=icalMap.end() ){ 00157 icalconst = (*icalit); 00158 // LogDebug("EcalRecHitDebug") << "Found intercalib for xtal " << EBDetId(it->id()).ic() << " " << icalconst ; 00159 } else { 00160 edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EBDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? " ; 00161 } 00162 // get laser coefficient 00163 float lasercalib = pLaser->getLaserCorrection( EBDetId(it->id()), evt.time() ); 00164 00165 // make the rechit and put in the output collection 00166 // must implement op= for EcalRecHit 00167 EcalRecHit aHit( EBalgo_->makeRecHit(*it, icalconst * lasercalib) ); 00168 EBrechits->push_back( aHit ); 00169 00170 #ifdef DEBUG 00171 if(it->amplitude()>0.) 00172 { 00173 LogDebug("EcalRecHitDebug") << "processed UncalibRecHit with rawId: " 00174 << it->id().rawId() << "\n" 00175 << "uncalib rechit amplitude: " << it->amplitude() 00176 << " calib rechit energy: " << aHit.energy() 00177 ; 00178 } 00179 #endif 00180 } 00181 } 00182 00183 if (EEuncalibRecHits) 00184 { 00185 // loop over uncalibrated rechits to make calibrated ones 00186 for(EEUncalibratedRecHitCollection::const_iterator it = EEuncalibRecHits->begin(); it != EEuncalibRecHits->end(); ++it) { 00187 00188 // check if status flag is valid -- FIXME: specialize flags 00189 EcalChannelStatusMap::const_iterator chit = chStatus->find(it->id()); 00190 EcalChannelStatusCode chStatusCode = 1; 00191 if ( chit != chStatus->end() ) { 00192 chStatusCode = *chit; 00193 } else { 00194 edm::LogError("EcalRecHitError") << "No channel status found for xtal " << EBDetId(it->id()) << "! something wrong with EcalChannelStatus in your DB? "; 00195 } 00196 if ( v_chstatus_.size() > 0) { 00197 std::vector<int>::const_iterator res = std::find( v_chstatus_.begin(), v_chstatus_.end(), chStatusCode.getStatusCode() ); 00198 if ( res != v_chstatus_.end() ) { 00199 continue; 00200 } 00201 } 00202 00203 // find intercalib constant for this xtal 00204 EcalIntercalibConstantMap::const_iterator icalit=icalMap.find(it->id()); 00205 EcalIntercalibConstant icalconst = 1; 00206 if( icalit!=icalMap.end() ){ 00207 icalconst = (*icalit); 00208 // LogDebug("EcalRecHitDebug") << "Found intercalib for xtal " << EEDetId(it->id()).ic() << " " << icalconst ; 00209 } else { 00210 edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EEDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? " 00211 ; 00212 } 00213 // get laser coefficient 00214 float lasercalib = pLaser->getLaserCorrection( EEDetId(it->id()), evt.time() ); 00215 00216 // make the rechit and put in the output collection 00217 // must implement op= for EcalRecHit 00218 EcalRecHit aHit( EEalgo_->makeRecHit(*it, icalconst * lasercalib) ); 00219 EErechits->push_back( aHit ); 00220 00221 #ifdef DEBUG 00222 if(it->amplitude()>0.) 00223 { 00224 LogDebug("EcalRecHitDebug") << "processed UncalibRecHit with rawId: " 00225 << it->id().rawId() << "\n" 00226 << "uncalib rechit amplitude: " << it->amplitude() 00227 << " calib rechit energy: " << aHit.energy() 00228 ; 00229 } 00230 #endif 00231 } 00232 } 00233 // put the collection of recunstructed hits in the event 00234 LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << EBrechits->size() 00235 ; 00236 LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << EErechits->size() 00237 ; 00238 00239 evt.put( EBrechits, EBrechitCollection_ ); 00240 evt.put( EErechits, EErechitCollection_ ); 00241 } //produce()
EcalRecHitAbsAlgo* EcalRecHitProducer::EBalgo_ [private] |
Definition at line 35 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), produce(), and ~EcalRecHitProducer().
std::string EcalRecHitProducer::EBrechitCollection_ [private] |
Definition at line 32 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), and produce().
Definition at line 30 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), and produce().
EcalRecHitAbsAlgo* EcalRecHitProducer::EEalgo_ [private] |
Definition at line 36 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), produce(), and ~EcalRecHitProducer().
std::string EcalRecHitProducer::EErechitCollection_ [private] |
Definition at line 33 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), and produce().
Definition at line 31 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), and produce().
std::vector<int> EcalRecHitProducer::v_chstatus_ [private] |
Definition at line 38 of file EcalRecHitProducer.h.
Referenced by EcalRecHitProducer(), and produce().