CMS 3D CMS Logo

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