CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
EGammaMvaEleEstimator Class Reference

#include <EGammaMvaEleEstimator.h>

Public Types

enum  MVAType {
  kTrig = 0, kTrigNoIP = 1, kNonTrig = 2, kIsoRings,
  kTrigIDIsoCombined, kTrigIDIsoCombinedPUCorrected
}
 

Public Member Functions

void bindVariables ()
 
 EGammaMvaEleEstimator ()
 
UInt_t GetMVABin (double eta, double pt) const
 
Double_t IDIsoCombinedMvaValue (const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, bool printDebug=kFALSE)
 
Double_t IDIsoCombinedMvaValue (Double_t fbrem, Double_t kfchi2, Int_t kfhits, Double_t gsfchi2, Double_t deta, Double_t dphi, Double_t detacalo, Double_t see, Double_t spp, Double_t etawidth, Double_t phiwidth, Double_t OneMinusE1x5E5x5, Double_t R9, Double_t HoE, Double_t EoP, Double_t IoEmIoP, Double_t eleEoPout, Double_t PreShowerOverRaw, Double_t d0, Double_t ip3d, Double_t ChargedIso_DR0p0To0p1, Double_t ChargedIso_DR0p1To0p2, Double_t ChargedIso_DR0p2To0p3, Double_t ChargedIso_DR0p3To0p4, Double_t ChargedIso_DR0p4To0p5, Double_t GammaIso_DR0p0To0p1, Double_t GammaIso_DR0p1To0p2, Double_t GammaIso_DR0p2To0p3, Double_t GammaIso_DR0p3To0p4, Double_t GammaIso_DR0p4To0p5, Double_t NeutralHadronIso_DR0p0To0p1, Double_t NeutralHadronIso_DR0p1To0p2, Double_t NeutralHadronIso_DR0p2To0p3, Double_t NeutralHadronIso_DR0p3To0p4, Double_t NeutralHadronIso_DR0p4To0p5, Double_t Rho, Double_t eta, Double_t pt, Bool_t printDebug=kFALSE)
 
void initialize (std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
 
void initialize (std::string methodName, EGammaMvaEleEstimator::MVAType type, Bool_t useBinnedVersion, std::vector< std::string > weightsfiles)
 
Bool_t isInitialized () const
 
Double_t isoMvaValue (const reco::GsfElectron &ele, const reco::Vertex &vertex, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, const reco::GsfElectronCollection &IdentifiedElectrons, const reco::MuonCollection &IdentifiedMuons, bool printDebug=kFALSE)
 
Double_t isoMvaValue (Double_t Pt, Double_t Eta, Double_t Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, Double_t ChargedIso_DR0p0To0p1, Double_t ChargedIso_DR0p1To0p2, Double_t ChargedIso_DR0p2To0p3, Double_t ChargedIso_DR0p3To0p4, Double_t ChargedIso_DR0p4To0p5, Double_t GammaIso_DR0p0To0p1, Double_t GammaIso_DR0p1To0p2, Double_t GammaIso_DR0p2To0p3, Double_t GammaIso_DR0p3To0p4, Double_t GammaIso_DR0p4To0p5, Double_t NeutralHadronIso_DR0p0To0p1, Double_t NeutralHadronIso_DR0p1To0p2, Double_t NeutralHadronIso_DR0p2To0p3, Double_t NeutralHadronIso_DR0p3To0p4, Double_t NeutralHadronIso_DR0p4To0p5, Bool_t printDebug=kFALSE)
 
Double_t mvaValue (const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
 
Double_t mvaValue (const reco::GsfElectron &ele, const reco::Vertex &vertex, double rho, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
 
Double_t mvaValue (const pat::Electron &ele, double rho, bool printDebug=kFALSE)
 
Double_t mvaValue (const pat::Electron &ele, const reco::Vertex &vertex, double rho, bool useFull5x5=kFALSE, bool printDebug=kFALSE)
 
Double_t mvaValue (Double_t fbrem, Double_t kfchi2, Int_t kfhits, Double_t gsfchi2, Double_t deta, Double_t dphi, Double_t detacalo, Double_t see, Double_t spp, Double_t etawidth, Double_t phiwidth, Double_t e1x5e5x5, Double_t R9, Double_t HoE, Double_t EoP, Double_t IoEmIoP, Double_t eleEoPout, Double_t PreShowerOverRaw, Double_t d0, Double_t ip3d, Double_t eta, Double_t pt, Bool_t printDebug=kFALSE)
 
Double_t mvaValue (Double_t fbrem, Double_t kfchi2, Int_t kfhits, Double_t gsfchi2, Double_t deta, Double_t dphi, Double_t detacalo, Double_t see, Double_t spp, Double_t etawidth, Double_t phiwidth, Double_t e1x5e5x5, Double_t R9, Double_t HoE, Double_t EoP, Double_t IoEmIoP, Double_t eleEoPout, Double_t rho, Double_t PreShowerOverRaw, Double_t eta, Double_t pt, Bool_t printDebug=kFALSE)
 
Double_t mvaValue (Double_t fbrem, Double_t kfchi2, Int_t kfhits, Double_t gsfchi2, Double_t deta, Double_t dphi, Double_t detacalo, Double_t see, Double_t spp, Double_t etawidth, Double_t phiwidth, Double_t e1x5e5x5, Double_t R9, Double_t HoE, Double_t EoP, Double_t IoEmIoP, Double_t eleEoPout, Double_t PreShowerOverRaw, Double_t eta, Double_t pt, Bool_t printDebug=kFALSE)
 
 ~EGammaMvaEleEstimator ()
 

Private Attributes

Bool_t fisInitialized
 
std::string fMethodname
 
MVAType fMVAType
 
Float_t fMVAVar_ChargedIso_DR0p0To0p1
 
Float_t fMVAVar_ChargedIso_DR0p1To0p2
 
Float_t fMVAVar_ChargedIso_DR0p2To0p3
 
Float_t fMVAVar_ChargedIso_DR0p3To0p4
 
Float_t fMVAVar_ChargedIso_DR0p4To0p5
 
Float_t fMVAVar_d0
 
Float_t fMVAVar_deta
 
Float_t fMVAVar_detacalo
 
Float_t fMVAVar_dphi
 
Float_t fMVAVar_eleEoPout
 
Float_t fMVAVar_EoP
 
Float_t fMVAVar_EoPout
 
Float_t fMVAVar_eta
 
Float_t fMVAVar_etawidth
 
Float_t fMVAVar_fbrem
 
Float_t fMVAVar_GammaIso_DR0p0To0p1
 
Float_t fMVAVar_GammaIso_DR0p1To0p2
 
Float_t fMVAVar_GammaIso_DR0p2To0p3
 
Float_t fMVAVar_GammaIso_DR0p3To0p4
 
Float_t fMVAVar_GammaIso_DR0p4To0p5
 
Float_t fMVAVar_gsfchi2
 
Float_t fMVAVar_HoE
 
Float_t fMVAVar_IoEmIoP
 
Float_t fMVAVar_ip3d
 
Float_t fMVAVar_ip3dSig
 
Float_t fMVAVar_kfchi2
 
Float_t fMVAVar_kfhits
 
Float_t fMVAVar_kfhitsall
 
Float_t fMVAVar_NeutralHadronIso_DR0p0To0p1
 
Float_t fMVAVar_NeutralHadronIso_DR0p1To0p2
 
Float_t fMVAVar_NeutralHadronIso_DR0p2To0p3
 
Float_t fMVAVar_NeutralHadronIso_DR0p3To0p4
 
Float_t fMVAVar_NeutralHadronIso_DR0p4To0p5
 
Float_t fMVAVar_OneMinusE1x5E5x5
 
Float_t fMVAVar_phiwidth
 
Float_t fMVAVar_PreShowerOverRaw
 
Float_t fMVAVar_pt
 
Float_t fMVAVar_R9
 
Float_t fMVAVar_rho
 
Float_t fMVAVar_see
 
Float_t fMVAVar_spp
 
UInt_t fNMVABins
 
std::vector< TMVA::MethodBase * > fTMVAMethod
 
std::vector< TMVA::Reader * > fTMVAReader
 
Bool_t fUseBinnedVersion
 

Detailed Description

–> NOTE if you want to use this class as standalone without the CMSSW part you need to uncomment the below line and compile normally with scramv1 b Then you need just to load it in your root macro the lib with the correct path, eg: gSystem->Load("/data/benedet/CMSSW_5_2_2/lib/slc5_amd64_gcc462/pluginEGammaEGammaAnalysisTools.so");

Definition at line 38 of file EGammaMvaEleEstimator.h.

Member Enumeration Documentation

◆ MVAType

Enumerator
kTrig 
kTrigNoIP 
kNonTrig 
kIsoRings 
kTrigIDIsoCombined 
kTrigIDIsoCombinedPUCorrected 

Definition at line 43 of file EGammaMvaEleEstimator.h.

43  {
44  kTrig = 0, // MVA for triggering electrons
45  kTrigNoIP = 1, // MVA for triggering electrons without IP info
46  kNonTrig = 2, // MVA for non-triggering electrons
47  kIsoRings, // Isolation MVA for non-trigger electrons
48  kTrigIDIsoCombined, // ID+Iso Combined MVA for triggering electrons
49  kTrigIDIsoCombinedPUCorrected // ID+Iso Combined MVA for triggering electrons
50  };

Constructor & Destructor Documentation

◆ EGammaMvaEleEstimator()

EGammaMvaEleEstimator::EGammaMvaEleEstimator ( )

◆ ~EGammaMvaEleEstimator()

EGammaMvaEleEstimator::~EGammaMvaEleEstimator ( )

Definition at line 34 of file EGammaMvaEleEstimator.cc.

References fTMVAReader, and mps_fire::i.

34  {
35  for (unsigned int i = 0; i < fTMVAReader.size(); ++i) {
36  if (fTMVAReader[i])
37  delete fTMVAReader[i];
38  }
39 }
std::vector< TMVA::Reader * > fTMVAReader

Member Function Documentation

◆ bindVariables()

void EGammaMvaEleEstimator::bindVariables ( )

Definition at line 1929 of file EGammaMvaEleEstimator.cc.

References fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_kfchi2, fMVAVar_OneMinusE1x5E5x5, fMVAVar_R9, fMVAVar_spp, CommonMethods::isnan(), and edm::isNotFinite().

Referenced by isoMvaValue(), and mvaValue().

1929  {
1930  // this binding is needed for variables that sometime diverge.
1931 
1932  if (fMVAVar_fbrem < -1.)
1933  fMVAVar_fbrem = -1.;
1934 
1935  fMVAVar_deta = fabs(fMVAVar_deta);
1936  if (fMVAVar_deta > 0.06)
1937  fMVAVar_deta = 0.06;
1938 
1939  fMVAVar_dphi = fabs(fMVAVar_dphi);
1940  if (fMVAVar_dphi > 0.6)
1941  fMVAVar_dphi = 0.6;
1942 
1943  if (fMVAVar_EoP > 20.)
1944  fMVAVar_EoP = 20.;
1945 
1946  if (fMVAVar_eleEoPout > 20.)
1947  fMVAVar_eleEoPout = 20.;
1948 
1950  if (fMVAVar_detacalo > 0.2)
1951  fMVAVar_detacalo = 0.2;
1952 
1953  if (fMVAVar_OneMinusE1x5E5x5 < -1.)
1955 
1956  if (fMVAVar_OneMinusE1x5E5x5 > 2.)
1958 
1959  if (fMVAVar_R9 > 5)
1960  fMVAVar_R9 = 5;
1961 
1962  if (fMVAVar_gsfchi2 > 200.)
1963  fMVAVar_gsfchi2 = 200;
1964 
1965  if (fMVAVar_kfchi2 > 10.)
1966  fMVAVar_kfchi2 = 10.;
1967 
1968  // Needed for a bug in CMSSW_420, fixed in more recent CMSSW versions
1969 #ifndef STANDALONE
1971 #else
1972  if (std::isnan(fMVAVar_spp))
1973 #endif
1974  fMVAVar_spp = 0.;
1975 
1976  return;
1977 }
def isnan(num)
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9

◆ GetMVABin()

UInt_t EGammaMvaEleEstimator::GetMVABin ( double  eta,
double  pt 
) const

Definition at line 399 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, PVValHelper::eta, fMVAType, kIsoRings, kNonTrig, kTrig, kTrigIDIsoCombined, kTrigIDIsoCombinedPUCorrected, kTrigNoIP, and DiDispStaMuonMonitor_cfi::pt.

Referenced by IDIsoCombinedMvaValue(), isoMvaValue(), and mvaValue().

399  {
400  //Default is to return the first bin
401  unsigned int bin = 0;
402 
404  if (pt < 10 && fabs(eta) < 1.479)
405  bin = 0;
406  if (pt < 10 && fabs(eta) >= 1.479)
407  bin = 1;
408  if (pt >= 10 && fabs(eta) < 1.479)
409  bin = 2;
410  if (pt >= 10 && fabs(eta) >= 1.479)
411  bin = 3;
412  }
413 
415  bin = 0;
416  if (pt < 10 && fabs(eta) < 0.8)
417  bin = 0;
418  if (pt < 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479)
419  bin = 1;
420  if (pt < 10 && fabs(eta) >= 1.479)
421  bin = 2;
422  if (pt >= 10 && fabs(eta) < 0.8)
423  bin = 3;
424  if (pt >= 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479)
425  bin = 4;
426  if (pt >= 10 && fabs(eta) >= 1.479)
427  bin = 5;
428  }
429 
433  bin = 0;
434  if (pt < 20 && fabs(eta) < 0.8)
435  bin = 0;
436  if (pt < 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479)
437  bin = 1;
438  if (pt < 20 && fabs(eta) >= 1.479)
439  bin = 2;
440  if (pt >= 20 && fabs(eta) < 0.8)
441  bin = 3;
442  if (pt >= 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479)
443  bin = 4;
444  if (pt >= 20 && fabs(eta) >= 1.479)
445  bin = 5;
446  }
447 
448  return bin;
449 }

