Go to the documentation of this file.00001 #include "RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerRatio.h"
00002
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007
00008 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00009 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00010
00011 EcalUncalibRecHitWorkerRatio::EcalUncalibRecHitWorkerRatio(const edm::ParameterSet&ps) :
00012 EcalUncalibRecHitWorkerBaseClass(ps)
00013 {
00014 EBtimeFitParameters_ = ps.getParameter<std::vector<double> >("EBtimeFitParameters");
00015 EEtimeFitParameters_ = ps.getParameter<std::vector<double> >("EEtimeFitParameters");
00016
00017 EBamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EBamplitudeFitParameters");
00018 EEamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EEamplitudeFitParameters");
00019
00020 EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
00021 EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
00022
00023 EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
00024 EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
00025
00026 EBtimeConstantTerm_ = ps.getParameter<double>("EBtimeConstantTerm");
00027 EEtimeConstantTerm_ = ps.getParameter<double>("EEtimeConstantTerm");
00028 }
00029
00030 void
00031 EcalUncalibRecHitWorkerRatio::set(const edm::EventSetup& es)
00032 {
00033 es.get<EcalGainRatiosRcd>().get(gains);
00034 es.get<EcalPedestalsRcd>().get(peds);
00035
00036 }
00037
00038
00039 bool
00040 EcalUncalibRecHitWorkerRatio::run( const edm::Event & evt,
00041 const EcalDigiCollection::const_iterator & itdg,
00042 EcalUncalibratedRecHitCollection & result )
00043 {
00044 DetId detid(itdg->id());
00045
00046 const EcalPedestals::Item * aped = 0;
00047 const EcalMGPAGainRatio * aGain = 0;
00048
00049 if (detid.subdetId()==EcalEndcap) {
00050 unsigned int hashedIndex = EEDetId(detid).hashedIndex();
00051 aped = &peds->endcap(hashedIndex);
00052 aGain = &gains->endcap(hashedIndex);
00053 } else {
00054 unsigned int hashedIndex = EBDetId(detid).hashedIndex();
00055 aped = &peds->barrel(hashedIndex);
00056 aGain = &gains->barrel(hashedIndex);
00057 }
00058
00059 pedVec[0] = aped->mean_x12;
00060 pedVec[1] = aped->mean_x6;
00061 pedVec[2] = aped->mean_x1;
00062 pedRMSVec[0] = aped->rms_x12;
00063 pedRMSVec[1] = aped->rms_x6;
00064 pedRMSVec[2] = aped->rms_x1;
00065 gainRatios[0] = 1.;
00066 gainRatios[1] = aGain->gain12Over6();
00067 gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
00068
00069 float clockToNsConstant = 25.;
00070 EcalUncalibratedRecHit uncalibRecHit;
00071
00072 if (detid.subdetId()==EcalEndcap) {
00073 uncalibMaker_endcap_.init(*itdg, pedVec, pedRMSVec, gainRatios);
00074 uncalibMaker_endcap_.computeTime(EEtimeFitParameters_,
00075 EEtimeFitLimits_,
00076 EEamplitudeFitParameters_ );
00077 uncalibMaker_endcap_.computeAmplitude(EEamplitudeFitParameters_);
00078 EcalUncalibRecHitRatioMethodAlgo<EEDataFrame>::CalculatedRecHit crh =
00079 uncalibMaker_endcap_.getCalculatedRecHit();
00080 uncalibRecHit.setAmplitude( crh.amplitudeMax );
00081 uncalibRecHit.setJitter( crh.timeMax - 5 );
00082 uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) +
00083 std::pow(EEtimeConstantTerm_,2)/
00084 std::pow(clockToNsConstant,2)) );
00085
00086 } else {
00087
00088 uncalibMaker_barrel_.init(*itdg, pedVec, pedRMSVec, gainRatios);
00089 bool gainSwitch = uncalibMaker_barrel_.fixMGPAslew(*itdg);
00090 uncalibMaker_barrel_.computeTime(EBtimeFitParameters_,
00091 EBtimeFitLimits_,
00092 EBamplitudeFitParameters_ );
00093 uncalibMaker_barrel_.computeAmplitude(EBamplitudeFitParameters_);
00094 EcalUncalibRecHitRatioMethodAlgo<EBDataFrame>::CalculatedRecHit crh =
00095 uncalibMaker_barrel_.getCalculatedRecHit();
00096 uncalibRecHit.setAmplitude( crh.amplitudeMax );
00097 if(gainSwitch){
00098
00099 uncalibRecHit.setJitter( crh.timeMax - 5 - 0.04 );
00100 }else{
00101 uncalibRecHit.setJitter( crh.timeMax - 5);
00102 }
00103 uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) +
00104 std::pow(EBtimeConstantTerm_,2)/
00105 std::pow(clockToNsConstant,2)) );
00106
00107 }
00108 result.push_back(uncalibRecHit);
00109
00110 return true;
00111 }
00112
00113 #include "FWCore/Framework/interface/MakerMacros.h"
00114 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerFactory.h"
00115 DEFINE_EDM_PLUGIN( EcalUncalibRecHitWorkerFactory, EcalUncalibRecHitWorkerRatio, "EcalUncalibRecHitWorkerRatio" );