Go to the documentation of this file.00001 #include "RecoLocalCalo/EcalRecProducers/plugins/EcalRecHitWorkerSimple.h"
00002
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00006 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
00007 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00008 #include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h"
00009 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00010 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
00011 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
00012
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014
00015 EcalRecHitWorkerSimple::EcalRecHitWorkerSimple(const edm::ParameterSet&ps) :
00016 EcalRecHitWorkerBaseClass(ps)
00017 {
00018 rechitMaker_ = new EcalRecHitSimpleAlgo();
00019 v_chstatus_ = ps.getParameter<std::vector<int> >("ChannelStatusToBeExcluded");
00020 v_DB_reco_flags_ = ps.getParameter<std::vector<int> >("flagsMapDBReco");
00021 killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
00022 laserCorrection_ = ps.getParameter<bool>("laserCorrection");
00023 }
00024
00025
00026 void EcalRecHitWorkerSimple::set(const edm::EventSetup& es)
00027 {
00028 es.get<EcalIntercalibConstantsRcd>().get(ical);
00029 es.get<EcalTimeCalibConstantsRcd>().get(itime);
00030 es.get<EcalTimeOffsetConstantRcd>().get(offtime);
00031 es.get<EcalADCToGeVConstantRcd>().get(agc);
00032 es.get<EcalChannelStatusRcd>().get(chStatus);
00033 if ( laserCorrection_ ) es.get<EcalLaserDbRecord>().get(laser);
00034 }
00035
00036
00037 bool
00038 EcalRecHitWorkerSimple::run( const edm::Event & evt,
00039 const EcalUncalibratedRecHit& uncalibRH,
00040 EcalRecHitCollection & result )
00041 {
00042 DetId detid=uncalibRH.id();
00043
00044 EcalChannelStatusMap::const_iterator chit = chStatus->find(detid);
00045 EcalChannelStatusCode chStatusCode = 1;
00046 if ( chit != chStatus->end() ) {
00047 chStatusCode = *chit;
00048 } else {
00049 edm::LogError("EcalRecHitError") << "No channel status found for xtal "
00050 << detid.rawId()
00051 << "! something wrong with EcalChannelStatus in your DB? ";
00052 }
00053 if ( v_chstatus_.size() > 0) {
00054 uint16_t code = chStatusCode.getStatusCode() & 0x001F;
00055 std::vector<int>::const_iterator res = std::find( v_chstatus_.begin(), v_chstatus_.end(), code );
00056 if ( res != v_chstatus_.end() ) {
00057 return false;
00058 }
00059 }
00060
00061
00062
00063
00064 uint32_t recoFlag = 0;
00065 uint16_t statusCode = chStatusCode.getStatusCode() & 0x001F;
00066 if ( statusCode < v_DB_reco_flags_.size() ) {
00067
00068 recoFlag = v_DB_reco_flags_[ statusCode ];
00069 } else {
00070 edm::LogError("EcalRecHitError") << "Flag " << statusCode
00071 << " in DB exceed the allowed range of " << v_DB_reco_flags_.size();
00072 }
00073
00074 float offsetTime = 0;
00075 const EcalIntercalibConstantMap& icalMap = ical->getMap();
00076 if ( detid.subdetId() == EcalEndcap ) {
00077 rechitMaker_->setADCToGeVConstant( float(agc->getEEValue()) );
00078 offsetTime = offtime->getEEValue();
00079 } else {
00080 rechitMaker_->setADCToGeVConstant( float(agc->getEBValue()) );
00081 offsetTime = offtime->getEBValue();
00082 }
00083
00084
00085 EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(detid);
00086 EcalIntercalibConstant icalconst = 1;
00087 if( icalit!=icalMap.end() ) {
00088 icalconst = (*icalit);
00089 } else {
00090 edm::LogError("EcalRecHitError") << "No intercalib const found for xtal "
00091 << detid.rawId()
00092 << "! something wrong with EcalIntercalibConstants in your DB? ";
00093 }
00094
00095
00096 float lasercalib = 1.;
00097 if ( laserCorrection_ ) lasercalib = laser->getLaserCorrection( detid, evt.time());
00098
00099
00100 const EcalTimeCalibConstantMap & itimeMap = itime->getMap();
00101 EcalTimeCalibConstantMap::const_iterator itime = itimeMap.find(detid);
00102 EcalTimeCalibConstant itimeconst = 0;
00103 if( itime!=itimeMap.end() ) {
00104 itimeconst = (*itime);
00105 } else {
00106 edm::LogError("EcalRecHitError") << "No time calib const found for xtal "
00107 << detid.rawId()
00108 << "! something wrong with EcalTimeCalibConstants in your DB? ";
00109 }
00110
00111
00112
00113 if ( recoFlag <= EcalRecHit::kLeadingEdgeRecovered || !killDeadChannels_ ) {
00114 result.push_back(EcalRecHit( rechitMaker_->makeRecHit(uncalibRH, icalconst * lasercalib, (itimeconst + offsetTime), recoFlag) ));
00115 }
00116 return true;
00117 }
00118
00119 #include "FWCore/Framework/interface/MakerMacros.h"
00120 #include "RecoLocalCalo/EcalRecProducers/interface/EcalRecHitWorkerFactory.h"
00121 DEFINE_EDM_PLUGIN( EcalRecHitWorkerFactory, EcalRecHitWorkerSimple, "EcalRecHitWorkerSimple" );