◆ IDIsoCombinedMvaValue() [1/2]

Double_t EGammaMvaEleEstimator::IDIsoCombinedMvaValue ( const reco::GsfElectron ele,
const reco::Vertex vertex,
const TransientTrackBuilder transientTrackBuilder,
EcalClusterLazyTools const &  myEcalCluster,
const reco::PFCandidateCollection PFCandidates,
double  Rho,
ElectronEffectiveArea::ElectronEffectiveAreaTarget  EATarget,
bool  printDebug = kFALSE 
)

Definition at line 1619 of file EGammaMvaEleEstimator.cc.

References IPTools::absoluteImpactParameter3D(), newFWLiteAna::bin, TransientTrackBuilder::build(), reco::GsfElectron::closestCtfTrackRef(), funct::cos(), gather_cfg::cout, reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), l1ctLayer1_cff::dr, reco::PFCandidate::e, reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::LeafCandidate::eta(), reco::GsfElectron::fbrem(), fisInitialized, fMethodname, fMVAType, fMVAVar_ChargedIso_DR0p0To0p1, fMVAVar_ChargedIso_DR0p1To0p2, fMVAVar_ChargedIso_DR0p2To0p3, fMVAVar_ChargedIso_DR0p3To0p4, fMVAVar_ChargedIso_DR0p4To0p5, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_GammaIso_DR0p0To0p1, fMVAVar_GammaIso_DR0p1To0p2, fMVAVar_GammaIso_DR0p2To0p3, fMVAVar_GammaIso_DR0p3To0p4, fMVAVar_GammaIso_DR0p4To0p5, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_ip3dSig, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_kfhitsall, fMVAVar_NeutralHadronIso_DR0p0To0p1, fMVAVar_NeutralHadronIso_DR0p1To0p2, fMVAVar_NeutralHadronIso_DR0p2To0p3, fMVAVar_NeutralHadronIso_DR0p3To0p4, fMVAVar_NeutralHadronIso_DR0p4To0p5, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, reco::PFCandidate::gamma, ElectronEffectiveArea::GetElectronEffectiveArea(), GetMVABin(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), electrons_cff::ip3d, edm::Ref< C, T, F >::isAvailable(), edm::isFinite(), edm::Ref< C, T, F >::isNonnull(), ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, kTrig, kTrigIDIsoCombined, kTrigIDIsoCombinedPUCorrected, METSkim_cff::Max, SiStripPI::max, METSkim_cff::Min, SiStripPI::min, reco::PFCandidate::mu, beam_dqm_sourceclient-live_cfg::mva, hltParticleFlowSoftKiller_cfi::PFCandidates, reco::LeafCandidate::phi(), funct::pow(), HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), nanoDQM_cfi::Rho, reco::GsfElectron::sigmaIetaIeta(), mathSSE::sqrt(), reco::GsfElectron::superCluster(), reco::GsfElectron::trackMomentumAtVtx(), and bphysicsOniaDQM_cfi::vertex.

1626  {
1627  if (!fisInitialized) {
1628  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1629  return -9999;
1630  }
1631 
1632  bool validKF = false;
1633  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1634  validKF = (myTrackRef.isAvailable());
1635  validKF &= (myTrackRef.isNonnull());
1636 
1637  // Pure tracking variables
1638  fMVAVar_fbrem = (ele.fbrem() < -1.) ? -1. : ele.fbrem();
1639  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
1640  if (fMVAVar_kfchi2 > 10)
1641  fMVAVar_kfchi2 = 10;
1642  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
1644  (validKF) ? myTrackRef->numberOfValidHits() : -1.; // save also this in your ntuple as possible alternative
1645  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1646  if (fMVAVar_gsfchi2 > 200)
1647  fMVAVar_gsfchi2 = 200;
1648 
1649  // Geometrical matchings
1650  fMVAVar_deta =
1651  (fabs(ele.deltaEtaSuperClusterTrackAtVtx()) > 0.06) ? 0.06 : fabs(ele.deltaEtaSuperClusterTrackAtVtx());
1654 
1655  // Pure ECAL -> shower shapes
1656  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1657  const auto& vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed()));
1658  if (edm::isFinite(vCov[2]))
1659  fMVAVar_spp = sqrt(vCov[2]); //EleSigmaIPhiIPhi
1660  else
1661  fMVAVar_spp = 0.;
1662 
1663  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1664  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1665  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) != 0. ? 1. - (ele.e1x5() / ele.e5x5()) : -1.;
1667  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
1668  if (fMVAVar_R9 > 5)
1669  fMVAVar_R9 = 5;
1670 
1671  // Energy matching
1672  fMVAVar_HoE = ele.hadronicOverEm();
1673  fMVAVar_EoP = (ele.eSuperClusterOverP() > 20) ? 20 : ele.eSuperClusterOverP();
1674  fMVAVar_IoEmIoP =
1675  (1.0 / ele.superCluster()->energy()) - (1.0 / ele.trackMomentumAtVtx().R()); //this is the proper variable
1676  fMVAVar_eleEoPout = (ele.eEleClusterOverPout() > 20) ? 20 : ele.eEleClusterOverPout();
1677  fMVAVar_PreShowerOverRaw = ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1678 
1679  // Spectators
1680  fMVAVar_eta = ele.superCluster()->eta();
1681  fMVAVar_pt = ele.pt();
1682 
1683  // for triggering electrons get the impact parameteres
1684  if (fMVAType == kTrig) {
1685  //d0
1686  if (ele.gsfTrack().isNonnull()) {
1687  fMVAVar_d0 = (-1.0) * ele.gsfTrack()->dxy(vertex.position());
1688  } else if (ele.closestCtfTrackRef().isNonnull()) {
1689  fMVAVar_d0 = (-1.0) * ele.closestCtfTrackRef()->dxy(vertex.position());
1690  } else {
1691  fMVAVar_d0 = -9999.0;
1692  }
1693 
1694  //default values for IP3D
1695  fMVAVar_ip3d = -999.0;
1696  fMVAVar_ip3dSig = 0.0;
1697  if (ele.gsfTrack().isNonnull()) {
1698  const double gsfsign = ((-ele.gsfTrack()->dxy(vertex.position())) >= 0) ? 1. : -1.;
1699 
1700  const reco::TransientTrack& tt = transientTrackBuilder.build(ele.gsfTrack());
1701  const std::pair<bool, Measurement1D>& ip3dpv = IPTools::absoluteImpactParameter3D(tt, vertex);
1702  if (ip3dpv.first) {
1703  double ip3d = gsfsign * ip3dpv.second.value();
1704  double ip3derr = ip3dpv.second.error();
1705  fMVAVar_ip3d = ip3d;
1706  fMVAVar_ip3dSig = ip3d / ip3derr;
1707  }
1708  }
1709  }
1710 
1711  //**********************************************************
1712  //Isolation variables
1713  //**********************************************************
1714  Double_t tmpChargedIso_DR0p0To0p1 = 0;
1715  Double_t tmpChargedIso_DR0p1To0p2 = 0;
1716  Double_t tmpChargedIso_DR0p2To0p3 = 0;
1717  Double_t tmpChargedIso_DR0p3To0p4 = 0;
1718  Double_t tmpChargedIso_DR0p4To0p5 = 0;
1719  Double_t tmpGammaIso_DR0p0To0p1 = 0;
1720  Double_t tmpGammaIso_DR0p1To0p2 = 0;
1721  Double_t tmpGammaIso_DR0p2To0p3 = 0;
1722  Double_t tmpGammaIso_DR0p3To0p4 = 0;
1723  Double_t tmpGammaIso_DR0p4To0p5 = 0;
1724  Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
1725  Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
1726  Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
1727  Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
1728  Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
1729 
1730  for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin(); iP != PFCandidates.end(); ++iP) {
1731  double dr = sqrt(pow(iP->eta() - ele.eta(), 2) + pow(acos(cos(iP->phi() - ele.phi())), 2));
1732 
1733  Bool_t passVeto = kTRUE;
1734  //Charged
1735  if (iP->trackRef().isNonnull()) {
1736  //make sure charged pf candidates pass the PFNoPU condition (assumed)
1737 
1738  //************************************************************
1739  // Veto any PFmuon, or PFEle
1740  if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu)
1741  passVeto = kFALSE;
1742  //************************************************************
1743  //************************************************************
1744  // Footprint Veto
1745  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015)
1746  passVeto = kFALSE;
1747  //************************************************************
1748  if (passVeto) {
1749  if (dr < 0.1)
1750  tmpChargedIso_DR0p0To0p1 += iP->pt();
1751  if (dr >= 0.1 && dr < 0.2)
1752  tmpChargedIso_DR0p1To0p2 += iP->pt();
1753  if (dr >= 0.2 && dr < 0.3)
1754  tmpChargedIso_DR0p2To0p3 += iP->pt();
1755  if (dr >= 0.3 && dr < 0.4)
1756  tmpChargedIso_DR0p3To0p4 += iP->pt();
1757  if (dr >= 0.4 && dr < 0.5)
1758  tmpChargedIso_DR0p4To0p5 += iP->pt();
1759  } //pass veto
1760  }
1761  //Gamma
1762  else if (iP->particleId() == reco::PFCandidate::gamma) {
1763  //************************************************************
1764  // Footprint Veto
1765  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08)
1766  passVeto = kFALSE;
1767  //************************************************************
1768  if (passVeto) {
1769  if (dr < 0.1)
1770  tmpGammaIso_DR0p0To0p1 += iP->pt();
1771  if (dr >= 0.1 && dr < 0.2)
1772  tmpGammaIso_DR0p1To0p2 += iP->pt();
1773  if (dr >= 0.2 && dr < 0.3)
1774  tmpGammaIso_DR0p2To0p3 += iP->pt();
1775  if (dr >= 0.3 && dr < 0.4)
1776  tmpGammaIso_DR0p3To0p4 += iP->pt();
1777  if (dr >= 0.4 && dr < 0.5)
1778  tmpGammaIso_DR0p4To0p5 += iP->pt();
1779  }
1780  }
1781  //NeutralHadron
1782  else {
1783  if (dr < 0.1)
1784  tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
1785  if (dr >= 0.1 && dr < 0.2)
1786  tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
1787  if (dr >= 0.2 && dr < 0.3)
1788  tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
1789  if (dr >= 0.3 && dr < 0.4)
1790  tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
1791  if (dr >= 0.4 && dr < 0.5)
1792  tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
1793  }
1794  } //loop over PF candidates
1795 
1797  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1) / ele.pt(), 2.5);
1798  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2) / ele.pt(), 2.5);
1799  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3) / ele.pt(), 2.5);
1800  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4) / ele.pt(), 2.5);
1801  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5) / ele.pt(), 2.5);
1803  TMath::Min(
1804  (tmpGammaIso_DR0p0To0p1 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1806  ele.pt(),
1807  2.5),
1808  0.0);
1810  TMath::Min(
1811  (tmpGammaIso_DR0p1To0p2 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1813  ele.pt(),
1814  2.5),
1815  0.0);
1817  TMath::Min(
1818  (tmpGammaIso_DR0p2To0p3 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1820  ele.pt(),
1821  2.5),
1822  0.0);
1824  TMath::Min(
1825  (tmpGammaIso_DR0p3To0p4 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1827  ele.pt(),
1828  2.5),
1829  0.0);
1831  TMath::Min(
1832  (tmpGammaIso_DR0p4To0p5 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1834  ele.pt(),
1835  2.5),
1836  0.0);
1838  TMath::Min((tmpNeutralHadronIso_DR0p0To0p1 -
1841  ele.pt(),
1842  2.5),
1843  0.0);
1845  TMath::Min((tmpNeutralHadronIso_DR0p1To0p2 -
1848  ele.pt(),
1849  2.5),
1850  0.0);
1852  TMath::Min((tmpNeutralHadronIso_DR0p2To0p3 -
1855  ele.pt(),
1856  2.5),
1857  0.0);
1859  TMath::Min((tmpNeutralHadronIso_DR0p3To0p4 -
1862  ele.pt(),
1863  2.5),
1864  0.0);
1866  TMath::Min((tmpNeutralHadronIso_DR0p4To0p5 -
1869  ele.pt(),
1870  2.5),
1871  0.0);
1872  } else if (fMVAType == kTrigIDIsoCombined) {
1873  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1) / ele.pt(), 2.5);
1874  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2) / ele.pt(), 2.5);
1875  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3) / ele.pt(), 2.5);
1876  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4) / ele.pt(), 2.5);
1877  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5) / ele.pt(), 2.5);
1878  fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpGammaIso_DR0p0To0p1) / ele.pt(), 2.5), 0.0);
1879  fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpGammaIso_DR0p1To0p2) / ele.pt(), 2.5), 0.0);
1880  fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpGammaIso_DR0p2To0p3) / ele.pt(), 2.5), 0.0);
1881  fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpGammaIso_DR0p3To0p4) / ele.pt(), 2.5), 0.0);
1882  fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpGammaIso_DR0p4To0p5) / ele.pt(), 2.5), 0.0);
1883  fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1) / ele.pt(), 2.5), 0.0);
1884  fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2) / ele.pt(), 2.5), 0.0);
1885  fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3) / ele.pt(), 2.5), 0.0);
1886  fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4) / ele.pt(), 2.5), 0.0);
1887  fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5) / ele.pt(), 2.5), 0.0);
1888  fMVAVar_rho = Rho;
1889  } else {
1890  std::cout << "Warning: Type " << fMVAType << " is not supported.\n";
1891  }
1892 
1893  // evaluate
1894  Double_t mva = -9999;
1895  if (fUseBinnedVersion) {
1897  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1898  } else {
1899  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1900  }
1901 
1902  if (printDebug) {
1903  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1904  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
1905  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
1906  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
1907  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " OneMinusE1x5E5x5 "
1908  << fMVAVar_OneMinusE1x5E5x5 << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP
1909  << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " d0 " << fMVAVar_d0
1910  << " ip3d " << fMVAVar_ip3d << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
1911  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_ChargedIso_DR0p0To0p1 << " "
1914  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_GammaIso_DR0p0To0p1 << " "
1916  << " " << fMVAVar_GammaIso_DR0p4To0p5 << std::endl;
1917  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_NeutralHadronIso_DR0p0To0p1
1920  std::cout << "Rho : " << Rho << std::endl;
1921  std::cout << " ### MVA " << mva << std::endl;
1922  }
1923 
1924  return mva;
1925 }
double pt() const final
transverse momentum
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< TMVA::Reader * > fTMVAReader
constexpr bool isFinite(T x)
float e1x5() const
Definition: GsfElectron.h:421
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
reco::TransientTrack build(const reco::Track *p) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
Definition: TTTypes.h:54
float e5x5() const
Definition: GsfElectron.h:423
T sqrt(T t)
Definition: SSEVec.h:19
bool isAvailable() const
Definition: Ref.h:541
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
UInt_t GetMVABin(double eta, double pt) const
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
float fbrem() const
Definition: GsfElectron.h:809
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
double phi() const final
momentum azimuthal angle
std::vector< TMVA::MethodBase * > fTMVAMethod
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float hadronicOverEm() const
Definition: GsfElectron.h:500
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
double eta() const final
momentum pseudorapidity

