CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhotonMVAEstimatorRun2Phys14NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Phys14NonTrig_H
2 #define RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Phys14NonTrig_H
3 
5 
7 
9 
11 
12 #include <vector>
13 #include <string>
14 #include <TROOT.h>
15 #include "TMVA/Factory.h"
16 #include "TMVA/Tools.h"
17 #include "TMVA/Reader.h"
18 
20 
21  public:
22 
23  // Define here the number and the meaning of the categories
24  // for this specific MVA
25  const int nCategories = 2;
27  UNDEFINED = -1,
28  CAT_EB = 0,
29  CAT_EE = 1
30  };
31 
32  // Define the struct that contains all necessary for MVA variables
33  struct AllVariables {
34 
35  float varPhi;
36  float varR9;
37  float varSieie;
38  float varSieip;
42  float varSCEta;
43  float varRawE;
46  float varESEnOverRawE; // for endcap MVA only
47  float varESEffSigmaRR; // for endcap MVA only
48  // Pile-up
49  float varRho;
50  // Isolations
51  float varPhoIsoRaw;
52  float varChIsoRaw;
54  // Spectators
55  float varPt;
56  float varEta;
57 
58  };
59 
60  // Constructor and destructor
63 
64  // Calculation of the MVA value
65  float mvaValue( const edm::Ptr<reco::Candidate>& particle);
66 
67  // Utility functions
68  TMVA::Reader *createSingleReader(const int iCategory, const edm::FileInPath &weightFile);
69 
70  inline int getNCategories(){return nCategories;};
71  bool isEndcapCategory( int category );
72  const inline std::string getName(){return name_;};
73 
74  // Functions that should work on both pat and reco electrons
75  // (use the fact that pat::Electron inherits from reco::GsfElectron)
76  void fillMVAVariables(const edm::Ptr<reco::Candidate>& particle);
77  int findCategory( const edm::Ptr<reco::Candidate>& particle);
78  // The function below ensures that the variables passed to MVA are
79  // within reasonable bounds
80  void constrainMVAVariables();
81 
82  // Call this function once after the constructor to declare
83  // the needed event content pieces to the framework
84  void setConsumes(edm::ConsumesCollector&&) override;
85  // Call this function once per event to retrieve all needed
86  // event content pices
87  void getEventContent(const edm::Event& iEvent) override;
88 
89 
90  private:
91 
92  // MVA name. This is a unique name for this MVA implementation.
93  // It will be used as part of ValueMap names.
94  // For simplicity, keep it set to the class name.
95  const std::string name_ = "PhotonMVAEstimatorRun2Phys14NonTrig";
96 
97  // Data members
98  std::vector< std::unique_ptr<TMVA::Reader> > _tmvaReaders;
99 
100  // All variables needed by this MVA
103 
104  // This MVA implementation relies on several ValueMap objects
105  // produced upstream.
106 
107  //
108  // Declare all tokens that will be needed to retrieve misc
109  // data from the event content required by this MVA
110  //
118  //
122 
123  //
124  // Declare all value maps corresponding to the above tokens
125  //
133  //
137 
138  // Rho will be pulled from the event content
141 
142 };
143 
146  "PhotonMVAEstimatorRun2Phys14NonTrig");
147 
148 #endif
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5E5x5MapToken
edm::Handle< edm::ValueMap< float > > _phoChargedIsolationMap
edm::Handle< edm::ValueMap< float > > _esEffSigmaRRMap
float mvaValue(const edm::Ptr< reco::Candidate > &particle)
void fillMVAVariables(const edm::Ptr< reco::Candidate > &particle)
int findCategory(const edm::Ptr< reco::Candidate > &particle)
edm::Handle< edm::ValueMap< float > > _full5x5E5x5Map
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< edm::ValueMap< float > > _phoChargedIsolationToken
edm::EDGetTokenT< edm::ValueMap< float > > _phoWorstChargedIsolationToken
TMVA::Reader * createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
edm::EDGetTokenT< edm::ValueMap< float > > _esEffSigmaRRMapToken
void getEventContent(const edm::Event &iEvent) override
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5SigmaIEtaIPhiMapToken
edm::Handle< edm::ValueMap< float > > _full5x5SigmaIEtaIPhiMap
edm::Handle< edm::ValueMap< float > > _phoPhotonIsolationMap
tuple conf
Definition: dbtoconf.py:185
edm::Handle< edm::ValueMap< float > > _full5x5E2x2Map
edm::Handle< edm::ValueMap< float > > _phoWorstChargedIsolationMap
edm::Handle< edm::ValueMap< float > > _full5x5SigmaIEtaIEtaMap
PhotonMVAEstimatorRun2Phys14NonTrig(const edm::ParameterSet &conf)
edm::Handle< edm::ValueMap< float > > _full5x5E1x3Map
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5SigmaIEtaIEtaMapToken
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5E2x5MaxMapToken
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5E1x3MapToken
edm::Handle< edm::ValueMap< float > > _full5x5E2x5MaxMap
std::vector< std::unique_ptr< TMVA::Reader > > _tmvaReaders
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setConsumes(edm::ConsumesCollector &&) override
edm::EDGetTokenT< edm::ValueMap< float > > _phoPhotonIsolationToken
edm::EDGetTokenT< edm::ValueMap< float > > _full5x5E2x2MapToken