Skip to content

Commit

Permalink
Merge pull request #30581 from cms-tau-pog/CMSSW_11_2_X_tau-pog_anti-…
Browse files Browse the repository at this point in the history
…e-refactoring

Refactoring of anti-electron tauID
  • Loading branch information
cmsbuild authored Jul 20, 2020
2 parents da116fc + aa84916 commit b2091ea
Show file tree
Hide file tree
Showing 11 changed files with 876 additions and 1,688 deletions.
6 changes: 5 additions & 1 deletion PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@
### Define new anit-e discriminants (2018)
antiElectronDiscrMVA6_version = "MVA"
## Raw
from RecoTauTag.RecoTau.PATTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
PATTauProducer = 'slimmedTaus',
Prediscriminants = noPrediscriminants, #already selected for MiniAOD
srcElectrons = 'slimmedElectrons',
vetoEcalCracks = False, #keep tau candidates in EB-EE cracks
mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_BL',
mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_EC',
Expand Down Expand Up @@ -247,7 +249,9 @@
antiElectronDiscrMVA6v1_version = "MVA6v1"
## Raw
patTauDiscriminationByElectronRejectionMVA62015Raw = patTauDiscriminationAgainstElectronMVA6.clone(
PATTauProducer = 'slimmedTaus',
Prediscriminants = noPrediscriminants, #already selected for MiniAOD
srcElectrons = 'slimmedElectrons',
vetoEcalCracks = True, #don't keep tau candidates in EB-EE cracks for v1
mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_BL',
mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_EC',
Expand Down
3 changes: 2 additions & 1 deletion RecoTauTag/Configuration/python/HPSPFTaus_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from RecoTauTag.RecoTau.PFRecoTauDiscriminationByIsolation_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationByLeadingTrackFinding_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectron_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstElectronMVA6_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstElectronMVA6_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstElectronDeadECAL_cfi import *
from RecoTauTag.RecoTau.PFRecoTauDiscriminationAgainstMuon_cfi import *
from RecoTauTag.RecoTau.pfRecoTauDiscriminationAgainstMuon2Container_cfi import *
Expand Down Expand Up @@ -220,6 +220,7 @@
## ByMVA6rawElectronRejection
hpsPFTauDiscriminationByMVA6rawElectronRejection = pfRecoTauDiscriminationAgainstElectronMVA6.clone(
PFTauProducer = cms.InputTag('hpsPFTauProducer'),
srcElectrons = cms.InputTag('gedGsfElectrons'),
Prediscriminants = requireDecayMode.clone(),
loadMVAfromDB = cms.bool(True),
vetoEcalCracks = cms.bool(False),
Expand Down
169 changes: 80 additions & 89 deletions RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Helper Class for applying MVA anti-electron discrimination
//
// Authors: F.Colombo, C.Veelken
// M. Bluj (template version)
//--------------------------------------------------------------------------------------------------

#ifndef RECOTAUTAG_RECOTAU_AntiElectronIDMVA6_H
Expand Down Expand Up @@ -32,98 +33,88 @@

#include <vector>

namespace antiElecIDMVA6_blocks {
struct TauVars {
float pt = 0;
float etaAtEcalEntrance = 0;
float phi = 0;
float leadChargedPFCandPt = 0;
float leadChargedPFCandEtaAtEcalEntrance = 0;
float emFraction = 0;
float leadPFChargedHadrHoP = 0;
float leadPFChargedHadrEoP = 0;
float visMassIn = 0;
float dCrackEta = 0;
float dCrackPhi = 0;
float hasGsf = 0;
};
struct TauGammaVecs {
std::vector<float> gammasdEtaInSigCone;
std::vector<float> gammasdPhiInSigCone;
std::vector<float> gammasPtInSigCone;
std::vector<float> gammasdEtaOutSigCone;
std::vector<float> gammasdPhiOutSigCone;
std::vector<float> gammasPtOutSigCone;
};
struct TauGammaMoms {
int signalPFGammaCandsIn = 0;
int signalPFGammaCandsOut = 0;
float gammaEtaMomIn = 0;
float gammaEtaMomOut = 0;
float gammaPhiMomIn = 0;
float gammaPhiMomOut = 0;
float gammaEnFracIn = 0;
float gammaEnFracOut = 0;
};
struct ElecVars {
float eta = 0;
float phi = 0;
float eTotOverPin = 0;
float chi2NormGSF = 0;
float chi2NormKF = 0;
float gsfNumHits = 0;
float kfNumHits = 0;
float gsfTrackResol = 0;
float gsfTracklnPt = 0;
float pIn = 0;
float pOut = 0;
float eEcal = 0;
float deltaEta = 0;
float deltaPhi = 0;
float mvaInSigmaEtaEta = 0;
float mvaInHadEnergy = 0;
float mvaInDeltaEta = 0;
};
} // namespace antiElecIDMVA6_blocks

template <class TauType, class ElectronType>
class AntiElectronIDMVA6 {
public:
AntiElectronIDMVA6(const edm::ParameterSet&);
~AntiElectronIDMVA6();

void beginEvent(const edm::Event&, const edm::EventSetup&);

double MVAValue(Float_t TauPt,
Float_t TauEtaAtEcalEntrance,
Float_t TauPhi,
Float_t TauLeadChargedPFCandPt,
Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
Float_t TauEmFraction,
Float_t TauLeadPFChargedHadrHoP,
Float_t TauLeadPFChargedHadrEoP,
Float_t TauVisMassIn,
Float_t TaudCrackEta,
Float_t TaudCrackPhi,
Float_t TauHasGsf,
Int_t TauSignalPFGammaCandsIn,
Int_t TauSignalPFGammaCandsOut,
const std::vector<Float_t>& GammasdEtaInSigCone,
const std::vector<Float_t>& GammasdPhiInSigCone,
const std::vector<Float_t>& GammasPtInSigCone,
const std::vector<Float_t>& GammasdEtaOutSigCone,
const std::vector<Float_t>& GammasdPhiOutSigCone,
const std::vector<Float_t>& GammasPtOutSigCone,
Float_t ElecEta,
Float_t ElecPhi,
Float_t ElecEtotOverPin,
Float_t ElecChi2NormGSF,
Float_t ElecChi2NormKF,
Float_t ElecGSFNumHits,
Float_t ElecKFNumHits,
Float_t ElecGSFTrackResol,
Float_t ElecGSFTracklnPt,
Float_t ElecPin,
Float_t ElecPout,
Float_t ElecEecal,
Float_t ElecDeltaEta,
Float_t ElecDeltaPhi,
Float_t ElecMvaInSigmaEtaEta,
Float_t ElecMvaInHadEnergy,
Float_t ElecMvaInDeltaEta);

double MVAValue(Float_t TauPt,
Float_t TauEtaAtEcalEntrance,
Float_t TauPhi,
Float_t TauLeadChargedPFCandPt,
Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
Float_t TauEmFraction,
Float_t TauLeadPFChargedHadrHoP,
Float_t TauLeadPFChargedHadrEoP,
Float_t TauVisMassIn,
Float_t TaudCrackEta,
Float_t TaudCrackPhi,
Float_t TauHasGsf,
Int_t TauSignalPFGammaCandsIn,
Int_t TauSignalPFGammaCandsOut,
Float_t TauGammaEtaMomIn,
Float_t TauGammaEtaMomOut,
Float_t TauGammaPhiMomIn,
Float_t TauGammaPhiMomOut,
Float_t TauGammaEnFracIn,
Float_t TauGammaEnFracOut,
Float_t ElecEta,
Float_t ElecPhi,
Float_t ElecEtotOverPin,
Float_t ElecChi2NormGSF,
Float_t ElecChi2NormKF,
Float_t ElecGSFNumHits,
Float_t ElecKFNumHits,
Float_t ElecGSFTrackResol,
Float_t ElecGSFTracklnPt,
Float_t ElecPin,
Float_t ElecPout,
Float_t ElecEecal,
Float_t ElecDeltaEta,
Float_t ElecDeltaPhi,
Float_t ElecMvaInSigmaEtaEta,
Float_t ElecMvaInHadEnergy,
Float_t ElecMvaInDeltaEta);
double MVAValue(const antiElecIDMVA6_blocks::TauVars& tauVars,
const antiElecIDMVA6_blocks::TauGammaVecs& tauGammaVecs,
const antiElecIDMVA6_blocks::ElecVars& elecVars);

// this function can be called for all categories
double MVAValue(const reco::PFTau& thePFTau, const reco::GsfElectron& theGsfEle);
// this function can be called for category 1 only !!
double MVAValue(const reco::PFTau& thePFTau);
double MVAValue(const antiElecIDMVA6_blocks::TauVars& tauVars,
const antiElecIDMVA6_blocks::TauGammaMoms& tauGammaMoms,
const antiElecIDMVA6_blocks::ElecVars& elecVars);

// this function can be called for all categories
double MVAValue(const pat::Tau& theTau, const pat::Electron& theEle);
double MVAValue(const TauType& theTau, const ElectronType& theEle);
// this function can be called for category 1 only !!
double MVAValue(const pat::Tau& theTau);
double MVAValue(const TauType& theTau);

// overloaded method with explicit tau type to avoid partial imlementation of full class
antiElecIDMVA6_blocks::TauVars getTauVarsTypeSpecific(const reco::PFTau& theTau);
antiElecIDMVA6_blocks::TauVars getTauVarsTypeSpecific(const pat::Tau& theTau);
antiElecIDMVA6_blocks::TauVars getTauVars(const TauType& theTau);
antiElecIDMVA6_blocks::TauGammaVecs getTauGammaVecs(const TauType& theTau);
antiElecIDMVA6_blocks::ElecVars getElecVars(const ElectronType& theEle);

// track extrapolation to ECAL entrance (used to re-calculate variables that might not be available on miniAOD)
bool atECalEntrance(const reco::Candidate* part, math::XYZPoint& pos);

Expand All @@ -147,14 +138,14 @@ class AntiElectronIDMVA6 {

bool usePhiAtEcalEntranceExtrapolation_;

Float_t* Var_NoEleMatch_woGwoGSF_Barrel_;
Float_t* Var_NoEleMatch_wGwoGSF_Barrel_;
Float_t* Var_woGwGSF_Barrel_;
Float_t* Var_wGwGSF_Barrel_;
Float_t* Var_NoEleMatch_woGwoGSF_Endcap_;
Float_t* Var_NoEleMatch_wGwoGSF_Endcap_;
Float_t* Var_woGwGSF_Endcap_;
Float_t* Var_wGwGSF_Endcap_;
float* Var_NoEleMatch_woGwoGSF_Barrel_;
float* Var_NoEleMatch_wGwoGSF_Barrel_;
float* Var_woGwGSF_Barrel_;
float* Var_wGwGSF_Barrel_;
float* Var_NoEleMatch_woGwoGSF_Endcap_;
float* Var_NoEleMatch_wGwoGSF_Endcap_;
float* Var_woGwGSF_Endcap_;
float* Var_wGwGSF_Endcap_;

const GBRForest* mva_NoEleMatch_woGwoGSF_BL_;
const GBRForest* mva_NoEleMatch_wGwoGSF_BL_;
Expand Down
Loading

0 comments on commit b2091ea

Please sign in to comment.