◆ IDIsoCombinedMvaValue() [2/2]

Double_t EGammaMvaEleEstimator::IDIsoCombinedMvaValue ( Double_t  fbrem,
Double_t  kfchi2,
Int_t  kfhits,
Double_t  gsfchi2,
Double_t  deta,
Double_t  dphi,
Double_t  detacalo,
Double_t  see,
Double_t  spp,
Double_t  etawidth,
Double_t  phiwidth,
Double_t  OneMinusE1x5E5x5,
Double_t  R9,
Double_t  HoE,
Double_t  EoP,
Double_t  IoEmIoP,
Double_t  eleEoPout,
Double_t  PreShowerOverRaw,
Double_t  d0,
Double_t  ip3d,
Double_t  ChargedIso_DR0p0To0p1,
Double_t  ChargedIso_DR0p1To0p2,
Double_t  ChargedIso_DR0p2To0p3,
Double_t  ChargedIso_DR0p3To0p4,
Double_t  ChargedIso_DR0p4To0p5,
Double_t  GammaIso_DR0p0To0p1,
Double_t  GammaIso_DR0p1To0p2,
Double_t  GammaIso_DR0p2To0p3,
Double_t  GammaIso_DR0p3To0p4,
Double_t  GammaIso_DR0p4To0p5,
Double_t  NeutralHadronIso_DR0p0To0p1,
Double_t  NeutralHadronIso_DR0p1To0p2,
Double_t  NeutralHadronIso_DR0p2To0p3,
Double_t  NeutralHadronIso_DR0p3To0p4,
Double_t  NeutralHadronIso_DR0p4To0p5,
Double_t  Rho,
Double_t  eta,
Double_t  pt,
Bool_t  printDebug = kFALSE 
)

Definition at line 711 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, gather_cfg::cout, d0, PVValHelper::eta, fisInitialized, dqmMemoryStats::float, fMethodname, fMVAVar_ChargedIso_DR0p0To0p1, fMVAVar_ChargedIso_DR0p1To0p2, fMVAVar_ChargedIso_DR0p2To0p3, fMVAVar_ChargedIso_DR0p3To0p4, fMVAVar_ChargedIso_DR0p4To0p5, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_GammaIso_DR0p0To0p1, fMVAVar_GammaIso_DR0p1To0p2, fMVAVar_GammaIso_DR0p2To0p3, fMVAVar_GammaIso_DR0p3To0p4, fMVAVar_GammaIso_DR0p4To0p5, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_NeutralHadronIso_DR0p0To0p1, fMVAVar_NeutralHadronIso_DR0p1To0p2, fMVAVar_NeutralHadronIso_DR0p2To0p3, fMVAVar_NeutralHadronIso_DR0p3To0p4, fMVAVar_NeutralHadronIso_DR0p4To0p5, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), electrons_cff::ip3d, SiStripPI::max, SiStripPI::min, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, DiDispStaMuonMonitor_cfi::pt, and nanoDQM_cfi::Rho.

749  {
750  if (!fisInitialized) {
751  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
752  return -9999;
753  }
754 
755  fMVAVar_fbrem = (fbrem < -1.0) ? -1.0 : fbrem;
756  fMVAVar_kfchi2 = (kfchi2 > 10) ? 10 : kfchi2;
757  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
758  fMVAVar_gsfchi2 = (gsfchi2 > 200) ? 200 : gsfchi2;
759  fMVAVar_deta = (fabs(deta) > 0.06) ? 0.06 : fabs(deta);
760  fMVAVar_dphi = dphi;
761  fMVAVar_detacalo = detacalo;
762 
763  fMVAVar_see = see;
764  fMVAVar_spp = spp;
765  fMVAVar_etawidth = etawidth;
766  fMVAVar_phiwidth = phiwidth;
767  fMVAVar_OneMinusE1x5E5x5 = std::max(std::min(double(OneMinusE1x5E5x5), 2.0), -1.0);
768  fMVAVar_R9 = (R9 > 5) ? 5 : R9;
769 
770  fMVAVar_HoE = HoE;
771  fMVAVar_EoP = (EoP > 20) ? 20 : EoP;
772  fMVAVar_IoEmIoP = IoEmIoP;
773  fMVAVar_eleEoPout = (eleEoPout > 20) ? 20 : eleEoPout;
774  fMVAVar_PreShowerOverRaw = PreShowerOverRaw;
775 
776  fMVAVar_d0 = d0;
777  fMVAVar_ip3d = ip3d;
778 
779  fMVAVar_ChargedIso_DR0p0To0p1 = ChargedIso_DR0p0To0p1;
780  fMVAVar_ChargedIso_DR0p1To0p2 = ChargedIso_DR0p1To0p2;
781  fMVAVar_ChargedIso_DR0p2To0p3 = ChargedIso_DR0p2To0p3;
782  fMVAVar_ChargedIso_DR0p3To0p4 = ChargedIso_DR0p3To0p4;
783  fMVAVar_ChargedIso_DR0p4To0p5 = ChargedIso_DR0p4To0p5;
784  fMVAVar_GammaIso_DR0p0To0p1 = GammaIso_DR0p0To0p1;
785  fMVAVar_GammaIso_DR0p1To0p2 = GammaIso_DR0p1To0p2;
786  fMVAVar_GammaIso_DR0p2To0p3 = GammaIso_DR0p2To0p3;
787  fMVAVar_GammaIso_DR0p3To0p4 = GammaIso_DR0p3To0p4;
788  fMVAVar_GammaIso_DR0p4To0p5 = GammaIso_DR0p4To0p5;
789  fMVAVar_NeutralHadronIso_DR0p0To0p1 = NeutralHadronIso_DR0p0To0p1;
790  fMVAVar_NeutralHadronIso_DR0p1To0p2 = NeutralHadronIso_DR0p1To0p2;
791  fMVAVar_NeutralHadronIso_DR0p2To0p3 = NeutralHadronIso_DR0p2To0p3;
792  fMVAVar_NeutralHadronIso_DR0p3To0p4 = NeutralHadronIso_DR0p3To0p4;
793  fMVAVar_NeutralHadronIso_DR0p4To0p5 = NeutralHadronIso_DR0p4To0p5;
794 
795  fMVAVar_rho = Rho;
796  fMVAVar_eta = eta;
797  fMVAVar_pt = pt;
798 
799  Double_t mva = -9999;
800  if (fUseBinnedVersion) {
802  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
803  } else {
804  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
805  }
806 
807  if (printDebug) {
808  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
809  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
810  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
811  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
812  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " OneMinusE1x5E5x5 "
813  << fMVAVar_OneMinusE1x5E5x5 << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP
814  << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " PreShowerOverRaw "
815  << fMVAVar_PreShowerOverRaw << " d0 " << fMVAVar_d0 << " ip3d " << fMVAVar_ip3d
816  << " ChargedIso_DR0p0To0p1 " << ChargedIso_DR0p0To0p1 << " ChargedIso_DR0p1To0p2 "
817  << ChargedIso_DR0p1To0p2 << " ChargedIso_DR0p2To0p3 " << ChargedIso_DR0p2To0p3
818  << " ChargedIso_DR0p3To0p4 " << ChargedIso_DR0p3To0p4 << " ChargedIso_DR0p4To0p5 "
819  << ChargedIso_DR0p4To0p5 << " GammaIso_DR0p0To0p1 " << GammaIso_DR0p0To0p1 << " GammaIso_DR0p1To0p2 "
820  << GammaIso_DR0p1To0p2 << " GammaIso_DR0p2To0p3 " << GammaIso_DR0p2To0p3 << " GammaIso_DR0p3To0p4 "
821  << GammaIso_DR0p3To0p4 << " GammaIso_DR0p4To0p5 " << GammaIso_DR0p4To0p5
822  << " NeutralHadronIso_DR0p0To0p1 " << NeutralHadronIso_DR0p0To0p1 << " NeutralHadronIso_DR0p1To0p2 "
823  << NeutralHadronIso_DR0p1To0p2 << " NeutralHadronIso_DR0p2To0p3 " << NeutralHadronIso_DR0p2To0p3
824  << " NeutralHadronIso_DR0p3To0p4 " << NeutralHadronIso_DR0p3To0p4 << " NeutralHadronIso_DR0p4To0p5 "
825  << NeutralHadronIso_DR0p4To0p5 << " Rho " << Rho << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt
826  << std::endl;
827  std::cout << " ### MVA " << mva << std::endl;
828  }
829 
830  return mva;
831 }
std::vector< TMVA::Reader * > fTMVAReader
static constexpr float d0
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::MethodBase * > fTMVAMethod

◆ initialize() [1/2]

void EGammaMvaEleEstimator::initialize ( std::string  methodName,
std::string  weightsfile,
EGammaMvaEleEstimator::MVAType  type 
)

Definition at line 42 of file EGammaMvaEleEstimator.cc.

Referenced by ElectronPATIdMVAProducer::ElectronPATIdMVAProducer(), and heppy::EGammaMvaEleEstimatorFWLite::initialize().

44  {
45  std::vector<std::string> tempWeightFileVector;
46  tempWeightFileVector.push_back(weightsfile);
47  initialize(methodName, type, kFALSE, tempWeightFileVector);
48 }
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)

◆ initialize() [2/2]

void EGammaMvaEleEstimator::initialize ( std::string  methodName,
EGammaMvaEleEstimator::MVAType  type,
Bool_t  useBinnedVersion,
std::vector< std::string >  weightsfiles 
)

Definition at line 51 of file EGammaMvaEleEstimator.cc.

