Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef __EgammaElectronAlgos_RegressionHelper_h__
0002 #define __EgammaElectronAlgos_RegressionHelper_h__
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Framework/interface/ConsumesCollector.h"
0009 
0010 #include "CondFormats/GBRForest/interface/GBRForest.h"
0011 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0012 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0013 
0014 #include "DataFormats/Common/interface/Handle.h"
0015 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0016 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0017 #include "DataFormats/VertexReco/interface/Vertex.h"
0018 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0019 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0020 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0021 
0022 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0023 #include "CondFormats/DataRecord/interface/GBRWrapperRcd.h"
0024 
0025 class RegressionHelper {
0026 public:
0027   struct Configuration {
0028     // weight files for the regression
0029     std::vector<std::string> ecalRegressionWeightLabels;
0030     bool ecalWeightsFromDB;
0031     std::vector<std::string> ecalRegressionWeightFiles;
0032     std::vector<std::string> combinationRegressionWeightLabels;
0033     bool combinationWeightsFromDB;
0034     std::vector<std::string> combinationRegressionWeightFiles;
0035   };
0036 
0037   struct ESGetTokens {
0038     ESGetTokens(Configuration const& cfg, bool useEcalReg, bool useCombinationReg, edm::ConsumesCollector& cc);
0039 
0040     edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopology;
0041     edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometry;
0042     edm::ESGetToken<GBRForest, GBRWrapperRcd> ecalRegBarrel;
0043     edm::ESGetToken<GBRForest, GBRWrapperRcd> ecalRegEndcap;
0044     edm::ESGetToken<GBRForest, GBRWrapperRcd> ecalRegErrorBarrel;
0045     edm::ESGetToken<GBRForest, GBRWrapperRcd> ecalRegErrorEndcap;
0046     edm::ESGetToken<GBRForest, GBRWrapperRcd> combinationReg;
0047   };
0048 
0049   RegressionHelper(Configuration const&, bool useEcalReg, bool useCombinationReg, edm::ConsumesCollector& cc);
0050   void checkSetup(const edm::EventSetup&);
0051   void applyEcalRegression(reco::GsfElectron& electron,
0052                            const reco::VertexCollection& vertices,
0053                            const EcalRecHitCollection& rechitsEB,
0054                            const EcalRecHitCollection& rechitsEE) const;
0055 
0056   void applyCombinationRegression(reco::GsfElectron& ele) const;
0057 
0058 private:
0059   void getEcalRegression(const reco::SuperCluster& sc,
0060                          const reco::VertexCollection& vertices,
0061                          const EcalRecHitCollection& rechitsEB,
0062                          const EcalRecHitCollection& rechitsEE,
0063                          double& energyFactor,
0064                          double& errorFactor) const;
0065 
0066 private:
0067   const Configuration cfg_;
0068   const ESGetTokens esGetTokens_;
0069 
0070   const CaloTopology* caloTopology_;
0071   const CaloGeometry* caloGeometry_;
0072   bool ecalRegressionInitialized_ = false;
0073   bool combinationRegressionInitialized_ = false;
0074 
0075   const GBRForest* ecalRegBarrel_;
0076   const GBRForest* ecalRegEndcap_;
0077   const GBRForest* ecalRegErrorBarrel_;
0078   const GBRForest* ecalRegErrorEndcap_;
0079   const GBRForest* combinationReg_;
0080 };
0081 
0082 #endif