Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:23

0001 #include "RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerRatio.h"
0002 
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 
0008 #include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
0009 #include <FWCore/ParameterSet/interface/ParameterSetDescription.h>
0010 
0011 EcalUncalibRecHitWorkerRatio::EcalUncalibRecHitWorkerRatio(const edm::ParameterSet& ps, edm::ConsumesCollector& c)
0012     : EcalUncalibRecHitWorkerRunOneDigiBase(ps, c) {
0013   EBtimeFitParameters_ = ps.getParameter<std::vector<double>>("EBtimeFitParameters");
0014   EEtimeFitParameters_ = ps.getParameter<std::vector<double>>("EEtimeFitParameters");
0015 
0016   EBamplitudeFitParameters_ = ps.getParameter<std::vector<double>>("EBamplitudeFitParameters");
0017   EEamplitudeFitParameters_ = ps.getParameter<std::vector<double>>("EEamplitudeFitParameters");
0018 
0019   EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
0020   EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
0021 
0022   EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
0023   EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
0024 
0025   EBtimeConstantTerm_ = ps.getParameter<double>("EBtimeConstantTerm");
0026   EEtimeConstantTerm_ = ps.getParameter<double>("EEtimeConstantTerm");
0027 
0028   pedsToken_ = c.esConsumes<EcalPedestals, EcalPedestalsRcd>();
0029   gainsToken_ = c.esConsumes<EcalGainRatios, EcalGainRatiosRcd>();
0030   sampleMaskToken_ = c.esConsumes<EcalSampleMask, EcalSampleMaskRcd>();
0031 }
0032 
0033 void EcalUncalibRecHitWorkerRatio::set(const edm::EventSetup& es) {
0034   // which of the samples need be used
0035   sampleMaskHand_ = es.getHandle(sampleMaskToken_);
0036 
0037   gains = es.getHandle(gainsToken_);
0038   peds = es.getHandle(pedsToken_);
0039 }
0040 
0041 bool EcalUncalibRecHitWorkerRatio::run(const edm::Event& evt,
0042                                        const EcalDigiCollection::const_iterator& itdg,
0043                                        EcalUncalibratedRecHitCollection& result) {
0044   DetId detid(itdg->id());
0045 
0046   const EcalSampleMask* sampleMask_ = sampleMaskHand_.product();
0047 
0048   const EcalPedestals::Item* aped = nullptr;
0049   const EcalMGPAGainRatio* aGain = nullptr;
0050 
0051   if (detid.subdetId() == EcalEndcap) {
0052     unsigned int hashedIndex = EEDetId(detid).hashedIndex();
0053     aped = &peds->endcap(hashedIndex);
0054     aGain = &gains->endcap(hashedIndex);
0055   } else {
0056     unsigned int hashedIndex = EBDetId(detid).hashedIndex();
0057     aped = &peds->barrel(hashedIndex);
0058     aGain = &gains->barrel(hashedIndex);
0059   }
0060 
0061   pedVec[0] = aped->mean_x12;
0062   pedVec[1] = aped->mean_x6;
0063   pedVec[2] = aped->mean_x1;
0064   pedRMSVec[0] = aped->rms_x12;
0065   pedRMSVec[1] = aped->rms_x6;
0066   pedRMSVec[2] = aped->rms_x1;
0067   gainRatios[0] = 1.;
0068   gainRatios[1] = aGain->gain12Over6();
0069   gainRatios[2] = aGain->gain6Over1() * aGain->gain12Over6();
0070 
0071   float clockToNsConstant = 25.;
0072   EcalUncalibratedRecHit uncalibRecHit;
0073 
0074   if (detid.subdetId() == EcalEndcap) {
0075     uncalibRecHit = uncalibMaker_endcap_.makeRecHit(*itdg,
0076                                                     *sampleMask_,
0077                                                     pedVec,
0078                                                     pedRMSVec,
0079                                                     gainRatios,
0080                                                     EEtimeFitParameters_,
0081                                                     EEamplitudeFitParameters_,
0082                                                     EEtimeFitLimits_);  //GF pass mask here
0083 
0084     EcalUncalibRecHitRatioMethodAlgo<EEDataFrame>::CalculatedRecHit crh = uncalibMaker_endcap_.getCalculatedRecHit();
0085     uncalibRecHit.setAmplitude(crh.amplitudeMax);
0086     uncalibRecHit.setJitter(crh.timeMax - 5);
0087     uncalibRecHit.setJitterError(
0088         std::sqrt(pow(crh.timeError, 2) + std::pow(EEtimeConstantTerm_, 2) / std::pow(clockToNsConstant, 2)));
0089 
0090   } else {
0091     bool gainSwitch = uncalibMaker_barrel_.fixMGPAslew(*itdg);
0092 
0093     uncalibRecHit = uncalibMaker_barrel_.makeRecHit(*itdg,
0094                                                     *sampleMask_,
0095                                                     pedVec,
0096                                                     pedRMSVec,
0097                                                     gainRatios,
0098                                                     EBtimeFitParameters_,
0099                                                     EBamplitudeFitParameters_,
0100                                                     EBtimeFitLimits_);  //GF pass mask here
0101 
0102     EcalUncalibRecHitRatioMethodAlgo<EBDataFrame>::CalculatedRecHit crh = uncalibMaker_barrel_.getCalculatedRecHit();
0103 
0104     uncalibRecHit.setAmplitude(crh.amplitudeMax);
0105     if (gainSwitch) {
0106       // introduce additional 1ns shift
0107       uncalibRecHit.setJitter(crh.timeMax - 5 - 0.04);
0108     } else {
0109       uncalibRecHit.setJitter(crh.timeMax - 5);
0110     }
0111     uncalibRecHit.setJitterError(
0112         std::sqrt(pow(crh.timeError, 2) + std::pow(EBtimeConstantTerm_, 2) / std::pow(clockToNsConstant, 2)));
0113   }
0114   result.push_back(uncalibRecHit);
0115 
0116   return true;
0117 }
0118 
0119 edm::ParameterSetDescription EcalUncalibRecHitWorkerRatio::getAlgoDescription() {
0120   edm::ParameterSetDescription psd;
0121   std::vector<double> dSet1 = {-2.390548, 3.553628, -17.62341, 67.67538, -133.213, 140.7432, -75.41106, 16.20277};
0122   std::vector<double> dSet2 = {-2.015452, 3.130702, -12.3473, 41.88921, -82.83944, 91.01147, -50.35761, 11.05621};
0123 
0124   psd.addNode(edm::ParameterDescription<double>("EEtimeFitLimits_Upper", 1.4, true) and
0125               edm::ParameterDescription<double>("EEtimeConstantTerm", 0.18, true) and
0126               edm::ParameterDescription<double>("EBtimeFitLimits_Lower", 0.2, true) and
0127               edm::ParameterDescription<double>("EBtimeConstantTerm", 0.26, true) and
0128               edm::ParameterDescription<double>("EEtimeFitLimits_Lower", 0.2, true) and
0129               edm::ParameterDescription<std::vector<double>>("EEtimeFitParameters", dSet1, true) and
0130               edm::ParameterDescription<std::vector<double>>("EEamplitudeFitParameters", {1.89, 1.4}, true) and
0131               edm::ParameterDescription<double>("EBtimeFitLimits_Upper", 1.4, true) and
0132               edm::ParameterDescription<std::vector<double>>("EBamplitudeFitParameters", {1.138, 1.652}, true) and
0133               edm::ParameterDescription<std::vector<double>>("EBtimeFitParameters", dSet2, true));
0134 
0135   return psd;
0136 }
0137 
0138 #include "FWCore/Framework/interface/MakerMacros.h"
0139 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerFactory.h"
0140 DEFINE_EDM_PLUGIN(EcalUncalibRecHitWorkerFactory, EcalUncalibRecHitWorkerRatio, "EcalUncalibRecHitWorkerRatio");
0141 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitFillDescriptionWorkerFactory.h"
0142 DEFINE_EDM_PLUGIN(EcalUncalibRecHitFillDescriptionWorkerFactory,
0143                   EcalUncalibRecHitWorkerRatio,
0144                   "EcalUncalibRecHitWorkerRatio");