References cms::cuda::assert(), gather_cfg::cout, data, Exception, geometryDiff::file, fisInitialized, fMethodname, fMVAType, fMVAVar_ChargedIso_DR0p0To0p1, fMVAVar_ChargedIso_DR0p1To0p2, fMVAVar_ChargedIso_DR0p2To0p3, fMVAVar_ChargedIso_DR0p3To0p4, fMVAVar_ChargedIso_DR0p4To0p5, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_GammaIso_DR0p0To0p1, fMVAVar_GammaIso_DR0p1To0p2, fMVAVar_GammaIso_DR0p2To0p3, fMVAVar_GammaIso_DR0p3To0p4, fMVAVar_GammaIso_DR0p4To0p5, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_NeutralHadronIso_DR0p0To0p1, fMVAVar_NeutralHadronIso_DR0p1To0p2, fMVAVar_NeutralHadronIso_DR0p2To0p3, fMVAVar_NeutralHadronIso_DR0p3To0p4, fMVAVar_NeutralHadronIso_DR0p4To0p5, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fNMVABins, fTMVAMethod, fTMVAReader, fUseBinnedVersion, mps_fire::i, kIsoRings, kNonTrig, kTrig, kTrigIDIsoCombined, kTrigIDIsoCombinedPUCorrected, kTrigNoIP, and fileinputsource_cfi::read.

54  {
55  //clean up first
56  for (unsigned int i = 0; i < fTMVAReader.size(); ++i) {
57  if (fTMVAReader[i])
58  delete fTMVAReader[i];
59  }
60  fTMVAReader.clear();
61  fTMVAMethod.clear();
62 
63  //initialize
64  fisInitialized = kTRUE;
65  fMVAType = type;
66  fMethodname = methodName;
67  fUseBinnedVersion = useBinnedVersion;
68 
69  //Define expected number of bins
70  UInt_t ExpectedNBins = 0;
71  if (!fUseBinnedVersion) {
72  ExpectedNBins = 1;
73  } else if (type == kTrig) {
74  ExpectedNBins = 6;
75  } else if (type == kTrigNoIP) {
76  ExpectedNBins = 6;
77  } else if (type == kNonTrig) {
78  ExpectedNBins = 6;
79  } else if (type == kIsoRings) {
80  ExpectedNBins = 4;
81  } else if (type == kTrigIDIsoCombined) {
82  ExpectedNBins = 6;
83  } else if (type == kTrigIDIsoCombinedPUCorrected) {
84  ExpectedNBins = 6;
85  }
86 
87  fNMVABins = ExpectedNBins;
88 
89  //Check number of weight files given
90  if (fNMVABins != weightsfiles.size()) {
91  std::cout << "Error: Expected Number of bins = " << fNMVABins
92  << " does not equal to weightsfiles.size() = " << weightsfiles.size() << std::endl;
93 
94 #ifndef STANDALONE
95  assert(fNMVABins == weightsfiles.size());
96 #endif
97  }
98 
99  //Loop over all bins
100  for (unsigned int i = 0; i < fNMVABins; ++i) {
101  TMVA::Reader* tmpTMVAReader = new TMVA::Reader("!Color:!Silent:Error");
102  tmpTMVAReader->SetVerbose(kTRUE);
103 
104  if (type == kTrig) {
105  // Pure tracking variables
106  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
107  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
108  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
109  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
110 
111  // Geometrical matchings
112  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
113  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
114  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
115 
116  // Pure ECAL -> shower shapes
117  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
118  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
119  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
120  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
121  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
122  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
123 
124  // Energy matching
125  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
126  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
127  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
128  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
129  if (i == 2 || i == 5)
130  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
131 
132  if (!fUseBinnedVersion)
133  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
134 
135  // IP
136  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
137  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
138 
139  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
140  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
141  }
142 
143  if (type == kTrigNoIP) {
144  // Pure tracking variables
145  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
146  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
147  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
148  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
149 
150  // Geometrical matchings
151  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
152  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
153  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
154 
155  // Pure ECAL -> shower shapes
156  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
157  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
158  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
159  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
160  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
161  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
162 
163  // Energy matching
164  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
165  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
166  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
167  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
168  tmpTMVAReader->AddVariable("rho", &fMVAVar_rho);
169 
170  if (i == 2 || i == 5)
171  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
172 
173  if (!fUseBinnedVersion)
174  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
175 
176  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
177  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
178  }
179 
180  if (type == kNonTrig) {
181  // Pure tracking variables
182  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
183  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
184  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
185  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
186 
187  // Geometrical matchings
188  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
189  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
190  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
191 
192  // Pure ECAL -> shower shapes
193  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
194  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
195  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
196  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
197  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
198  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
199 
200  // Energy matching
201  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
202  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
203  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
204  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
205  if (i == 2 || i == 5)
206  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
207 
208  if (!fUseBinnedVersion)
209  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
210 
211  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
212  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
213  }
214 
215  if (type == kIsoRings) {
216  tmpTMVAReader->AddVariable("ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1);
217  tmpTMVAReader->AddVariable("ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2);
218  tmpTMVAReader->AddVariable("ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3);
219  tmpTMVAReader->AddVariable("ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4);
220  tmpTMVAReader->AddVariable("ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5);
221  tmpTMVAReader->AddVariable("GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1);
222  tmpTMVAReader->AddVariable("GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2);
223  tmpTMVAReader->AddVariable("GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3);
224  tmpTMVAReader->AddVariable("GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4);
225  tmpTMVAReader->AddVariable("GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5);
226  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1);
227  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2);
228  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3);
229  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4);
230  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5);
231  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
232  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
233  }
234 
236  // Pure tracking variables
237  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
238  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
239  tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
240  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
241 
242  // Geometrical matchings
243  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
244  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
245  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
246 
247  // Pure ECAL -> shower shapes
248  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
249  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
250  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
251  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
252  tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
253  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
254 
255  // Energy matching
256  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
257  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
258  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
259  tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
260  if (i == 2 || i == 5) {
261  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
262  }
263  if (!fUseBinnedVersion) {
264  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
265  }
266 
267  // IP
268  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
269  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
270 
271  //isolation variables
272  tmpTMVAReader->AddVariable("ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1);
273  tmpTMVAReader->AddVariable("ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2);
274  tmpTMVAReader->AddVariable("ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3);
275  tmpTMVAReader->AddVariable("ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4);
276  tmpTMVAReader->AddVariable("ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5);
277  tmpTMVAReader->AddVariable("GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1);
278  tmpTMVAReader->AddVariable("GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2);
279  tmpTMVAReader->AddVariable("GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3);
280  tmpTMVAReader->AddVariable("GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4);
281  tmpTMVAReader->AddVariable("GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5);
282  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1);
283  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2);
284  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3);
285  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4);
286  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5);
287 
288  //spectators
289  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
290  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
291  }
292 
293  if (type == kTrigIDIsoCombined) {
294  // Pure tracking variables
295  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
296  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
297  tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
298  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
299 
300  // Geometrical matchings
301  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
302  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
303  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
304 
305  // Pure ECAL -> shower shapes
306  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
307  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
308  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
309  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
310  tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
311  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
312 
313  // Energy matching
314  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
315  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
316  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
317  tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
318  if (i == 2 || i == 5) {
319  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
320  }
321  if (!fUseBinnedVersion) {
322  tmpTMVAReader->AddVariable("PreShowerOverRaw", &fMVAVar_PreShowerOverRaw);
323  }
324 
325  // IP
326  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
327  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
328 
329  //isolation variables
330  tmpTMVAReader->AddVariable("ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1);
331  tmpTMVAReader->AddVariable("ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2);
332  tmpTMVAReader->AddVariable("ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3);
333  tmpTMVAReader->AddVariable("ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4);
334  tmpTMVAReader->AddVariable("ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5);
335  tmpTMVAReader->AddVariable("GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1);
336  tmpTMVAReader->AddVariable("GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2);
337  tmpTMVAReader->AddVariable("GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3);
338  tmpTMVAReader->AddVariable("GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4);
339  tmpTMVAReader->AddVariable("GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5);
340  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1);
341  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2);
342  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3);
343  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4);
344  tmpTMVAReader->AddVariable("NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5);
345  tmpTMVAReader->AddVariable("rho", &fMVAVar_rho);
346 
347  //spectators
348  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
349  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
350  }
351 
352 #ifndef STANDALONE
353  if ((fMethodname == "BDT") && (weightsfiles[i].rfind(".xml.gz") == weightsfiles[i].length() - strlen(".xml.gz"))) {
354  gzFile file = gzopen(weightsfiles[i].c_str(), "rb");
355  if (file == nullptr) {
356  std::cout << "Error opening gzip file associated to " << weightsfiles[i] << std::endl;
357  throw cms::Exception("Configuration", "Error reading zipped XML file");
358  }
359  std::vector<char> data;
360  data.reserve(1024 * 1024 * 10);
361  unsigned int bufflen = 32 * 1024;
362  char* buff = reinterpret_cast<char*>(malloc(bufflen));
363  if (buff == nullptr) {
364  std::cout << "Error creating buffer for " << weightsfiles[i] << std::endl;
365  gzclose(file);
366  throw cms::Exception("Configuration", "Error reading zipped XML file");
367  }
368  int read;
369  while ((read = gzread(file, buff, bufflen)) != 0) {
370  if (read == -1) {
371  std::cout << "Error reading gzip file associated to " << weightsfiles[i] << ": " << gzerror(file, &read)
372  << std::endl;
373  gzclose(file);
374  free(buff);
375  throw cms::Exception("Configuration", "Error reading zipped XML file");
376  }
377  data.insert(data.end(), buff, buff + read);
378  }
379  if (gzclose(file) != Z_OK) {
380  std::cout << "Error closing gzip file associated to " << weightsfiles[i] << std::endl;
381  }
382  free(buff);
383  data.push_back('\0'); // IMPORTANT
384  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(TMVA::Types::kBDT, &data[0])));
385  } else {
386  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(fMethodname, weightsfiles[i])));
387  }
388 #else
389  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(fMethodname, weightsfiles[i])));
390 #endif
391  std::cout << "MVABin " << i << " : MethodName = " << fMethodname << " , type == " << type << " , "
392  << "Load weights file : " << weightsfiles[i] << std::endl;
393  fTMVAReader.push_back(tmpTMVAReader);
394  }
395  std::cout << "Electron ID MVA Completed\n";
396 }
std::vector< TMVA::Reader * > fTMVAReader
assert(be >=bs)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< TMVA::MethodBase * > fTMVAMethod

◆ isInitialized()

Bool_t EGammaMvaEleEstimator::isInitialized ( ) const
inline

Definition at line 58 of file EGammaMvaEleEstimator.h.

References fisInitialized.

◆ isoMvaValue() [1/2]

Double_t EGammaMvaEleEstimator::isoMvaValue ( const reco::GsfElectron ele,
const reco::Vertex vertex,
const reco::PFCandidateCollection PFCandidates,
double  Rho,
ElectronEffectiveArea::ElectronEffectiveAreaTarget  EATarget,
const reco::GsfElectronCollection IdentifiedElectrons,
const reco::MuonCollection IdentifiedMuons,
bool  printDebug = kFALSE 
)

Definition at line 1348 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), reco::GsfElectron::closestCtfTrackRef(), funct::cos(), gather_cfg::cout, l1ctLayer1_cff::dr, reco::PFCandidate::e, reco::LeafCandidate::eta(), fisInitialized, fMethodname, fMVAType, fMVAVar_ChargedIso_DR0p0To0p1, fMVAVar_ChargedIso_DR0p1To0p2, fMVAVar_ChargedIso_DR0p2To0p3, fMVAVar_ChargedIso_DR0p3To0p4, fMVAVar_ChargedIso_DR0p4To0p5, fMVAVar_eta, fMVAVar_GammaIso_DR0p0To0p1, fMVAVar_GammaIso_DR0p1To0p2, fMVAVar_GammaIso_DR0p2To0p3, fMVAVar_GammaIso_DR0p3To0p4, fMVAVar_GammaIso_DR0p4To0p5, fMVAVar_NeutralHadronIso_DR0p0To0p1, fMVAVar_NeutralHadronIso_DR0p1To0p2, fMVAVar_NeutralHadronIso_DR0p2To0p3, fMVAVar_NeutralHadronIso_DR0p3To0p4, fMVAVar_NeutralHadronIso_DR0p4To0p5, fMVAVar_pt, fTMVAMethod, fTMVAReader, fUseBinnedVersion, reco::PFCandidate::gamma, ElectronEffectiveArea::GetElectronEffectiveArea(), GetMVABin(), reco::GsfElectron::gsfTrack(), edm::Ref< C, T, F >::isNonnull(), ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, METSkim_cff::Max, METSkim_cff::Min, reco::PFCandidate::mu, beam_dqm_sourceclient-live_cfg::mva, hltParticleFlowSoftKiller_cfi::PFCandidates, reco::LeafCandidate::phi(), funct::pow(), HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), edm::refToPtr(), nanoDQM_cfi::Rho, mathSSE::sqrt(), reco::GsfElectron::superCluster(), and bphysicsOniaDQM_cfi::vertex.

1355  {
1356  if (!fisInitialized) {
1357  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1358  return -9999;
1359  }
1360 
1361  // Spectators
1362  fMVAVar_eta = ele.superCluster()->eta();
1363  fMVAVar_pt = ele.pt();
1364 
1365  //**********************************************************
1366  //Isolation variables
1367  //**********************************************************
1368  Double_t tmpChargedIso_DR0p0To0p1 = 0;
1369  Double_t tmpChargedIso_DR0p1To0p2 = 0;
1370  Double_t tmpChargedIso_DR0p2To0p3 = 0;
1371  Double_t tmpChargedIso_DR0p3To0p4 = 0;
1372  Double_t tmpChargedIso_DR0p4To0p5 = 0;
1373  Double_t tmpGammaIso_DR0p0To0p1 = 0;
1374  Double_t tmpGammaIso_DR0p1To0p2 = 0;
1375  Double_t tmpGammaIso_DR0p2To0p3 = 0;
1376  Double_t tmpGammaIso_DR0p3To0p4 = 0;
1377  Double_t tmpGammaIso_DR0p4To0p5 = 0;
1378  Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
1379  Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
1380  Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
1381  Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
1382  Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
1383 
1384  double electronTrackZ = 0;
1385  if (ele.gsfTrack().isNonnull()) {
1386  electronTrackZ = ele.gsfTrack()->dz(vertex.position());
1387  } else if (ele.closestCtfTrackRef().isNonnull()) {
1388  electronTrackZ = ele.closestCtfTrackRef()->dz(vertex.position());
1389  }
1390 
1391  for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin(); iP != PFCandidates.end(); ++iP) {
1392  //exclude the electron itself
1393  if (iP->gsfTrackRef().isNonnull() && ele.gsfTrack().isNonnull() &&
1394  refToPtr(iP->gsfTrackRef()) == refToPtr(ele.gsfTrack()))
1395  continue;
1396  if (iP->trackRef().isNonnull() && ele.closestCtfTrackRef().isNonnull() &&
1397  refToPtr(iP->trackRef()) == refToPtr(ele.closestCtfTrackRef()))
1398  continue;
1399 
1400  //************************************************************
1401  // New Isolation Calculations
1402  //************************************************************
1403  double dr = sqrt(pow(iP->eta() - ele.eta(), 2) + pow(acos(cos(iP->phi() - ele.phi())), 2));
1404  //Double_t deta = (iP->eta() - ele.eta());
1405 
1406  if (dr < 1.0) {
1407  Bool_t IsLeptonFootprint = kFALSE;
1408  //************************************************************
1409  // Lepton Footprint Removal
1410  //************************************************************
1411  for (reco::GsfElectronCollection::const_iterator iE = IdentifiedElectrons.begin();
1412  iE != IdentifiedElectrons.end();
1413  ++iE) {
1414  //if pf candidate matches an electron passing ID cuts, then veto it
1415  if (iP->gsfTrackRef().isNonnull() && iE->gsfTrack().isNonnull() &&
1416  refToPtr(iP->gsfTrackRef()) == refToPtr(iE->gsfTrack()))
1417  IsLeptonFootprint = kTRUE;
1418  if (iP->trackRef().isNonnull() && iE->closestCtfTrackRef().isNonnull() &&
1419  refToPtr(iP->trackRef()) == refToPtr(iE->closestCtfTrackRef()))
1420  IsLeptonFootprint = kTRUE;
1421 
1422  //if pf candidate lies in veto regions of electron passing ID cuts, then veto it
1423  double tmpDR = sqrt(pow(iP->eta() - iE->eta(), 2) + pow(acos(cos(iP->phi() - iE->phi())), 2));
1424  if (iP->trackRef().isNonnull() && fabs(iE->superCluster()->eta()) >= 1.479 && tmpDR < 0.015)
1425  IsLeptonFootprint = kTRUE;
1426  if (iP->particleId() == reco::PFCandidate::gamma && fabs(iE->superCluster()->eta()) >= 1.479 && tmpDR < 0.08)
1427  IsLeptonFootprint = kTRUE;
1428  }
1429  for (reco::MuonCollection::const_iterator iM = IdentifiedMuons.begin(); iM != IdentifiedMuons.end(); ++iM) {
1430  //if pf candidate matches an muon passing ID cuts, then veto it
1431  if (iP->trackRef().isNonnull() && iM->innerTrack().isNonnull() &&
1432  refToPtr(iP->trackRef()) == refToPtr(iM->innerTrack()))
1433  IsLeptonFootprint = kTRUE;
1434 
1435  //if pf candidate lies in veto regions of muon passing ID cuts, then veto it
1436  double tmpDR = sqrt(pow(iP->eta() - iM->eta(), 2) + pow(acos(cos(iP->phi() - iM->phi())), 2));
1437  if (iP->trackRef().isNonnull() && tmpDR < 0.01)
1438  IsLeptonFootprint = kTRUE;
1439  }
1440 
1441  if (!IsLeptonFootprint) {
1442  Bool_t passVeto = kTRUE;
1443  //Charged
1444  if (iP->trackRef().isNonnull()) {
1445  if (!(fabs(iP->trackRef()->dz(vertex.position()) - electronTrackZ) < 0.2))
1446  passVeto = kFALSE;
1447  //************************************************************
1448  // Veto any PFmuon, or PFEle
1449  if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu)
1450  passVeto = kFALSE;
1451  //************************************************************
1452  //************************************************************
1453  // Footprint Veto
1454  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015)
1455  passVeto = kFALSE;
1456  //************************************************************
1457  if (passVeto) {
1458  if (dr < 0.1)
1459  tmpChargedIso_DR0p0To0p1 += iP->pt();
1460  if (dr >= 0.1 && dr < 0.2)
1461  tmpChargedIso_DR0p1To0p2 += iP->pt();
1462  if (dr >= 0.2 && dr < 0.3)
1463  tmpChargedIso_DR0p2To0p3 += iP->pt();
1464  if (dr >= 0.3 && dr < 0.4)
1465  tmpChargedIso_DR0p3To0p4 += iP->pt();
1466  if (dr >= 0.4 && dr < 0.5)
1467  tmpChargedIso_DR0p4To0p5 += iP->pt();
1468  } //pass veto
1469  }
1470  //Gamma
1471  else if (iP->particleId() == reco::PFCandidate::gamma) {
1472  //************************************************************
1473  // Footprint Veto
1474  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08)
1475  passVeto = kFALSE;
1476  //************************************************************
1477  if (passVeto) {
1478  if (dr < 0.1)
1479  tmpGammaIso_DR0p0To0p1 += iP->pt();
1480  if (dr >= 0.1 && dr < 0.2)
1481  tmpGammaIso_DR0p1To0p2 += iP->pt();
1482  if (dr >= 0.2 && dr < 0.3)
1483  tmpGammaIso_DR0p2To0p3 += iP->pt();
1484  if (dr >= 0.3 && dr < 0.4)
1485  tmpGammaIso_DR0p3To0p4 += iP->pt();
1486  if (dr >= 0.4 && dr < 0.5)
1487  tmpGammaIso_DR0p4To0p5 += iP->pt();
1488  }
1489  }
1490  //NeutralHadron
1491  else {
1492  if (dr < 0.1)
1493  tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
1494  if (dr >= 0.1 && dr < 0.2)
1495  tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
1496  if (dr >= 0.2 && dr < 0.3)
1497  tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
1498  if (dr >= 0.3 && dr < 0.4)
1499  tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
1500  if (dr >= 0.4 && dr < 0.5)
1501  tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
1502  }
1503  } //not lepton footprint
1504  } //in 1.0 dr cone
1505  } //loop over PF candidates
1506 
1507  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1) / ele.pt(), 2.5);
1508  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2) / ele.pt(), 2.5);
1509  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3) / ele.pt(), 2.5);
1510  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4) / ele.pt(), 2.5);
1511  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5) / ele.pt(), 2.5);
1513  TMath::Min(
1514  (tmpGammaIso_DR0p0To0p1 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1516  ele.pt(),
1517  2.5),
1518  0.0);
1520  TMath::Min(
1521  (tmpGammaIso_DR0p1To0p2 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1523  ele.pt(),
1524  2.5),
1525  0.0);
1527  TMath::Min(
1528  (tmpGammaIso_DR0p2To0p3 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1530  ele.pt(),
1531  2.5),
1532  0.0);
1534  TMath::Min(
1535  (tmpGammaIso_DR0p3To0p4 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1537  ele.pt(),
1538  2.5),
1539  0.0);
1541  TMath::Min(
1542  (tmpGammaIso_DR0p4To0p5 - Rho * ElectronEffectiveArea::GetElectronEffectiveArea(
1544  ele.pt(),
1545  2.5),
1546  0.0);
1548  TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1 -
1551  ele.pt(),
1552  2.5),
1553  0.0);
1555  TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2 -
1558  ele.pt(),
1559  2.5),
1560  0.0);
1562  TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3 -
1565  ele.pt(),
1566  2.5),
1567  0.0);
1569  TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4 -
1572  ele.pt(),
1573  2.5),
1574  0.0);
1576  TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5 -
1579  ele.pt(),
1580  2.5),
1581  0.0);
1582 
1583  if (printDebug) {
1584  std::cout << "UseBinnedVersion=" << fUseBinnedVersion << " -> BIN: " << fMVAVar_eta << " " << fMVAVar_pt << " : "
1585  << GetMVABin(fMVAVar_eta, fMVAVar_pt) << std::endl;
1586  }
1587 
1588  // evaluate
1589  bindVariables();
1590  Double_t mva = -9999;
1591 
1592  // mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
1593  if (fUseBinnedVersion) {
1595  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1596  } else {
1597  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1598  }
1599 
1600  if (printDebug) {
1601  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1602  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_ChargedIso_DR0p0To0p1 << " "
1605  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_GammaIso_DR0p0To0p1 << " "
1607  << " " << fMVAVar_GammaIso_DR0p4To0p5 << std::endl;
1608  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_NeutralHadronIso_DR0p0To0p1
1611  std::cout << " ### MVA " << mva << std::endl;
1612  }
1613 
1614  return mva;
1615 }
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
double pt() const final
transverse momentum
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< TMVA::Reader * > fTMVAReader
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
UInt_t GetMVABin(double eta, double pt) const
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
double phi() const final
momentum azimuthal angle
std::vector< TMVA::MethodBase * > fTMVAMethod
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
double eta() const final
momentum pseudorapidity

