CMS 3D CMS Logo

AntiElectronIDCut2.cc
Go to the documentation of this file.
2 
4 
9 #include <TMath.h>
10 
12  //default, keep all taus in cracks for HLT
13  keepAllInEcalCrack_ = true;
14  rejectAllInEcalCrack_ = false;
15 
16  //Default Cuts to be applied
23 
24  verbosity_ = 0;
25 }
26 
28 
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  if (verbosity_) {
39  std::cout << "Tau GammaEnFrac " << TauGammaEnFrac << std::endl;
40  std::cout << "Tau GammaEtaMom " << TauGammaEtaMom << std::endl;
41  std::cout << "Tau GammaPhiMom " << TauGammaPhiMom << std::endl;
42  std::cout << "Tau Hcal3x3OverPLead " << TauHcal3x3OverPLead << std::endl;
43  std::cout << "Tau LeadPFChargedHadrEoP " << TauLeadPFChargedHadrEoP << std::endl;
44  std::cout << "Tau LeadChargedPFCandEtaAtEcalEntrance " << TauLeadChargedPFCandEtaAtEcalEntrance << std::endl;
45  std::cout << "Tau LeadChargedPFCandPt " << TauLeadChargedPFCandPt << std::endl;
46  std::cout << "Tau Eta " << TauEta << std::endl;
47  std::cout << "Tau Pt " << TauPt << std::endl;
48  }
49 
50  // ensure tau has at least one charged object
51  if (TauLeadChargedPFCandPt <= 0) {
52  return 0.;
53  } else {
54  // Check if track goes to Ecal Crack
55  if (isInEcalCrack(TauLeadChargedPFCandEtaAtEcalEntrance)) {
57  return 1.0;
58  else if (rejectAllInEcalCrack_)
59  return 0.;
60  }
61  }
62 
63  bool decision = false;
64  //Apply separate cuts for barrel and endcap
65  if (TMath::Abs(TauEta) < 1.479) {
66  //Apply cut for barrel
68  decision = true;
69 
71  decision = true;
72 
74  decision = true;
75 
77  decision = true;
78 
80  TauLeadPFChargedHadrEoP > TauLeadPFChargedHadrEoP_barrel_max_))
81  decision = true;
82  } else {
83  //Apply cut for endcap
85  decision = true;
86 
88  decision = true;
89 
91  decision = true;
92 
93  //This cut is for both offline and HLT. For offline, use cut 0.99-1.01,
94  //For HLT use cut 0.7-1.3
96  TauLeadPFChargedHadrEoP > TauLeadPFChargedHadrEoP_endcap_max1_))
97  decision = true;
98 
99  //This cut is only for HLT. For HLT, use cut like 0.99-1.01 & H3x3/P>0.1
100  //For offline, keep the values same as above : 0.99-1.01 & H3x3/P>0, otherwise it may select events in a wrong way.
102  (TauLeadPFChargedHadrEoP < TauLeadPFChargedHadrEoP_endcap_min2_ ||
103  TauLeadPFChargedHadrEoP > TauLeadPFChargedHadrEoP_endcap_max2_) &&
104  TauHcal3x3OverPLead > TauHcal3x3OverPLead_endcap_max_)
105  decision = true;
106  }
107 
108  return (decision ? 1. : 0.);
109 }
110 
112  float TauEta,
113  float TauLeadChargedPFCandPt,
114  float TauLeadChargedPFCandEtaAtEcalEntrance,
115  float TauLeadPFChargedHadrEoP,
116  float TauHcal3x3OverPLead,
117  const std::vector<float>& GammasdEta,
118  const std::vector<float>& GammasdPhi,
119  const std::vector<float>& GammasPt) {
120  double sumPt = 0.;
121  double dEta2 = 0.;
122  double dPhi2 = 0.;
123  for (unsigned int i = 0; i < GammasPt.size(); ++i) {
124  double pt_i = GammasPt[i];
125  double phi_i = GammasdPhi[i];
126  if (GammasdPhi[i] > TMath::Pi())
127  phi_i = GammasdPhi[i] - 2 * TMath::Pi();
128  else if (GammasdPhi[i] < -TMath::Pi())
129  phi_i = GammasdPhi[i] + 2 * TMath::Pi();
130  double eta_i = GammasdEta[i];
131  sumPt += pt_i;
132  dEta2 += (pt_i * eta_i * eta_i);
133  dPhi2 += (pt_i * phi_i * phi_i);
134  }
135 
136  float TauGammaEnFrac = sumPt / TauPt;
137 
138  if (sumPt > 0.) {
139  dEta2 /= sumPt;
140  dPhi2 /= sumPt;
141  }
142 
143  float TauGammaEtaMom = TMath::Sqrt(dEta2) * TMath::Sqrt(TauGammaEnFrac) * TauPt;
144  float TauGammaPhiMom = TMath::Sqrt(dPhi2) * TMath::Sqrt(TauGammaEnFrac) * TauPt;
145 
146  return Discriminator(TauPt,
147  TauEta,
148  TauLeadChargedPFCandPt,
149  TauLeadChargedPFCandEtaAtEcalEntrance,
150  TauLeadPFChargedHadrEoP,
151  TauHcal3x3OverPLead,
152  TauGammaEtaMom,
153  TauGammaPhiMom,
154  TauGammaEnFrac);
155 }
156 
157 void AntiElectronIDCut2::SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min,
158  float TauLeadPFChargedHadrEoP_max,
159  float TauHcal3x3OverPLead_max,
160  float TauGammaEtaMom_max,
161  float TauGammaPhiMom_max,
162  float TauGammaEnFrac_max) {
163  TauLeadPFChargedHadrEoP_barrel_min_ = TauLeadPFChargedHadrEoP_min;
164  TauLeadPFChargedHadrEoP_barrel_max_ = TauLeadPFChargedHadrEoP_max;
165  TauHcal3x3OverPLead_barrel_max_ = TauHcal3x3OverPLead_max;
166  TauGammaEtaMom_barrel_max_ = TauGammaEtaMom_max;
167  TauGammaPhiMom_barrel_max_ = TauGammaPhiMom_max;
168  TauGammaEnFrac_barrel_max_ = TauGammaEnFrac_max;
169 }
170 
171 void AntiElectronIDCut2::SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1,
172  float TauLeadPFChargedHadrEoP_max_1,
173  float TauLeadPFChargedHadrEoP_min_2,
174  float TauLeadPFChargedHadrEoP_max_2,
175  float TauHcal3x3OverPLead_max,
176  float TauGammaEtaMom_max,
177  float TauGammaPhiMom_max,
178  float TauGammaEnFrac_max) {
179  TauLeadPFChargedHadrEoP_endcap_min1_ = TauLeadPFChargedHadrEoP_min_1;
180  TauLeadPFChargedHadrEoP_endcap_max1_ = TauLeadPFChargedHadrEoP_max_1;
181  TauLeadPFChargedHadrEoP_endcap_min2_ = TauLeadPFChargedHadrEoP_min_2;
182  TauLeadPFChargedHadrEoP_endcap_max2_ = TauLeadPFChargedHadrEoP_max_2;
183  TauHcal3x3OverPLead_endcap_max_ = TauHcal3x3OverPLead_max;
184  TauGammaEtaMom_endcap_max_ = TauGammaEtaMom_max;
185  TauGammaPhiMom_endcap_max_ = TauGammaPhiMom_max;
186  TauGammaEnFrac_endcap_max_ = TauGammaEnFrac_max;
187 }
188 
194  bool applyCut_HLTSpecific) {
201 }
202 
204  bool in_ecal_crack = false;
205 
206  eta = fabs(eta);
207  for (std::vector<pdouble>::const_iterator etaCrack = ecalCracks_.begin(); etaCrack != ecalCracks_.end(); ++etaCrack)
208  if (eta >= etaCrack->first && eta < etaCrack->second)
209  in_ecal_crack = true;
210 
211  return in_ecal_crack;
212 }
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
PFCandidate.h
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
gather_cfg.cout
cout
Definition: gather_cfg.py:144
AntiElectronIDCut2::keepAllInEcalCrack_
bool keepAllInEcalCrack_
Definition: AntiElectronIDCut2.h:162
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
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
TtFullHadEvtBuilder_cfi.sumPt
sumPt
Definition: TtFullHadEvtBuilder_cfi.py:38
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_leadPFChargedHadrEoP
applyCut_leadPFChargedHadrEoP
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:20
AntiElectronIDCut2::TauGammaEnFrac_barrel_max_
float TauGammaEnFrac_barrel_max_
Definition: AntiElectronIDCut2.h:152
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
Abs
T Abs(T a)
Definition: MathUtil.h:49
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
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
PFRecoTauDiscriminationAgainstElectron2_cfi.applyCut_GammaPhiMom
applyCut_GammaPhiMom
Definition: PFRecoTauDiscriminationAgainstElectron2_cfi.py:22
AntiElectronIDCut2.h
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
AntiElectronIDCut2::Tau_applyCut_GammaEtaMom_
bool Tau_applyCut_GammaEtaMom_
Definition: AntiElectronIDCut2.h:167
AntiElectronIDCut2::TauGammaPhiMom_endcap_max_
float TauGammaPhiMom_endcap_max_
Definition: AntiElectronIDCut2.h:159
AntiElectronIDCut2::verbosity_
int verbosity_
Definition: AntiElectronIDCut2.h:174
Exception.h
AntiElectronIDCut2::TauHcal3x3OverPLead_endcap_max_
float TauHcal3x3OverPLead_endcap_max_
Definition: AntiElectronIDCut2.h:157
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
AntiElectronIDCut2::TauLeadPFChargedHadrEoP_endcap_min2_
float TauLeadPFChargedHadrEoP_endcap_min2_
Definition: AntiElectronIDCut2.h:155
PFCandidateFwd.h
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