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 dEta = 0.;
141  double dEta2 = 0.;
142  double dPhi = 0.;
143  double dPhi2 = 0.;
144  double sumPt2 = 0.;
145  for ( unsigned int i = 0 ; i < GammasPt.size() ; ++i ) {
146  double pt_i = GammasPt[i];
147  double phi_i = GammasdPhi[i];
148  if ( GammasdPhi[i] > TMath::Pi() ) phi_i = GammasdPhi[i] - 2*TMath::Pi();
149  else if ( GammasdPhi[i] < -TMath::Pi() ) phi_i = GammasdPhi[i] + 2*TMath::Pi();
150  double eta_i = GammasdEta[i];
151  sumPt += pt_i;
152  sumPt2 += (pt_i*pt_i);
153  dEta += (pt_i*eta_i);
154  dEta2 += (pt_i*eta_i*eta_i);
155  dPhi += (pt_i*phi_i);
156  dPhi2 += (pt_i*phi_i*phi_i);
157  }
158 
159  float TauGammaEnFrac = sumPt/TauPt;
160 
161  if ( sumPt > 0. ) {
162  dEta /= sumPt;
163  dPhi /= sumPt;
164  dEta2 /= sumPt;
165  dPhi2 /= sumPt;
166  }
167 
168  float TauGammaEtaMom = TMath::Sqrt(dEta2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
169  float TauGammaPhiMom = TMath::Sqrt(dPhi2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
170 
171  return Discriminator(TauPt,
172  TauEta,
173  TauLeadChargedPFCandPt,
174  TauLeadChargedPFCandEtaAtEcalEntrance,
175  TauLeadPFChargedHadrEoP,
176  TauHcal3x3OverPLead,
177  TauGammaEtaMom,
178  TauGammaPhiMom,
179  TauGammaEnFrac
180  );
181 }
182 
183 void
184 AntiElectronIDCut2::SetBarrelCutValues(float TauLeadPFChargedHadrEoP_min,
185  float TauLeadPFChargedHadrEoP_max,
186  float TauHcal3x3OverPLead_max,
187  float TauGammaEtaMom_max,
188  float TauGammaPhiMom_max,
189  float TauGammaEnFrac_max
190  )
191 {
192  TauLeadPFChargedHadrEoP_barrel_min_ = TauLeadPFChargedHadrEoP_min;
193  TauLeadPFChargedHadrEoP_barrel_max_ = TauLeadPFChargedHadrEoP_max;
194  TauHcal3x3OverPLead_barrel_max_ = TauHcal3x3OverPLead_max;
195  TauGammaEtaMom_barrel_max_ = TauGammaEtaMom_max;
196  TauGammaPhiMom_barrel_max_ = TauGammaPhiMom_max;
197  TauGammaEnFrac_barrel_max_ = TauGammaEnFrac_max;
198 }
199 
200 void
201 AntiElectronIDCut2::SetEndcapCutValues(float TauLeadPFChargedHadrEoP_min_1,
202  float TauLeadPFChargedHadrEoP_max_1,
203  float TauLeadPFChargedHadrEoP_min_2,
204  float TauLeadPFChargedHadrEoP_max_2,
205  float TauHcal3x3OverPLead_max,
206  float TauGammaEtaMom_max,
207  float TauGammaPhiMom_max,
208  float TauGammaEnFrac_max
209  )
210 {
211  TauLeadPFChargedHadrEoP_endcap_min1_ = TauLeadPFChargedHadrEoP_min_1;
212  TauLeadPFChargedHadrEoP_endcap_max1_ = TauLeadPFChargedHadrEoP_max_1;
213  TauLeadPFChargedHadrEoP_endcap_min2_ = TauLeadPFChargedHadrEoP_min_2;
214  TauLeadPFChargedHadrEoP_endcap_max2_ = TauLeadPFChargedHadrEoP_max_2;
215  TauHcal3x3OverPLead_endcap_max_ = TauHcal3x3OverPLead_max;
216  TauGammaEtaMom_endcap_max_ = TauGammaEtaMom_max;
217  TauGammaPhiMom_endcap_max_ = TauGammaPhiMom_max;
218  TauGammaEnFrac_endcap_max_ = TauGammaEnFrac_max;
219 }
220 
221 void
224  bool applyCut_GammaEtaMom,
225  bool applyCut_GammaPhiMom,
226  bool applyCut_GammaEnFrac,
228  )
229 {
236 }
237 
238 bool
240 {
241  bool in_ecal_crack = false;
242 
243  eta = fabs(eta);
244  for(std::vector<pdouble>::const_iterator etaCrack = ecalCracks_.begin();
245  etaCrack != ecalCracks_.end(); ++etaCrack)
246  if(eta >= etaCrack->first && eta < etaCrack->second)
247  in_ecal_crack = true;
248 
249  return in_ecal_crack;
250 }
251 
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)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
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)