◆ isoMvaValue() [2/2]

Double_t EGammaMvaEleEstimator::isoMvaValue ( Double_t  Pt,
Double_t  Eta,
Double_t  Rho,
ElectronEffectiveArea::ElectronEffectiveAreaTarget  EATarget,
Double_t  ChargedIso_DR0p0To0p1,
Double_t  ChargedIso_DR0p1To0p2,
Double_t  ChargedIso_DR0p2To0p3,
Double_t  ChargedIso_DR0p3To0p4,
Double_t  ChargedIso_DR0p4To0p5,
Double_t  GammaIso_DR0p0To0p1,
Double_t  GammaIso_DR0p1To0p2,
Double_t  GammaIso_DR0p2To0p3,
Double_t  GammaIso_DR0p3To0p4,
Double_t  GammaIso_DR0p4To0p5,
Double_t  NeutralHadronIso_DR0p0To0p1,
Double_t  NeutralHadronIso_DR0p1To0p2,
Double_t  NeutralHadronIso_DR0p2To0p3,
Double_t  NeutralHadronIso_DR0p3To0p4,
Double_t  NeutralHadronIso_DR0p4To0p5,
Bool_t  printDebug = kFALSE 
)

Definition at line 834 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, gather_cfg::cout, fisInitialized, fMethodname, fMVAType, fMVAVar_ChargedIso_DR0p0To0p1, fMVAVar_ChargedIso_DR0p1To0p2, fMVAVar_ChargedIso_DR0p2To0p3, fMVAVar_ChargedIso_DR0p3To0p4, fMVAVar_ChargedIso_DR0p4To0p5, fMVAVar_GammaIso_DR0p0To0p1, fMVAVar_GammaIso_DR0p1To0p2, fMVAVar_GammaIso_DR0p2To0p3, fMVAVar_GammaIso_DR0p3To0p4, fMVAVar_GammaIso_DR0p4To0p5, fMVAVar_NeutralHadronIso_DR0p0To0p1, fMVAVar_NeutralHadronIso_DR0p1To0p2, fMVAVar_NeutralHadronIso_DR0p2To0p3, fMVAVar_NeutralHadronIso_DR0p3To0p4, fMVAVar_NeutralHadronIso_DR0p4To0p5, fTMVAMethod, fTMVAReader, ElectronEffectiveArea::GetElectronEffectiveArea(), GetMVABin(), ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, METSkim_cff::Max, METSkim_cff::Min, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, and nanoDQM_cfi::Rho.

