CMS 3D CMS Logo

AntiElectronIDMVA6.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------------------------------
2 // AntiElectronIDMVA6
3 //
4 // Helper Class for applying MVA anti-electron discrimination
5 //
6 // Authors: F.Colombo, C.Veelken
7 // M. Bluj (template version)
8 //--------------------------------------------------------------------------------------------------
9 
10 #ifndef RECOTAUTAG_RECOTAU_AntiElectronIDMVA6_H
11 #define RECOTAUTAG_RECOTAU_AntiElectronIDMVA6_H
12 
18 
29 
30 #include "TMVA/Tools.h"
31 #include "TMVA/Reader.h"
32 
34 
35 #include <vector>
36 
37 class GBRWrapperRcd;
38 
40  struct TauVars {
41  float pt = 0;
42  float etaAtEcalEntrance = 0;
43  float phi = 0;
46  float emFraction = 0;
49  float visMassIn = 0;
50  float dCrackEta = 0;
51  float dCrackPhi = 0;
52  float hasGsf = 0;
53  };
54  struct TauGammaVecs {
55  std::vector<float> gammasdEtaInSigCone;
56  std::vector<float> gammasdPhiInSigCone;
57  std::vector<float> gammasPtInSigCone;
58  std::vector<float> gammasdEtaOutSigCone;
59  std::vector<float> gammasdPhiOutSigCone;
60  std::vector<float> gammasPtOutSigCone;
61  };
62  struct TauGammaMoms {
65  float gammaEtaMomIn = 0;
66  float gammaEtaMomOut = 0;
67  float gammaPhiMomIn = 0;
68  float gammaPhiMomOut = 0;
69  float gammaEnFracIn = 0;
70  float gammaEnFracOut = 0;
71  };
72  struct ElecVars {
73  float eta = 0;
74  float phi = 0;
75  float eTotOverPin = 0;
76  float chi2NormGSF = 0;
77  float chi2NormKF = 0;
78  float gsfNumHits = 0;
79  float kfNumHits = 0;
80  float gsfTrackResol = 0;
81  float gsfTracklnPt = 0;
82  float pIn = 0;
83  float pOut = 0;
84  float eEcal = 0;
85  float deltaEta = 0;
86  float deltaPhi = 0;
87  float mvaInSigmaEtaEta = 0;
88  float mvaInHadEnergy = 0;
89  float mvaInDeltaEta = 0;
93  float sigmaIEtaIEta5x5 = 0;
94  float sigmaIPhiIPhi5x5 = 0;
95  float showerCircularity = 0;
96  float r9 = 0;
97  float hgcalSigmaUU = 0;
98  float hgcalSigmaVV = 0;
99  float hgcalSigmaEE = 0;
100  float hgcalSigmaPP = 0;
101  float hgcalNLayers = 0;
102  float hgcalFirstLayer = 0;
103  float hgcalLastLayer = 0;
104  float hgcalLayerEfrac10 = 0;
105  float hgcalLayerEfrac90 = 0;
106  float hgcalEcEnergyEE = 0;
107  float hgcalEcEnergyFH = 0;
112  };
113 } // namespace antiElecIDMVA6_blocks
114 
115 template <class TauType, class ElectronType>
117 public:
118  typedef std::vector<ElectronType> ElectronCollection;
120 
123 
124  void beginEvent(const edm::Event&, const edm::EventSetup&);
125 
127  const antiElecIDMVA6_blocks::TauGammaVecs& tauGammaVecs,
128  const antiElecIDMVA6_blocks::ElecVars& elecVars);
129 
131  const antiElecIDMVA6_blocks::TauGammaMoms& tauGammaMoms,
132  const antiElecIDMVA6_blocks::ElecVars& elecVars);
133 
135  const antiElecIDMVA6_blocks::TauGammaMoms& tauGammaMoms,
136  const antiElecIDMVA6_blocks::ElecVars& elecVars);
137 
138  // this function can be called for all categories
139  double mvaValue(const TauType& theTau, const ElectronRef& theEleRef);
140  // this function can be called for category 1 only !!
141  double mvaValue(const TauType& theTau);
142 
143  // overloaded method with explicit tau type to avoid partial imlementation of full class
146  antiElecIDMVA6_blocks::TauVars getTauVars(const TauType& theTau);
149  // overloaded method with explicit electron type to avoid partial imlementation of full class
152 
153 private:
154  double dCrackEta(double eta);
155  double minimum(double a, double b);
156  double dCrackPhi(double phi, double eta);
158  const pat::Tau& theTau,
159  float& eta,
160  float& phi); // MB: needed only for pat::Tau and called within pat::Tau specific method so also pat::Tau specific
161 
162  static constexpr float ecalBarrelEndcapEtaBorder_ = 1.479;
164 
168 
181 
194 
196 
198  std::vector<float> var_NoEleMatch_wGwoGSF_Barrel_;
199  std::vector<float> var_woGwGSF_Barrel_;
200  std::vector<float> var_wGwGSF_Barrel_;
202  std::vector<float> var_NoEleMatch_wGwoGSF_Endcap_;
203  std::vector<float> var_woGwGSF_Endcap_;
204  std::vector<float> var_wGwGSF_Endcap_;
207  std::vector<float> var_woGwGSF_VFEndcap_;
208  std::vector<float> var_wGwGSF_VFEndcap_;
209 
222 
223  std::vector<TFile*> inputFilesToDelete_;
224 
225  const bool isPhase2_;
226 
228 
229  std::map<std::string, edm::EDGetTokenT<edm::ValueMap<float>>> electronIds_tokens_;
230  std::map<std::string, edm::Handle<edm::ValueMap<float>>> electronIds_;
231 
232  const int verbosity_;
233 };
234 
235 #endif
std::vector< float > var_NoEleMatch_wGwoGSF_Barrel_
double minimum(double a, double b)
std::string mvaName_wGwGSF_BL_
std::vector< float > var_wGwGSF_Endcap_
std::vector< float > var_wGwGSF_VFEndcap_
antiElecIDMVA6_blocks::TauVars getTauVars(const TauType &theTau)
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_EC_
antiElecIDMVA6_blocks::TauVars getTauVarsTypeSpecific(const reco::PFTau &theTau)
const GBRForest * mva_NoEleMatch_wGwoGSF_BL_
const GBRForest * mva_woGwGSF_EC_
std::string mvaName_NoEleMatch_woGwoGSF_VFEC_
const GBRForest * mva_NoEleMatch_wGwoGSF_VFEC_
edm::Ref< ElectronCollection > ElectronRef
const GBRForest * mva_wGwGSF_EC_
std::vector< ElectronType > ElectronCollection
std::vector< float > var_NoEleMatch_woGwoGSF_Endcap_
const GBRForest * mva_NoEleMatch_wGwoGSF_EC_
const GBRForest * mva_wGwGSF_VFEC_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_VFEC_
PositionAtECalEntranceComputer positionAtECalEntrance_
static constexpr float ecalEndcapVFEndcapEtaBorder_
std::string mvaName_NoEleMatch_wGwoGSF_BL_
void getElecVarsHGCalTypeSpecific(const reco::GsfElectronRef &theEleRef, antiElecIDMVA6_blocks::ElecVars &elecVars)
std::string mvaName_NoEleMatch_wGwoGSF_EC_
std::vector< float > var_wGwGSF_Barrel_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_BL_
std::string mvaName_wGwGSF_VFEC_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_BL_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_BL_
std::string mvaName_NoEleMatch_wGwoGSF_VFEC_
std::vector< float > var_woGwGSF_Endcap_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_EC_
const GBRForest * mva_woGwGSF_BL_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_VFEC_
std::vector< float > var_NoEleMatch_woGwoGSF_Barrel_
Analysis-level tau class.
Definition: Tau.h:53
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_BL_
const GBRForest * mva_NoEleMatch_woGwoGSF_VFEC_
const GBRForest * mva_woGwGSF_VFEC_
double mvaValue(const antiElecIDMVA6_blocks::TauVars &tauVars, const antiElecIDMVA6_blocks::TauGammaVecs &tauGammaVecs, const antiElecIDMVA6_blocks::ElecVars &elecVars)
antiElecIDMVA6_blocks::TauGammaVecs getTauGammaVecs(const TauType &theTau)
std::map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > electronIds_tokens_
bool energyWeightedEtaAndPhiAtECal(const pat::Tau &theTau, float &eta, float &phi)
const GBRForest * mva_NoEleMatch_woGwoGSF_EC_
const GBRForest * mva_NoEleMatch_woGwoGSF_BL_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_EC_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_EC_
std::string mvaName_woGwGSF_VFEC_
double b
Definition: hdecay.h:120
std::vector< float > var_NoEleMatch_wGwoGSF_VFEndcap_
double dCrackEta(double eta)
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_VFEC_
antiElecIDMVA6_blocks::ElecVars getElecVars(const ElectronRef &theEleRef)
static constexpr float ecalBarrelEndcapEtaBorder_
std::vector< float > var_NoEleMatch_wGwoGSF_Endcap_
double mvaValuePhase2(const antiElecIDMVA6_blocks::TauVars &tauVars, const antiElecIDMVA6_blocks::TauGammaMoms &tauGammaMoms, const antiElecIDMVA6_blocks::ElecVars &elecVars)
edm::FileInPath inputFileName_
double a
Definition: hdecay.h:121
std::vector< TFile * > inputFilesToDelete_
std::string mvaName_wGwGSF_EC_
std::map< std::string, edm::Handle< edm::ValueMap< float > > > electronIds_
const GBRForest * mva_wGwGSF_BL_
std::string mvaName_NoEleMatch_woGwoGSF_EC_
std::vector< float > var_woGwGSF_Barrel_
std::string mvaName_woGwGSF_EC_
std::string mvaName_woGwGSF_BL_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_VFEC_
AntiElectronIDMVA6(const edm::ParameterSet &, edm::ConsumesCollector &&)
void beginEvent(const edm::Event &, const edm::EventSetup &)
double dCrackPhi(double phi, double eta)
std::vector< float > var_NoEleMatch_woGwoGSF_VFEndcap_
std::vector< float > var_woGwGSF_VFEndcap_
std::string mvaName_NoEleMatch_woGwoGSF_BL_