CMS 3D CMS Logo

AntiElectronIDCut2.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------------------------------
2 // AntiElectronIDCut2
3 //
4 // Helper Class for applying simple cut based anti-electron discrimination
5 //
6 // Authors: A Nayak
7 //--------------------------------------------------------------------------------------------------
8 
9 #ifndef RECOTAUTAG_RECOTAU_AntiElectronIDCut2_H
10 #define RECOTAUTAG_RECOTAU_AntiElectronIDCut2_H
11 
17 
18 #include <vector>
19 
20 typedef std::pair<double, double> pdouble;
21 
23 public:
26 
27  double Discriminator(float TauPt,
28  float TauEta,
29  float TauLeadChargedPFCandPt,
30  float TauLeadChargedPFCandEtaAtEcalEntrance,
31  float TauLeadPFChargedHadrEoP,
32  float TauHcal3x3OverPLead,
33  float TauGammaEtaMom,
34  float TauGammaPhiMom,
35  float TauGammaEnFrac);
36 
37  double Discriminator(float TauPt,
38  float TauEta,
39  float TauLeadChargedPFCandPt,
40  float TauLeadChargedPFCandEtaAtEcalEntrance,
41  float TauLeadPFChargedHadrEoP,
42  float TauHcal3x3OverPLead,
43  const std::vector<float>& GammasdEta,
44  const std::vector<float>& GammasdPhi,
45  const std::vector<float>& GammasPt);
46 
47  template <typename T>
48  double Discriminator(const T& thePFTau) {
49  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
50  float TauLeadChargedPFCandPt = -99.;
51  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
52  for (std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
53  pfCandidate != signalPFCands.end();
54  ++pfCandidate) {
55  const reco::Track* track = nullptr;
56  if ((*pfCandidate)->trackRef().isNonnull())
57  track = (*pfCandidate)->trackRef().get();
58  else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull())
59  track = (*pfCandidate)->muonRef()->innerTrack().get();
60  else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull())
61  track = (*pfCandidate)->muonRef()->globalTrack().get();
62  else if ((*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull())
63  track = (*pfCandidate)->muonRef()->outerTrack().get();
64  else if ((*pfCandidate)->gsfTrackRef().isNonnull())
65  track = (*pfCandidate)->gsfTrackRef().get();
66  if (track) {
67  if (track->pt() > TauLeadChargedPFCandPt) {
68  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
69  TauLeadChargedPFCandPt = track->pt();
70  }
71  }
72  }
73 
74  float TauPt = thePFTau.pt();
75  float TauEta = thePFTau.eta();
76  //float TauLeadPFChargedHadrHoP = 0.;
77  float TauLeadPFChargedHadrEoP = 0.;
78  if (thePFTau.leadPFChargedHadrCand()->p() > 0.) {
79  //TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
80  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
81  }
82 
83  std::vector<float> GammasdEta;
84  std::vector<float> GammasdPhi;
85  std::vector<float> GammasPt;
86  for (unsigned i = 0; i < thePFTau.signalGammaCands().size(); ++i) {
87  reco::CandidatePtr gamma = thePFTau.signalGammaCands().at(i);
88  if (thePFTau.leadChargedHadrCand().isNonnull()) {
89  GammasdEta.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
90  GammasdPhi.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
91  } else {
92  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
93  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
94  }
95  GammasPt.push_back(gamma->pt());
96  }
97 
98  float TauHcal3x3OverPLead = thePFTau.hcal3x3OverPLead();
99 
100  return Discriminator(TauPt,
101  TauEta,
102  TauLeadChargedPFCandPt,
103  TauLeadChargedPFCandEtaAtEcalEntrance,
104  TauLeadPFChargedHadrEoP,
105  TauHcal3x3OverPLead,
106  GammasdEta,
107  GammasdPhi,
108  GammasPt);
109  };
110 
111  void SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min,
112  float TauLeadPFChargedHadrEoP_max,
113  float TauHcal3x3OverPLead_max,
114  float TauGammaEtaMom_max,
115  float TauGammaPhiMom_max,
116  float TauGammaEnFrac_max);
117 
118  void SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1,
119  float TauLeadPFChargedHadrEoP_max_1,
120  float TauLeadPFChargedHadrEoP_min_2,
121  float TauLeadPFChargedHadrEoP_max_2,
122  float TauHcal3x3OverPLead_max,
123  float TauGammaEtaMom_max,
124  float TauGammaPhiMom_max,
125  float TauGammaEnFrac_max);
126  void ApplyCut_EcalCrack(bool keepAll_, bool rejectAll_) {
127  keepAllInEcalCrack_ = keepAll_;
128  rejectAllInEcalCrack_ = rejectAll_;
129  };
130 
136  bool applyCut_HLTSpecific);
137 
138  void SetEcalCracks(const std::vector<pdouble>& etaCracks) {
139  ecalCracks_.clear();
140  for (size_t i = 0; i < etaCracks.size(); i++)
141  ecalCracks_.push_back(etaCracks[i]);
142  }
143 
144 private:
145  bool isInEcalCrack(double eta) const;
146 
161 
164 
171 
172  std::vector<pdouble> ecalCracks_;
173 
175 };
176 
177 #endif
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_hcal3x3OverPLead
applyCut_hcal3x3OverPLead
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:19
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_HLTSpecific
applyCut_HLTSpecific
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:24
mps_fire.i
i
Definition: mps_fire.py:355
AntiElectronIDCut2::SetBarrelCutValues
void SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min, float TauLeadPFChargedHadrEoP_max, float TauHcal3x3OverPLead_max, float TauGammaEtaMom_max, float TauGammaPhiMom_max, float TauGammaEnFrac_max)
Definition: AntiElectronIDCut2.cc:157
AntiElectronIDCut2::~AntiElectronIDCut2
~AntiElectronIDCut2()
Definition: AntiElectronIDCut2.cc:27
AntiElectronIDCut2::Tau_applyCut_leadPFChargedHadrEoP_
bool Tau_applyCut_leadPFChargedHadrEoP_
Definition: AntiElectronIDCut2.h:166
AntiElectronIDCut2::Tau_applyCut_hcal3x3OverPLead_
bool Tau_applyCut_hcal3x3OverPLead_
Definition: AntiElectronIDCut2.h:165
AntiElectronIDCut2::isInEcalCrack
bool isInEcalCrack(double eta) const
Definition: AntiElectronIDCut2.cc:203
AntiElectronIDCut2::TauGammaPhiMom_barrel_max_
float TauGammaPhiMom_barrel_max_
Definition: AntiElectronIDCut2.h:151
AntiElectronIDCut2::keepAllInEcalCrack_
bool keepAllInEcalCrack_
Definition: AntiElectronIDCut2.h:162
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
AntiElectronIDCut2::Tau_applyCut_HLTSpecific_
bool Tau_applyCut_HLTSpecific_
Definition: AntiElectronIDCut2.h:170
AntiElectronIDCut2::Discriminator
double Discriminator(float TauPt, float TauEta, float TauLeadChargedPFCandPt, float TauLeadChargedPFCandEtaAtEcalEntrance, float TauLeadPFChargedHadrEoP, float TauHcal3x3OverPLead, float TauGammaEtaMom, float TauGammaPhiMom, float TauGammaEnFrac)
Definition: AntiElectronIDCut2.cc:29
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_barrel_min_
float TauLeadPFChargedHadrEoP_barrel_min_
Definition: AntiElectronIDCut2.h:147
deltaR.h
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_leadPFChargedHadrEoP
applyCut_leadPFChargedHadrEoP
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:20
AntiElectronIDCut2::TauGammaEnFrac_barrel_max_
float TauGammaEnFrac_barrel_max_
Definition: AntiElectronIDCut2.h:152
PFRecoTauDiscriminationAgainstElectron2_cfi.etaCracks
etaCracks
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:17
AntiElectronIDCut2::rejectAllInEcalCrack_
bool rejectAllInEcalCrack_
Definition: AntiElectronIDCut2.h:163
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_endcap_min1_
float TauLeadPFChargedHadrEoP_endcap_min1_
Definition: AntiElectronIDCut2.h:153
AntiElectronIDCut2::TauGammaEnFrac_endcap_max_
float TauGammaEnFrac_endcap_max_
Definition: AntiElectronIDCut2.h:160
Track.h
TrackFwd.h
AntiElectronIDCut2::TauHcal3x3OverPLead_barrel_max_
float TauHcal3x3OverPLead_barrel_max_
Definition: AntiElectronIDCut2.h:149
AntiElectronIDCut2::TauGammaEtaMom_endcap_max_
float TauGammaEtaMom_endcap_max_
Definition: AntiElectronIDCut2.h:158
AntiElectronIDCut2::TauGammaEtaMom_barrel_max_
float TauGammaEtaMom_barrel_max_
Definition: AntiElectronIDCut2.h:150
PVValHelper::eta
Definition: PVValidationHelpers.h:69
AntiElectronIDCut2::AntiElectronIDCut2
AntiElectronIDCut2()
Definition: AntiElectronIDCut2.cc:11
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_barrel_max_
float TauLeadPFChargedHadrEoP_barrel_max_
Definition: AntiElectronIDCut2.h:148
reco::Track
Definition: Track.h:27
AntiElectronIDCut2::ecalCracks_
std::vector< pdouble > ecalCracks_
Definition: AntiElectronIDCut2.h:172
AntiElectronIDCut2::Tau_applyCut_GammaEnFrac_
bool Tau_applyCut_GammaEnFrac_
Definition: AntiElectronIDCut2.h:169
AntiElectronIDCut2::Tau_applyCut_GammaPhiMom_
bool Tau_applyCut_GammaPhiMom_
Definition: AntiElectronIDCut2.h:168
AntiElectronIDCut2::SetEcalCracks
void SetEcalCracks(const std::vector< pdouble > &etaCracks)
Definition: AntiElectronIDCut2.h:138
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_GammaPhiMom
applyCut_GammaPhiMom
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:22
AntiElectronIDCut2::ApplyCuts
void ApplyCuts(bool applyCut_hcal3x3OverPLead, bool applyCut_leadPFChargedHadrEoP, bool applyCut_GammaEtaMom, bool applyCut_GammaPhiMom, bool applyCut_GammaEnFrac, bool applyCut_HLTSpecific)
Definition: AntiElectronIDCut2.cc:189
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_GammaEnFrac
applyCut_GammaEnFrac
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:23
GsfTrack.h
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_endcap_max1_
float TauLeadPFChargedHadrEoP_endcap_max1_
Definition: AntiElectronIDCut2.h:154
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_GammaEtaMom
applyCut_GammaEtaMom
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:21
edm::Ptr< Candidate >
AntiElectronIDCut2::Tau_applyCut_GammaEtaMom_
bool Tau_applyCut_GammaEtaMom_
Definition: AntiElectronIDCut2.h:167
AntiElectronIDCut2
Definition: AntiElectronIDCut2.h:22
AntiElectronIDCut2::TauGammaPhiMom_endcap_max_
float TauGammaPhiMom_endcap_max_
Definition: AntiElectronIDCut2.h:159
T
long double T
Definition: Basic3DVectorLD.h:48
AntiElectronIDCut2::verbosity_
int verbosity_
Definition: AntiElectronIDCut2.h:174
PFTau.h
AntiElectronIDCut2::ApplyCut_EcalCrack
void ApplyCut_EcalCrack(bool keepAll_, bool rejectAll_)
Definition: AntiElectronIDCut2.h:126
AntiElectronIDCut2::TauHcal3x3OverPLead_endcap_max_
float TauHcal3x3OverPLead_endcap_max_
Definition: AntiElectronIDCut2.h:157
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
AntiElectronIDCut2::Discriminator
double Discriminator(const T &thePFTau)
Definition: AntiElectronIDCut2.h:48
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_endcap_min2_
float TauLeadPFChargedHadrEoP_endcap_min2_
Definition: AntiElectronIDCut2.h:155
pdouble
std::pair< double, double > pdouble
Definition: AntiElectronIDCut2.h:20
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_endcap_max2_
float TauLeadPFChargedHadrEoP_endcap_max2_
Definition: AntiElectronIDCut2.h:156
AntiElectronIDCut2::SetEndcapCutValues
void SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1, float TauLeadPFChargedHadrEoP_max_1, float TauLeadPFChargedHadrEoP_min_2, float TauLeadPFChargedHadrEoP_max_2, float TauHcal3x3OverPLead_max, float TauGammaEtaMom_max, float TauGammaPhiMom_max, float TauGammaEnFrac_max)
Definition: AntiElectronIDCut2.cc:171