853  {
854  if (!fisInitialized) {
855  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
856  return -9999;
857  }
858 
859  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((ChargedIso_DR0p0To0p1) / Pt, 2.5);
860  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((ChargedIso_DR0p1To0p2) / Pt, 2.5);
861  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((ChargedIso_DR0p2To0p3) / Pt, 2.5);
862  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((ChargedIso_DR0p3To0p4) / Pt, 2.5);
863  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((ChargedIso_DR0p4To0p5) / Pt, 2.5);
867  Pt,
868  2.5),
869  0.0);
873  Pt,
874  2.5),
875  0.0);
879  Pt,
880  2.5),
881  0.0);
885  Pt,
886  2.5),
887  0.0);
891  Pt,
892  2.5),
893  0.0);
895  TMath::Max(TMath::Min((NeutralHadronIso_DR0p0To0p1 -
898  Pt,
899  2.5),
900  0.0);
902  TMath::Max(TMath::Min((NeutralHadronIso_DR0p1To0p2 -
905  Pt,
906  2.5),
907  0.0);
909  TMath::Max(TMath::Min((NeutralHadronIso_DR0p2To0p3 -
912  Pt,
913  2.5),
914  0.0);
916  TMath::Max(TMath::Min((NeutralHadronIso_DR0p3To0p4 -
919  Pt,
920  2.5),
921  0.0);
923  TMath::Max(TMath::Min((NeutralHadronIso_DR0p4To0p5 -
926  Pt,
927  2.5),
928  0.0);
929 
930  // evaluate
931  int bin = GetMVABin(Eta, Pt);
932  Double_t mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
933 
934  if (printDebug) {
935  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
936  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_ChargedIso_DR0p0To0p1 << " "
939  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_GammaIso_DR0p0To0p1 << " "
941  << " " << fMVAVar_GammaIso_DR0p4To0p5 << std::endl;
942  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): " << fMVAVar_NeutralHadronIso_DR0p0To0p1
945  std::cout << " ### MVA " << mva << std::endl;
946  }
947 
948  return mva;
949 }
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
std::vector< TMVA::Reader * > fTMVAReader
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::MethodBase * > fTMVAMethod

◆ mvaValue() [1/7]

Double_t EGammaMvaEleEstimator::mvaValue ( const reco::GsfElectron ele,
const reco::Vertex vertex,
const TransientTrackBuilder transientTrackBuilder,
EcalClusterLazyTools const &  myEcalCluster,
bool  printDebug = kFALSE 
)

Definition at line 954 of file EGammaMvaEleEstimator.cc.

References IPTools::absoluteImpactParameter3D(), newFWLiteAna::bin, bindVariables(), TransientTrackBuilder::build(), reco::GsfElectron::closestCtfTrackRef(), gather_cfg::cout, reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::ecalEnergy(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::GsfElectron::fbrem(), fisInitialized, fMethodname, fMVAType, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_ip3dSig, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_kfhitsall, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), electrons_cff::ip3d, edm::Ref< C, T, F >::isAvailable(), edm::isFinite(), edm::Ref< C, T, F >::isNonnull(), kNonTrig, kTrig, beam_dqm_sourceclient-live_cfg::mva, reco::LeafCandidate::p(), HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), reco::GsfElectron::sigmaIetaIeta(), mathSSE::sqrt(), reco::GsfElectron::superCluster(), and bphysicsOniaDQM_cfi::vertex.

Referenced by ElectronIdMVAProducer::filter(), heppy::EGammaMvaEleEstimatorFWLite::mvaValue(), and ElectronPATIdMVAProducer::produce().

958  {
959  if (!fisInitialized) {
960  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
961  return -9999;
962  }
963 
965  std::cout << "Error: This method should be called for kTrig or kNonTrig MVA only" << std::endl;
966  return -9999;
967  }
968 
969  bool validKF = false;
970  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
971  validKF = (myTrackRef.isAvailable());
972  validKF &= (myTrackRef.isNonnull());
973 
974  // Pure tracking variables
975  fMVAVar_fbrem = ele.fbrem();
976  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
977  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
979  (validKF) ? myTrackRef->numberOfValidHits() : -1.; // save also this in your ntuple as possible alternative
980  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
981 
982  // Geometrical matchings
986 
987  // Pure ECAL -> shower shapes
988  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
989  const auto& vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed()));
990  if (edm::isFinite(vCov[2]))
991  fMVAVar_spp = sqrt(vCov[2]); //EleSigmaIPhiIPhi
992  else
993  fMVAVar_spp = 0.;
994 
995  fMVAVar_etawidth = ele.superCluster()->etaWidth();
996  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
997  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) != 0. ? 1. - (ele.e1x5() / ele.e5x5()) : -1.;
998  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
999 
1000  // Energy matching
1001  fMVAVar_HoE = ele.hadronicOverEm();
1003  fMVAVar_IoEmIoP = (1.0 / ele.ecalEnergy()) - (1.0 / ele.p()); // in the future to be changed with ele.gsfTrack()->p()
1005  fMVAVar_PreShowerOverRaw = ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1006 
1007  // Spectators
1008  fMVAVar_eta = ele.superCluster()->eta();
1009  fMVAVar_pt = ele.pt();
1010 
1011  // for triggering electrons get the impact parameteres
1012  if (fMVAType == kTrig) {
1013  //d0
1014  if (ele.gsfTrack().isNonnull()) {
1015  fMVAVar_d0 = (-1.0) * ele.gsfTrack()->dxy(vertex.position());
1016  } else if (ele.closestCtfTrackRef().isNonnull()) {
1017  fMVAVar_d0 = (-1.0) * ele.closestCtfTrackRef()->dxy(vertex.position());
1018  } else {
1019  fMVAVar_d0 = -9999.0;
1020  }
1021 
1022  //default values for IP3D
1023  fMVAVar_ip3d = -999.0;
1024  fMVAVar_ip3dSig = 0.0;
1025  if (ele.gsfTrack().isNonnull()) {
1026  const double gsfsign = ((-ele.gsfTrack()->dxy(vertex.position())) >= 0) ? 1. : -1.;
1027 
1028  const reco::TransientTrack& tt = transientTrackBuilder.build(ele.gsfTrack());
1029  const std::pair<bool, Measurement1D>& ip3dpv = IPTools::absoluteImpactParameter3D(tt, vertex);
1030  if (ip3dpv.first) {
1031  double ip3d = gsfsign * ip3dpv.second.value();
1032  double ip3derr = ip3dpv.second.error();
1033  fMVAVar_ip3d = ip3d;
1034  fMVAVar_ip3dSig = ip3d / ip3derr;
1035  }
1036  }
1037  }
1038 
1039  // evaluate
1040  bindVariables();
1041  Double_t mva = -9999;
1042  if (fUseBinnedVersion) {
1044  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1045  } else {
1046  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1047  }
1048 
1049  if (printDebug) {
1050  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1051  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
1052  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
1053  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
1054  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " OneMinusE1x5E5x5 "
1055  << fMVAVar_OneMinusE1x5E5x5 << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP
1056  << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " d0 " << fMVAVar_d0
1057  << " ip3d " << fMVAVar_ip3d << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
1058  std::cout << " ### MVA " << mva << std::endl;
1059  }
1060 
1061  return mva;
1062 }
double pt() const final
transverse momentum
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:38
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< TMVA::Reader * > fTMVAReader
constexpr bool isFinite(T x)
float e1x5() const
Definition: GsfElectron.h:421
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
reco::TransientTrack build(const reco::Track *p) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
Definition: TTTypes.h:54
double p() const final
magnitude of momentum vector
float e5x5() const
Definition: GsfElectron.h:423
T sqrt(T t)
Definition: SSEVec.h:19
bool isAvailable() const
Definition: Ref.h:541
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float ecalEnergy() const
Definition: GsfElectron.h:896
UInt_t GetMVABin(double eta, double pt) const
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
float fbrem() const
Definition: GsfElectron.h:809
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
std::vector< TMVA::MethodBase * > fTMVAMethod
float hadronicOverEm() const
Definition: GsfElectron.h:500
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155

◆ mvaValue() [2/7]

Double_t EGammaMvaEleEstimator::mvaValue ( const reco::GsfElectron ele,
const reco::Vertex vertex,
double  rho,
EcalClusterLazyTools const &  myEcalCluster,
bool  printDebug = kFALSE 
)

Definition at line 1065 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), reco::GsfElectron::closestCtfTrackRef(), gather_cfg::cout, reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::GsfElectron::fbrem(), fisInitialized, fMethodname, fMVAType, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), edm::Ref< C, T, F >::isAvailable(), edm::isFinite(), edm::Ref< C, T, F >::isNonnull(), kTrigNoIP, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), rho, reco::GsfElectron::sigmaIetaIeta(), mathSSE::sqrt(), and reco::GsfElectron::superCluster().

1070  {
1071  if (!fisInitialized) {
1072  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1073  return -9999;
1074  }
1075 
1077  std::cout << "Error: This method should be called for kTrigNoIP MVA only" << std::endl;
1078  return -9999;
1079  }
1080 
1081  bool validKF = false;
1082  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1083  validKF = (myTrackRef.isAvailable());
1084  validKF &= (myTrackRef.isNonnull());
1085 
1086  // Pure tracking variables
1087  fMVAVar_fbrem = ele.fbrem();
1088  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
1089  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
1090  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1091 
1092  // Geometrical matchings
1096 
1097  // Pure ECAL -> shower shapes
1098  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1099  const auto& vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed()));
1100  if (edm::isFinite(vCov[2]))
1101  fMVAVar_spp = sqrt(vCov[2]); //EleSigmaIPhiIPhi
1102  else
1103  fMVAVar_spp = 0.;
1104 
1105  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1106  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1107  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) != 0. ? 1. - (ele.e1x5() / ele.e5x5()) : -1.;
1108  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
1109 
1110  // Energy matching
1111  fMVAVar_HoE = ele.hadronicOverEm();
1113  fMVAVar_IoEmIoP = (1.0 / ele.superCluster()->energy()) -
1114  (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1116  fMVAVar_rho = rho;
1117  fMVAVar_PreShowerOverRaw = ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1118 
1119  // Spectators
1120  fMVAVar_eta = ele.superCluster()->eta();
1121  fMVAVar_pt = ele.pt();
1122 
1123  // evaluate
1124  bindVariables();
1125  Double_t mva = -9999;
1126  if (fUseBinnedVersion) {
1128  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1129  } else {
1130  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1131  }
1132 
1133  if (printDebug) {
1134  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1135  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
1136  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
1137  << fMVAVar_detacalo
1138  // << " dphicalo " << fMVAVar_dphicalo
1139  << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth " << fMVAVar_etawidth << " phiwidth "
1140  << fMVAVar_phiwidth << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5 << " R9 "
1141  << fMVAVar_R9
1142  // << " mynbrems " << fMVAVar_nbrems
1143  << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout "
1144  << fMVAVar_eleEoPout << " rho "
1145  << fMVAVar_rho
1146  // << " EoPout " << fMVAVar_EoPout
1147  << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
1148  std::cout << " ### MVA " << mva << std::endl;
1149  }
1150 
1151  return mva;
1152 }
double pt() const final
transverse momentum
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< TMVA::Reader * > fTMVAReader
constexpr bool isFinite(T x)
float e1x5() const
Definition: GsfElectron.h:421
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
float e5x5() const
Definition: GsfElectron.h:423
T sqrt(T t)
Definition: SSEVec.h:19
bool isAvailable() const
Definition: Ref.h:541
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
UInt_t GetMVABin(double eta, double pt) const
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
float fbrem() const
Definition: GsfElectron.h:809
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
std::vector< TMVA::MethodBase * > fTMVAMethod
float hadronicOverEm() const
Definition: GsfElectron.h:500
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155

◆ mvaValue() [3/7]

Double_t EGammaMvaEleEstimator::mvaValue ( const pat::Electron ele,
double  rho,
bool  printDebug = kFALSE 
)

Definition at line 1267 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), pat::Electron::closestCtfTrackRef(), gather_cfg::cout, reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::GsfElectron::fbrem(), fisInitialized, fMethodname, fMVAType, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), pat::Electron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), kTrigNoIP, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), reco::GsfElectron::r9(), rho, reco::GsfElectron::sigmaIetaIeta(), reco::GsfElectron::sigmaIphiIphi(), and pat::Electron::superCluster().

