Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:23

0001 #include "RecoEgamma/EgammaTools/interface/EgammaRegressionContainer.h"
0002 
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/ConsumesCollector.h"
0008 
0009 EgammaRegressionContainer::EgammaRegressionContainer(const edm::ParameterSet& iConfig, edm::ConsumesCollector& cc)
0010     : outputTransformerLowEt_(iConfig.getParameter<double>("rangeMinLowEt"),
0011                               iConfig.getParameter<double>("rangeMaxLowEt")),
0012       outputTransformerHighEt_(iConfig.getParameter<double>("rangeMinHighEt"),
0013                                iConfig.getParameter<double>("rangeMaxHighEt")),
0014       forceHighEnergyTrainingIfSaturated_(iConfig.getParameter<bool>("forceHighEnergyTrainingIfSaturated")),
0015       lowEtHighEtBoundary_(iConfig.getParameter<double>("lowEtHighEtBoundary")),
0016       ebLowEtForestToken_{cc.esConsumes(iConfig.getParameter<edm::ESInputTag>("ebLowEtForestName"))},
0017       ebHighEtForestToken_{cc.esConsumes(iConfig.getParameter<edm::ESInputTag>("ebHighEtForestName"))},
0018       eeLowEtForestToken_{cc.esConsumes(iConfig.getParameter<edm::ESInputTag>("eeLowEtForestName"))},
0019       eeHighEtForestToken_{cc.esConsumes(iConfig.getParameter<edm::ESInputTag>("eeHighEtForestName"))} {}
0020 
0021 edm::ParameterSetDescription EgammaRegressionContainer::makePSetDescription() {
0022   edm::ParameterSetDescription desc;
0023   desc.add<double>("rangeMinLowEt", -1.);
0024   desc.add<double>("rangeMaxLowEt", 3.0);
0025   desc.add<double>("rangeMinHighEt", -1.);
0026   desc.add<double>("rangeMaxHighEt", 3.0);
0027   desc.add<double>("lowEtHighEtBoundary", 50.);
0028   desc.add<bool>("forceHighEnergyTrainingIfSaturated", false);
0029   desc.add<edm::ESInputTag>("ebLowEtForestName", edm::ESInputTag{"", "electron_eb_ECALTRK_lowpt"});
0030   desc.add<edm::ESInputTag>("ebHighEtForestName", edm::ESInputTag{"", "electron_eb_ECALTRK"});
0031   desc.add<edm::ESInputTag>("eeLowEtForestName", edm::ESInputTag{"", "electron_ee_ECALTRK_lowpt"});
0032   desc.add<edm::ESInputTag>("eeHighEtForestName", edm::ESInputTag{"", "electron_ee_ECALTRK"});
0033   return desc;
0034 }
0035 
0036 void EgammaRegressionContainer::setEventContent(const edm::EventSetup& iSetup) {
0037   ebLowEtForest_ = &iSetup.getData(ebLowEtForestToken_);
0038   ebHighEtForest_ = &iSetup.getData(ebHighEtForestToken_);
0039   eeLowEtForest_ = &iSetup.getData(eeLowEtForestToken_);
0040   eeHighEtForest_ = &iSetup.getData(eeHighEtForestToken_);
0041 }
0042 
0043 float EgammaRegressionContainer::operator()(const float et,
0044                                             const bool isEB,
0045                                             const bool isSaturated,
0046                                             const float* data) const {
0047   if (useLowEtBin(et, isSaturated)) {
0048     if (isEB)
0049       return outputTransformerLowEt_(ebLowEtForest_->GetResponse(data));
0050     else
0051       return outputTransformerLowEt_(eeLowEtForest_->GetResponse(data));
0052   } else {
0053     if (isEB)
0054       return outputTransformerHighEt_(ebHighEtForest_->GetResponse(data));
0055     else
0056       return outputTransformerHighEt_(eeHighEtForest_->GetResponse(data));
0057   }
0058 }
0059 
0060 bool EgammaRegressionContainer::useLowEtBin(const float et, const bool isSaturated) const {
0061   if (isSaturated && forceHighEnergyTrainingIfSaturated_)
0062     return false;
0063   else
0064     return et < lowEtHighEtBoundary_;
0065 }