CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
const double Pi
float TauLeadPFChargedHadrEoP_barrel_max_
float TauLeadPFChargedHadrEoP_endcap_max1_
double Discriminator(float TauPt, float TauEta, float TauLeadChargedPFCandPt, float TauLeadChargedPFCandEtaAtEcalEntrance, float TauLeadPFChargedHadrEoP, float TauHcal3x3OverPLead, float TauGammaEtaMom, float TauGammaPhiMom, float TauGammaEnFrac)
float TauLeadPFChargedHadrEoP_endcap_min2_
U second(std::pair< T, U > const &p)
void SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min, float TauLeadPFChargedHadrEoP_max, float TauHcal3x3OverPLead_max, float TauGammaEtaMom_max, float TauGammaPhiMom_max, float TauGammaEnFrac_max)
T Abs(T a)
Definition: MathUtil.h:49
std::vector< pdouble > ecalCracks_
bool isInEcalCrack(double eta) const
float TauLeadPFChargedHadrEoP_endcap_max2_
float TauLeadPFChargedHadrEoP_barrel_min_
float TauLeadPFChargedHadrEoP_endcap_min1_
tuple cout
Definition: gather_cfg.py:144
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)
void ApplyCuts(bool applyCut_hcal3x3OverPLead, bool applyCut_leadPFChargedHadrEoP, bool applyCut_GammaEtaMom, bool applyCut_GammaPhiMom, bool applyCut_GammaEnFrac, bool applyCut_HLTSpecific)