1267  {
1268  if (!fisInitialized) {
1269  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1270  return -9999;
1271  }
1272 
1274  std::cout << "Error: This method should be called for kTrigNoIP mva only" << std::endl;
1275  return -9999;
1276  }
1277 
1278  bool validKF = false;
1279  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1280  validKF = (myTrackRef.isAvailable());
1281  validKF &= (myTrackRef.isNonnull());
1282 
1283  // Pure tracking variables
1284  fMVAVar_fbrem = ele.fbrem();
1285  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
1286  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
1287  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1288 
1289  // Geometrical matchings
1293 
1294  // Pure ECAL -> shower shapes
1295  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1296 
1297  fMVAVar_spp = ele.sigmaIphiIphi();
1298 
1299  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1300  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1301  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) != 0. ? 1. - (ele.e1x5() / ele.e5x5()) : -1.;
1302  fMVAVar_R9 = ele.r9();
1303 
1304  // Energy matching
1305  fMVAVar_HoE = ele.hadronicOverEm();
1307  fMVAVar_IoEmIoP = (1.0 / ele.superCluster()->energy()) -
1308  (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1310  fMVAVar_rho = rho;
1311  fMVAVar_PreShowerOverRaw = ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1312 
1313  // Spectators
1314  fMVAVar_eta = ele.superCluster()->eta();
1315  fMVAVar_pt = ele.pt();
1316 
1317  // evaluate
1318  bindVariables();
1319  Double_t mva = -9999;
1320  if (fUseBinnedVersion) {
1322  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1323  } else {
1324  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1325  }
1326 
1327  if (printDebug) {
1328  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1329  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
1330  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
1331  << fMVAVar_detacalo
1332  // << " dphicalo " << fMVAVar_dphicalo
1333  << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth " << fMVAVar_etawidth << " phiwidth "
1334  << fMVAVar_phiwidth << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5 << " R9 "
1335  << fMVAVar_R9
1336  // << " mynbrems " << fMVAVar_nbrems
1337  << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout "
1338  << fMVAVar_eleEoPout << " rho "
1339  << fMVAVar_rho
1340  // << " EoPout " << fMVAVar_EoPout
1341  << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
1342  std::cout << " ### MVA " << mva << std::endl;
1343  }
1344 
1345  return mva;
1346 }
double pt() const final
transverse momentum
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
std::vector< TMVA::Reader * > fTMVAReader
float e1x5() const
Definition: GsfElectron.h:421
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
float e5x5() const
Definition: GsfElectron.h:423
bool isAvailable() const
Definition: Ref.h:541
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
UInt_t GetMVABin(double eta, double pt) const
float fbrem() const
Definition: GsfElectron.h:809
float r9() const
Definition: GsfElectron.h:424
float sigmaIphiIphi() const
Definition: GsfElectron.h:420
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
std::vector< TMVA::MethodBase * > fTMVAMethod
float hadronicOverEm() const
Definition: GsfElectron.h:500

◆ mvaValue() [4/7]

Double_t EGammaMvaEleEstimator::mvaValue ( const pat::Electron ele,
const reco::Vertex vertex,
double  rho,
bool  useFull5x5 = kFALSE,
bool  printDebug = kFALSE 
)

Definition at line 1155 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), pat::Electron::closestCtfTrackRef(), gather_cfg::cout, pat::Electron::dB(), reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::ecalEnergy(), pat::Electron::edB(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::GsfElectron::fbrem(), fisInitialized, fMethodname, fMVAType, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_ip3dSig, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, reco::GsfElectron::full5x5_e1x5(), reco::GsfElectron::full5x5_e5x5(), reco::GsfElectron::full5x5_r9(), reco::GsfElectron::full5x5_sigmaIetaIeta(), reco::GsfElectron::full5x5_sigmaIphiIphi(), fUseBinnedVersion, GetMVABin(), pat::Electron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), electrons_cff::ip3d, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), kNonTrig, kTrig, beam_dqm_sourceclient-live_cfg::mva, reco::LeafCandidate::p(), HLT_2023v12_cff::printDebug, reco::LeafCandidate::pt(), reco::GsfElectron::r9(), rho, reco::GsfElectron::sigmaIetaIeta(), reco::GsfElectron::sigmaIphiIphi(), pat::Electron::superCluster(), and bphysicsOniaDQM_cfi::vertex.

1156  {
1157  if (!fisInitialized) {
1158  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1159  return -9999;
1160  }
1161 
1162  bool validKF = false;
1163  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1164  validKF = (myTrackRef.isAvailable());
1165  validKF &= (myTrackRef.isNonnull());
1166 
1167  // Pure tracking variables
1168  fMVAVar_fbrem = ele.fbrem();
1169  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
1170  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
1171  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1172 
1173  // Geometrical matchings
1177 
1178  // Pure ECAL -> shower shapes
1179  fMVAVar_see = useFull5x5 ? ele.full5x5_sigmaIetaIeta() : ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1180  fMVAVar_spp = useFull5x5 ? ele.full5x5_sigmaIphiIphi() : ele.sigmaIphiIphi(); //EleSigmaIEtaIEta
1181 
1182  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1183  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1184  fMVAVar_OneMinusE1x5E5x5 = useFull5x5
1185  ? ((ele.full5x5_e5x5()) != 0. ? 1. - (ele.full5x5_e1x5() / ele.full5x5_e5x5()) : -1.)
1186  : ((ele.e5x5()) != 0. ? 1. - (ele.e1x5() / ele.e5x5()) : -1.);
1187  fMVAVar_R9 = useFull5x5 ? ele.full5x5_r9() : ele.r9();
1188 
1189  // Energy matching
1190  fMVAVar_HoE = ele.hadronicOverEm(); // this is identical for both
1192 
1193  // unify this in the future?
1194  if (fMVAType == kTrig || fMVAType == kNonTrig) {
1195  fMVAVar_IoEmIoP =
1196  (1.0 / ele.ecalEnergy()) - (1.0 / ele.p()); // in the future to be changed with ele.gsfTrack()->p()
1197  } else {
1198  fMVAVar_IoEmIoP = (1.0 / ele.superCluster()->energy()) -
1199  (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1200  }
1202  fMVAVar_rho = rho;
1203  fMVAVar_PreShowerOverRaw = ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1204 
1205  // for triggering electrons get the impact parameteres
1206  if (fMVAType == kTrig) {
1207  //d0
1208  if (ele.gsfTrack().isNonnull()) {
1209  fMVAVar_d0 = (-1.0) * ele.gsfTrack()->dxy(vertex.position());
1210  } else if (ele.closestCtfTrackRef().isNonnull()) {
1211  fMVAVar_d0 = (-1.0) * ele.closestCtfTrackRef()->dxy(vertex.position());
1212  } else {
1213  fMVAVar_d0 = -9999.0;
1214  }
1215 
1216  //default values for IP3D
1217  fMVAVar_ip3d = -999.0;
1218  fMVAVar_ip3dSig = 0.0;
1219  if (ele.gsfTrack().isNonnull()) {
1220  const double gsfsign = ((-ele.gsfTrack()->dxy(vertex.position())) >= 0) ? 1. : -1.;
1221 
1222  //std::cout << "Warning : if usePV = false when pat-electrons were produced, dB() was calculated with respect to beamspot while original mva uses primary vertex" << std::endl;
1223  double ip3d = gsfsign * ele.dB();
1224  double ip3derr = ele.edB();
1225  fMVAVar_ip3d = ip3d;
1226  fMVAVar_ip3dSig = ip3d / ip3derr;
1227  }
1228  }
1229 
1230  // Spectators
1231  fMVAVar_eta = ele.superCluster()->eta();
1232  fMVAVar_pt = ele.pt();
1233 
1234  // evaluate
1235  bindVariables();
1236  Double_t mva = -9999;
1237  if (fUseBinnedVersion) {
1239  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1240  } else {
1241  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1242  }
1243 
1244  if (printDebug) {
1245  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
1246  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
1247  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
1248  << fMVAVar_detacalo
1249  // << " dphicalo " << fMVAVar_dphicalo
1250  << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth " << fMVAVar_etawidth << " phiwidth "
1251  << fMVAVar_phiwidth << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5 << " R9 "
1252  << fMVAVar_R9
1253  // << " mynbrems " << fMVAVar_nbrems
1254  << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout "
1255  << fMVAVar_eleEoPout << " rho "
1256  << fMVAVar_rho
1257  // << " EoPout " << fMVAVar_EoPout
1258  << " d0 " << fMVAVar_d0 << " ip3d " << fMVAVar_ip3d << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt
1259  << std::endl;
1260  std::cout << " ### MVA " << mva << std::endl;
1261  }
1262 
1263  return mva;
1264 }
double pt() const final
transverse momentum
float full5x5_e1x5() const
Definition: GsfElectron.h:473
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
float full5x5_sigmaIphiIphi() const
Definition: GsfElectron.h:472
std::vector< TMVA::Reader * > fTMVAReader
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float full5x5_e5x5() const
Definition: GsfElectron.h:475
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
double edB(IPTYPE type) const
Uncertainty on the corresponding impact parameter.
double p() const final
magnitude of momentum vector
bool isAvailable() const
Definition: Ref.h:541
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
double dB(IPTYPE type) const
Impact parameter wrt primary vertex or beamspot.
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float ecalEnergy() const
Definition: GsfElectron.h:896
UInt_t GetMVABin(double eta, double pt) const
float fbrem() const
Definition: GsfElectron.h:809
float r9() const
Definition: GsfElectron.h:424
float sigmaIphiIphi() const
Definition: GsfElectron.h:420
float full5x5_r9() const
Definition: GsfElectron.h:476
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
float full5x5_sigmaIetaIeta() const
Definition: GsfElectron.h:471
std::vector< TMVA::MethodBase * > fTMVAMethod
float hadronicOverEm() const
Definition: GsfElectron.h:500

◆ mvaValue() [5/7]

Double_t EGammaMvaEleEstimator::mvaValue ( Double_t  fbrem,
Double_t  kfchi2,
Int_t  kfhits,
Double_t  gsfchi2,
Double_t  deta,
Double_t  dphi,
Double_t  detacalo,
Double_t  see,
Double_t  spp,
Double_t  etawidth,
Double_t  phiwidth,
Double_t  e1x5e5x5,
Double_t  R9,
Double_t  HoE,
Double_t  EoP,
Double_t  IoEmIoP,
Double_t  eleEoPout,
Double_t  PreShowerOverRaw,
Double_t  d0,
Double_t  ip3d,
Double_t  eta,
Double_t  pt,
Bool_t  printDebug = kFALSE 
)

Definition at line 453 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), gather_cfg::cout, d0, PVValHelper::eta, fisInitialized, dqmMemoryStats::float, fMethodname, fMVAType, fMVAVar_d0, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_ip3d, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), electrons_cff::ip3d, kTrig, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, and DiDispStaMuonMonitor_cfi::pt.

478  {
479  if (!fisInitialized) {
480  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
481  return -9999;
482  }
483 
485  std::cout << "Error: This method should be called for kTrig MVA only" << std::endl;
486  return -9999;
487  }
488 
489  fMVAVar_fbrem = fbrem;
490  fMVAVar_kfchi2 = kfchi2;
491  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
492  fMVAVar_gsfchi2 = gsfchi2;
493 
494  fMVAVar_deta = deta;
495  fMVAVar_dphi = dphi;
496  fMVAVar_detacalo = detacalo;
497 
498  fMVAVar_see = see;
499  fMVAVar_spp = spp;
500  fMVAVar_etawidth = etawidth;
501  fMVAVar_phiwidth = phiwidth;
502  fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
503  fMVAVar_R9 = R9;
504 
505  fMVAVar_HoE = HoE;
506  fMVAVar_EoP = EoP;
507  fMVAVar_IoEmIoP = IoEmIoP;
508  fMVAVar_eleEoPout = eleEoPout;
509  fMVAVar_PreShowerOverRaw = PreShowerOverRaw;
510 
511  fMVAVar_d0 = d0;
512  fMVAVar_ip3d = ip3d;
513  fMVAVar_eta = eta;
514  fMVAVar_pt = pt;
515 
516  bindVariables();
517  Double_t mva = -9999;
518  if (fUseBinnedVersion) {
520  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
521  } else {
522  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
523  }
524 
525  if (printDebug) {
526  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
527  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
528  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
529  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
530  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " OneMinusE1x5E5x5 "
531  << fMVAVar_OneMinusE1x5E5x5 << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP
532  << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " PreShowerOverRaw "
533  << fMVAVar_PreShowerOverRaw << " d0 " << fMVAVar_d0 << " ip3d " << fMVAVar_ip3d << " eta " << fMVAVar_eta
534  << " pt " << fMVAVar_pt << std::endl;
535  std::cout << " ### MVA " << mva << std::endl;
536  }
537 
538  return mva;
539 }
std::vector< TMVA::Reader * > fTMVAReader
static constexpr float d0
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::MethodBase * > fTMVAMethod

◆ mvaValue() [6/7]

Double_t EGammaMvaEleEstimator::mvaValue ( Double_t  fbrem,
Double_t  kfchi2,
Int_t  kfhits,
Double_t  gsfchi2,
Double_t  deta,
Double_t  dphi,
Double_t  detacalo,
Double_t  see,
Double_t  spp,
Double_t  etawidth,
Double_t  phiwidth,
Double_t  e1x5e5x5,
Double_t  R9,
Double_t  HoE,
Double_t  EoP,
Double_t  IoEmIoP,
Double_t  eleEoPout,
Double_t  rho,
Double_t  PreShowerOverRaw,
Double_t  eta,
Double_t  pt,
Bool_t  printDebug = kFALSE 
)

