CMS 3D CMS Logo

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