CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerRatio.cc

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 
00074           uncalibRecHit = 
00075             uncalibMaker_endcap_.makeRecHit(*itdg,pedVec,pedRMSVec,
00076                                             gainRatios,EEtimeFitParameters_,
00077                                             EEamplitudeFitParameters_,
00078                                             EEtimeFitLimits_);
00079           
00080           EcalUncalibRecHitRatioMethodAlgo<EEDataFrame>::CalculatedRecHit crh =
00081                                   uncalibMaker_endcap_.getCalculatedRecHit();
00082           uncalibRecHit.setAmplitude( crh.amplitudeMax );
00083           uncalibRecHit.setJitter( crh.timeMax - 5 );
00084           uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + 
00085                                         std::pow(EEtimeConstantTerm_,2)/
00086                                         std::pow(clockToNsConstant,2)) );
00087 
00088         } else {
00089  
00090 
00091           bool gainSwitch = uncalibMaker_barrel_.fixMGPAslew(*itdg);
00092 
00093           uncalibRecHit= 
00094             uncalibMaker_barrel_.makeRecHit(*itdg,pedVec,pedRMSVec,
00095                                             gainRatios,EBtimeFitParameters_,
00096                                             EBamplitudeFitParameters_,
00097                                             EBtimeFitLimits_);
00098           
00099           
00100           EcalUncalibRecHitRatioMethodAlgo<EBDataFrame>::CalculatedRecHit crh= 
00101             uncalibMaker_barrel_.getCalculatedRecHit();
00102 
00103           uncalibRecHit.setAmplitude( crh.amplitudeMax );
00104           if(gainSwitch){
00105             // introduce additional 1ns shift
00106             uncalibRecHit.setJitter( crh.timeMax - 5 - 0.04 );
00107           }else{
00108             uncalibRecHit.setJitter( crh.timeMax - 5);
00109           }
00110           uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + 
00111                                         std::pow(EBtimeConstantTerm_,2)/
00112                                         std::pow(clockToNsConstant,2)) );
00113 
00114         }
00115         result.push_back(uncalibRecHit);
00116 
00117         return true;
00118 }
00119 
00120 #include "FWCore/Framework/interface/MakerMacros.h"
00121 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerFactory.h"
00122 DEFINE_EDM_PLUGIN( EcalUncalibRecHitWorkerFactory, EcalUncalibRecHitWorkerRatio, "EcalUncalibRecHitWorkerRatio" );