Definition at line 543 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), gather_cfg::cout, PVValHelper::eta, fisInitialized, dqmMemoryStats::float, fMethodname, fMVAType, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_rho, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), kTrigNoIP, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, DiDispStaMuonMonitor_cfi::pt, and rho.

564  {
565  if (!fisInitialized) {
566  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
567  return -9999;
568  }
569 
571  std::cout << "Error: This method should be called for kTrigNoIP MVA only" << std::endl;
572  return -9999;
573  }
574 
575  fMVAVar_fbrem = fbrem;
576  fMVAVar_kfchi2 = kfchi2;
577  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
578  fMVAVar_gsfchi2 = gsfchi2;
579 
580  fMVAVar_deta = deta;
581  fMVAVar_dphi = dphi;
582  fMVAVar_detacalo = detacalo;
583 
584  fMVAVar_see = see;
585  fMVAVar_spp = spp;
586  fMVAVar_etawidth = etawidth;
587  fMVAVar_phiwidth = phiwidth;
588  fMVAVar_OneMinusE1x5E5x5 = e1x5e5x5;
589  fMVAVar_R9 = R9;
590 
591  fMVAVar_HoE = HoE;
592  fMVAVar_EoP = EoP;
593  fMVAVar_IoEmIoP = IoEmIoP;
594  fMVAVar_eleEoPout = eleEoPout;
595  fMVAVar_rho = rho;
596  fMVAVar_PreShowerOverRaw = PreShowerOverRaw;
597 
598  fMVAVar_eta = eta;
599  fMVAVar_pt = pt;
600 
601  bindVariables();
602  Double_t mva = -9999;
603  if (fUseBinnedVersion) {
605  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
606  } else {
607  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
608  }
609 
610  if (printDebug) {
611  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
612  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
613  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
614  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
615  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
616  << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP << " IoEmIoP "
617  << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " rho " << fMVAVar_rho << " PreShowerOverRaw "
618  << fMVAVar_PreShowerOverRaw << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
619  std::cout << " ### MVA " << mva << std::endl;
620  }
621 
622  return mva;
623 }
std::vector< TMVA::Reader * > fTMVAReader
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::MethodBase * > fTMVAMethod

◆ mvaValue() [7/7]

Double_t EGammaMvaEleEstimator::mvaValue ( Double_t  fbrem,
Double_t  kfchi2,
Int_t  kfhits,
Double_t  gsfchi2,
Double_t  deta,
Double_t  dphi,
Double_t  detacalo,
Double_t  see,
Double_t  spp,
Double_t  etawidth,
Double_t  phiwidth,
Double_t  e1x5e5x5,
Double_t  R9,
Double_t  HoE,
Double_t  EoP,
Double_t  IoEmIoP,
Double_t  eleEoPout,
Double_t  PreShowerOverRaw,
Double_t  eta,
Double_t  pt,
Bool_t  printDebug = kFALSE 
)

Definition at line 627 of file EGammaMvaEleEstimator.cc.

References newFWLiteAna::bin, bindVariables(), gather_cfg::cout, PVValHelper::eta, fisInitialized, dqmMemoryStats::float, fMethodname, fMVAType, fMVAVar_deta, fMVAVar_detacalo, fMVAVar_dphi, fMVAVar_eleEoPout, fMVAVar_EoP, fMVAVar_eta, fMVAVar_etawidth, fMVAVar_fbrem, fMVAVar_gsfchi2, fMVAVar_HoE, fMVAVar_IoEmIoP, fMVAVar_kfchi2, fMVAVar_kfhits, fMVAVar_OneMinusE1x5E5x5, fMVAVar_phiwidth, fMVAVar_PreShowerOverRaw, fMVAVar_pt, fMVAVar_R9, fMVAVar_see, fMVAVar_spp, fTMVAMethod, fTMVAReader, fUseBinnedVersion, GetMVABin(), kNonTrig, beam_dqm_sourceclient-live_cfg::mva, HLT_2023v12_cff::printDebug, and DiDispStaMuonMonitor_cfi::pt.

650  {
651  if (!fisInitialized) {
652  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
653  return -9999;
654  }
655 
657  std::cout << "Error: This method should be called for kNonTrig MVA only" << std::endl;
658  return -9999;
659  }
660 
661  fMVAVar_fbrem = fbrem;
662  fMVAVar_kfchi2 = kfchi2;
663  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
664  fMVAVar_gsfchi2 = gsfchi2;
665 
666  fMVAVar_deta = deta;
667  fMVAVar_dphi = dphi;
668  fMVAVar_detacalo = detacalo;
669 
670  fMVAVar_see = see;
671  fMVAVar_spp = spp;
672  fMVAVar_etawidth = etawidth;
673  fMVAVar_phiwidth = phiwidth;
674  fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
675  fMVAVar_R9 = R9;
676 
677  fMVAVar_HoE = HoE;
678  fMVAVar_EoP = EoP;
679  fMVAVar_IoEmIoP = IoEmIoP;
680  fMVAVar_eleEoPout = eleEoPout;
681  fMVAVar_PreShowerOverRaw = PreShowerOverRaw;
682 
683  fMVAVar_eta = eta;
684  fMVAVar_pt = pt;
685 
686  bindVariables();
687  Double_t mva = -9999;
688  if (fUseBinnedVersion) {
690  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
691  } else {
692  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
693  }
694 
695  if (printDebug) {
696  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
697  std::cout << " fbrem " << fMVAVar_fbrem << " kfchi2 " << fMVAVar_kfchi2 << " mykfhits " << fMVAVar_kfhits
698  << " gsfchi2 " << fMVAVar_gsfchi2 << " deta " << fMVAVar_deta << " dphi " << fMVAVar_dphi << " detacalo "
699  << fMVAVar_detacalo << " see " << fMVAVar_see << " spp " << fMVAVar_spp << " etawidth "
700  << fMVAVar_etawidth << " phiwidth " << fMVAVar_phiwidth << " OneMinusE1x5E5x5 "
701  << fMVAVar_OneMinusE1x5E5x5 << " R9 " << fMVAVar_R9 << " HoE " << fMVAVar_HoE << " EoP " << fMVAVar_EoP
702  << " IoEmIoP " << fMVAVar_IoEmIoP << " eleEoPout " << fMVAVar_eleEoPout << " PreShowerOverRaw "
703  << fMVAVar_PreShowerOverRaw << " eta " << fMVAVar_eta << " pt " << fMVAVar_pt << std::endl;
704  std::cout << " ### MVA " << mva << std::endl;
705  }
706 
707  return mva;
708 }
std::vector< TMVA::Reader * > fTMVAReader
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::MethodBase * > fTMVAMethod

Member Data Documentation

◆ fisInitialized

Bool_t EGammaMvaEleEstimator::fisInitialized
private

◆ fMethodname

std::string EGammaMvaEleEstimator::fMethodname
private

Definition at line 243 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), isoMvaValue(), and mvaValue().

◆ fMVAType

MVAType EGammaMvaEleEstimator::fMVAType
private

◆ fMVAVar_ChargedIso_DR0p0To0p1

Float_t EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p0To0p1
private

Definition at line 281 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_ChargedIso_DR0p1To0p2

Float_t EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p1To0p2
private

Definition at line 282 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_ChargedIso_DR0p2To0p3

Float_t EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p2To0p3
private

Definition at line 283 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_ChargedIso_DR0p3To0p4

Float_t EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p3To0p4
private

Definition at line 284 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_ChargedIso_DR0p4To0p5

Float_t EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p4To0p5
private

Definition at line 285 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_d0

Float_t EGammaMvaEleEstimator::fMVAVar_d0
private

Definition at line 273 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_deta

Float_t EGammaMvaEleEstimator::fMVAVar_deta
private

◆ fMVAVar_detacalo

Float_t EGammaMvaEleEstimator::fMVAVar_detacalo
private

◆ fMVAVar_dphi

Float_t EGammaMvaEleEstimator::fMVAVar_dphi
private

◆ fMVAVar_eleEoPout

Float_t EGammaMvaEleEstimator::fMVAVar_eleEoPout
private

◆ fMVAVar_EoP

Float_t EGammaMvaEleEstimator::fMVAVar_EoP
private

◆ fMVAVar_EoPout

Float_t EGammaMvaEleEstimator::fMVAVar_EoPout
private

Definition at line 270 of file EGammaMvaEleEstimator.h.

◆ fMVAVar_eta

Float_t EGammaMvaEleEstimator::fMVAVar_eta
private

Definition at line 277 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), isoMvaValue(), and mvaValue().

◆ fMVAVar_etawidth

Float_t EGammaMvaEleEstimator::fMVAVar_etawidth
private

Definition at line 261 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_fbrem

Float_t EGammaMvaEleEstimator::fMVAVar_fbrem
private

◆ fMVAVar_GammaIso_DR0p0To0p1

Float_t EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p0To0p1
private

Definition at line 286 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_GammaIso_DR0p1To0p2

Float_t EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p1To0p2
private

Definition at line 287 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_GammaIso_DR0p2To0p3

Float_t EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p2To0p3
private

Definition at line 288 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_GammaIso_DR0p3To0p4

Float_t EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p3To0p4
private

Definition at line 289 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_GammaIso_DR0p4To0p5

Float_t EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p4To0p5
private

Definition at line 290 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_gsfchi2

Float_t EGammaMvaEleEstimator::fMVAVar_gsfchi2
private

◆ fMVAVar_HoE

Float_t EGammaMvaEleEstimator::fMVAVar_HoE
private

Definition at line 266 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_IoEmIoP

Float_t EGammaMvaEleEstimator::fMVAVar_IoEmIoP
private

Definition at line 268 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_ip3d

Float_t EGammaMvaEleEstimator::fMVAVar_ip3d
private

Definition at line 274 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_ip3dSig

Float_t EGammaMvaEleEstimator::fMVAVar_ip3dSig
private

Definition at line 275 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), and mvaValue().

◆ fMVAVar_kfchi2

Float_t EGammaMvaEleEstimator::fMVAVar_kfchi2
private

◆ fMVAVar_kfhits

Float_t EGammaMvaEleEstimator::fMVAVar_kfhits
private

Definition at line 251 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_kfhitsall

Float_t EGammaMvaEleEstimator::fMVAVar_kfhitsall
private

Definition at line 252 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), and mvaValue().

◆ fMVAVar_NeutralHadronIso_DR0p0To0p1

Float_t EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p0To0p1
private

Definition at line 291 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_NeutralHadronIso_DR0p1To0p2

Float_t EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p1To0p2
private

Definition at line 292 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_NeutralHadronIso_DR0p2To0p3

Float_t EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p2To0p3
private

Definition at line 293 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_NeutralHadronIso_DR0p3To0p4

Float_t EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p3To0p4
private

Definition at line 294 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_NeutralHadronIso_DR0p4To0p5

Float_t EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p4To0p5
private

Definition at line 295 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and isoMvaValue().

◆ fMVAVar_OneMinusE1x5E5x5

Float_t EGammaMvaEleEstimator::fMVAVar_OneMinusE1x5E5x5
private

◆ fMVAVar_phiwidth

Float_t EGammaMvaEleEstimator::fMVAVar_phiwidth
private

Definition at line 262 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_PreShowerOverRaw

Float_t EGammaMvaEleEstimator::fMVAVar_PreShowerOverRaw
private

Definition at line 271 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_pt

Float_t EGammaMvaEleEstimator::fMVAVar_pt
private

Definition at line 278 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), isoMvaValue(), and mvaValue().

◆ fMVAVar_R9

Float_t EGammaMvaEleEstimator::fMVAVar_R9
private

◆ fMVAVar_rho

Float_t EGammaMvaEleEstimator::fMVAVar_rho
private

Definition at line 279 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_see

Float_t EGammaMvaEleEstimator::fMVAVar_see
private

Definition at line 259 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), and mvaValue().

◆ fMVAVar_spp

Float_t EGammaMvaEleEstimator::fMVAVar_spp
private

◆ fNMVABins

UInt_t EGammaMvaEleEstimator::fNMVABins
private

Definition at line 247 of file EGammaMvaEleEstimator.h.

Referenced by initialize().

◆ fTMVAMethod

std::vector<TMVA::MethodBase*> EGammaMvaEleEstimator::fTMVAMethod
private

Definition at line 242 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), isoMvaValue(), and mvaValue().

◆ fTMVAReader

std::vector<TMVA::Reader*> EGammaMvaEleEstimator::fTMVAReader
private

◆ fUseBinnedVersion

Bool_t EGammaMvaEleEstimator::fUseBinnedVersion
private

Definition at line 246 of file EGammaMvaEleEstimator.h.

Referenced by IDIsoCombinedMvaValue(), initialize(), isoMvaValue(), and mvaValue().