CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
24  public:
25 
28 
29  double Discriminator(float TauPt,
30  float TauEta,
31  float TauLeadChargedPFCandPt,
32  float TauLeadChargedPFCandEtaAtEcalEntrance,
33  float TauLeadPFChargedHadrEoP,
34  float TauHcal3x3OverPLead,
35  float TauGammaEtaMom,
36  float TauGammaPhiMom,
37  float TauGammaEnFrac
38  );
39 
40  double Discriminator(float TauPt,
41  float TauEta,
42  float TauLeadChargedPFCandPt,
43  float TauLeadChargedPFCandEtaAtEcalEntrance,
44  float TauLeadPFChargedHadrEoP,
45  float TauHcal3x3OverPLead,
46  const std::vector<float>& GammasdEta,
47  const std::vector<float>& GammasdPhi,
48  const std::vector<float>& GammasPt
49  );
50 
51  template<typename T>
52  double Discriminator(const T& thePFTau)
53  {
54  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
55  float TauLeadChargedPFCandPt = -99.;
56  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
57  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
58  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
59  const reco::Track* track = 0;
60  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
61  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
62  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
63  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
64  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
65  if ( track ) {
66  if ( track->pt() > TauLeadChargedPFCandPt ) {
67  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
68  TauLeadChargedPFCandPt = track->pt();
69  }
70  }
71  }
72 
73  float TauPt = thePFTau.pt();
74  float TauEta = thePFTau.eta();
75  //float TauLeadPFChargedHadrHoP = 0.;
76  float TauLeadPFChargedHadrEoP = 0.;
77  if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) {
78  //TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
79  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
80  }
81 
82  std::vector<float> GammasdEta;
83  std::vector<float> GammasdPhi;
84  std::vector<float> GammasPt;
85  for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) {
86  reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i);
87  if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) {
88  GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta());
89  GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi());
90  } else {
91  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
92  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
93  }
94  GammasPt.push_back(gamma->pt());
95  }
96 
97  float TauHcal3x3OverPLead = thePFTau.hcal3x3OverPLead();
98 
99  return Discriminator(TauPt,
100  TauEta,
101  TauLeadChargedPFCandPt,
102  TauLeadChargedPFCandEtaAtEcalEntrance,
103  TauLeadPFChargedHadrEoP,
104  TauHcal3x3OverPLead,
105  GammasdEta,
106  GammasdPhi,
107  GammasPt
108  );
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 
119  void SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1,
120  float TauLeadPFChargedHadrEoP_max_1,
121  float TauLeadPFChargedHadrEoP_min_2,
122  float TauLeadPFChargedHadrEoP_max_2,
123  float TauHcal3x3OverPLead_max,
124  float TauGammaEtaMom_max,
125  float TauGammaPhiMom_max,
126  float TauGammaEnFrac_max
127  );
128  void ApplyCut_EcalCrack(bool keepAll_, bool rejectAll_){
129  keepAllInEcalCrack_ = keepAll_;
130  rejectAllInEcalCrack_ = rejectAll_;
131  };
132 
135  bool applyCut_GammaEtaMom,
136  bool applyCut_GammaPhiMom,
137  bool applyCut_GammaEnFrac,
139  );
140 
141  void SetEcalCracks(const std::vector<pdouble>& etaCracks)
142  {
143  ecalCracks_.clear();
144  for(size_t i = 0; i < etaCracks.size(); i++)
145  ecalCracks_.push_back(etaCracks[i]);
146  }
147 
148  private:
149 
150  bool isInEcalCrack(double eta) const;
151 
166 
169 
176 
177  std::vector<pdouble> ecalCracks_;
178 
180 };
181 
182 #endif
int i
Definition: DBlmapReader.cc:9
float TauLeadPFChargedHadrEoP_barrel_max_
std::pair< double, double > pdouble
void ApplyCut_EcalCrack(bool keepAll_, bool rejectAll_)
float TauLeadPFChargedHadrEoP_endcap_max1_
T eta() const
double Discriminator(float TauPt, float TauEta, float TauLeadChargedPFCandPt, float TauLeadChargedPFCandEtaAtEcalEntrance, float TauLeadPFChargedHadrEoP, float TauHcal3x3OverPLead, float TauGammaEtaMom, float TauGammaPhiMom, float TauGammaEnFrac)
float TauLeadPFChargedHadrEoP_endcap_min2_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
void SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min, float TauLeadPFChargedHadrEoP_max, float TauHcal3x3OverPLead_max, float TauGammaEtaMom_max, float TauGammaPhiMom_max, float TauGammaEnFrac_max)
double pt() const
track transverse momentum
Definition: TrackBase.h:129
std::vector< pdouble > ecalCracks_
bool isInEcalCrack(double eta) const
float TauLeadPFChargedHadrEoP_endcap_max2_
float TauLeadPFChargedHadrEoP_barrel_min_
float TauLeadPFChargedHadrEoP_endcap_min1_
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)
long double T
void SetEcalCracks(const std::vector< pdouble > &etaCracks)
void ApplyCuts(bool applyCut_hcal3x3OverPLead, bool applyCut_leadPFChargedHadrEoP, bool applyCut_GammaEtaMom, bool applyCut_GammaPhiMom, bool applyCut_GammaEnFrac, bool applyCut_HLTSpecific)
double Discriminator(const T &thePFTau)