CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AntiElectronIDMVA5GBR.cc
Go to the documentation of this file.
2 
4 
10 
11 #include <TFile.h>
12 #include <TMath.h>
13 
15  : isInitialized_(kFALSE),
16  methodName_("BDTG")
17 {
18  Var_NoEleMatch_woGwoGSF_Barrel_ = new Float_t[10];
19  Var_NoEleMatch_woGwGSF_Barrel_ = new Float_t[16];
20  Var_NoEleMatch_wGwoGSF_Barrel_ = new Float_t[14];
21  Var_NoEleMatch_wGwGSF_Barrel_ = new Float_t[20];
22  Var_woGwoGSF_Barrel_ = new Float_t[18];
23  Var_woGwGSF_Barrel_ = new Float_t[24];
24  Var_wGwoGSF_Barrel_ = new Float_t[22];
25  Var_wGwGSF_Barrel_ = new Float_t[28];
26  Var_NoEleMatch_woGwoGSF_Endcap_ = new Float_t[9];
27  Var_NoEleMatch_woGwGSF_Endcap_ = new Float_t[15];
28  Var_NoEleMatch_wGwoGSF_Endcap_ = new Float_t[13];
29  Var_NoEleMatch_wGwGSF_Endcap_ = new Float_t[19];
30  Var_woGwoGSF_Endcap_ = new Float_t[17];
31  Var_woGwGSF_Endcap_ = new Float_t[23];
32  Var_wGwoGSF_Endcap_ = new Float_t[21];
33  Var_wGwGSF_Endcap_ = new Float_t[27];
34 
40  gbr_woGwGSF_BL_ = 0;
41  gbr_wGwoGSF_BL_ = 0;
42  gbr_wGwGSF_BL_ = 0;
47  gbr_woGwoGSF_EC_ = 0;
48  gbr_woGwGSF_EC_ = 0;
49  gbr_wGwoGSF_EC_ = 0;
50  gbr_wGwGSF_EC_ = 0;
51 
52  verbosity_ = 0;
53 }
54 
56 {
61  delete [] Var_woGwoGSF_Barrel_;
62  delete [] Var_woGwGSF_Barrel_;
63  delete [] Var_wGwoGSF_Barrel_;
64  delete [] Var_wGwGSF_Barrel_;
69  delete [] Var_woGwoGSF_Endcap_;
70  delete [] Var_woGwGSF_Endcap_;
71  delete [] Var_wGwoGSF_Endcap_;
72  delete [] Var_wGwGSF_Endcap_;
73  delete fin_;
74 }
75 
77 {
78  isInitialized_ = kTRUE;
79  methodName_ = methodName;
80 
81  //open input root file
82  fin_ = new TFile(gbrFile.data(), "READ");
83  if ( fin_->IsZombie() )
84  throw cms::Exception("AntiElectronIDMVA5GBR")
85  << " Failed to open File = " << gbrFile << " !!\n";
86 
87  //read GBRForest from file
88  gbr_NoEleMatch_woGwoGSF_BL_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_woGwoGSF_BL"));
89  gbr_NoEleMatch_woGwGSF_BL_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_woGwGSF_BL"));
90  gbr_NoEleMatch_wGwoGSF_BL_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_wGwoGSF_BL"));
91  gbr_NoEleMatch_wGwGSF_BL_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_wGwGSF_BL"));
92  gbr_woGwoGSF_BL_ = (GBRForest *)(fin_->Get("gbr_woGwoGSF_BL"));
93  gbr_woGwGSF_BL_ = (GBRForest *)(fin_->Get("gbr_woGwGSF_BL"));
94  gbr_wGwoGSF_BL_ = (GBRForest *)(fin_->Get("gbr_wGwoGSF_BL"));
95  gbr_wGwGSF_BL_ = (GBRForest *)(fin_->Get("gbr_wGwGSF_BL"));
96  gbr_NoEleMatch_woGwoGSF_EC_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_woGwoGSF_EC"));
97  gbr_NoEleMatch_woGwGSF_EC_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_woGwGSF_EC"));
98  gbr_NoEleMatch_wGwoGSF_EC_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_wGwoGSF_EC"));
99  gbr_NoEleMatch_wGwGSF_EC_ = (GBRForest *)(fin_->Get("gbr_NoEleMatch_wGwGSF_EC"));
100  gbr_woGwoGSF_EC_ = (GBRForest *)(fin_->Get("gbr_woGwoGSF_EC"));
101  gbr_woGwGSF_EC_ = (GBRForest *)(fin_->Get("gbr_woGwGSF_EC"));
102  gbr_wGwoGSF_EC_ = (GBRForest *)(fin_->Get("gbr_wGwoGSF_EC"));
103  gbr_wGwGSF_EC_ = (GBRForest *)(fin_->Get("gbr_wGwGSF_EC"));
104 }
105 
106 double AntiElectronIDMVA5GBR::MVAValue(Float_t TauEtaAtEcalEntrance,
107  Float_t TauPt,
108  Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
109  Float_t TauLeadChargedPFCandPt,
110  Float_t TaudCrackEta,
111  Float_t TaudCrackPhi,
112  Float_t TauEmFraction,
113  Float_t TauSignalPFGammaCands,
114  Float_t TauLeadPFChargedHadrHoP,
115  Float_t TauLeadPFChargedHadrEoP,
116  Float_t TauVisMass,
117  Float_t TauHadrMva,
118  const std::vector<Float_t>& GammasdEta,
119  const std::vector<Float_t>& GammasdPhi,
120  const std::vector<Float_t>& GammasPt,
121  Float_t TauKFNumHits,
122  Float_t TauGSFNumHits,
123  Float_t TauGSFChi2,
124  Float_t TauGSFTrackResol,
125  Float_t TauGSFTracklnPt,
126  Float_t TauGSFTrackEta,
127  Float_t TauPhi,
128  Float_t TauSignalPFChargedCands,
129  Float_t TauHasGsf,
130  Float_t ElecEta,
131  Float_t ElecPhi,
132  Float_t ElecPt,
133  Float_t ElecEe,
134  Float_t ElecEgamma,
135  Float_t ElecPin,
136  Float_t ElecPout,
137  Float_t ElecFbrem,
138  Float_t ElecChi2GSF,
139  Float_t ElecGSFNumHits,
140  Float_t ElecGSFTrackResol,
141  Float_t ElecGSFTracklnPt,
142  Float_t ElecGSFTrackEta)
143 {
144  double sumPt = 0.;
145  double dEta = 0.;
146  double dEta2 = 0.;
147  double dPhi = 0.;
148  double dPhi2 = 0.;
149  double sumPt2 = 0.;
150  for ( unsigned int i = 0 ; i < GammasPt.size() ; ++i ) {
151  double pt_i = GammasPt[i];
152  double phi_i = GammasdPhi[i];
153  if ( GammasdPhi[i] > TMath::Pi() ) phi_i = GammasdPhi[i] - 2*TMath::Pi();
154  else if ( GammasdPhi[i] < -TMath::Pi() ) phi_i = GammasdPhi[i] + 2*TMath::Pi();
155  double eta_i = GammasdEta[i];
156  sumPt += pt_i;
157  sumPt2 += (pt_i*pt_i);
158  dEta += (pt_i*eta_i);
159  dEta2 += (pt_i*eta_i*eta_i);
160  dPhi += (pt_i*phi_i);
161  dPhi2 += (pt_i*phi_i*phi_i);
162  }
163 
164  Float_t TauGammaEnFrac = sumPt/TauPt;
165 
166  if ( sumPt > 0. ) {
167  dEta /= sumPt;
168  dPhi /= sumPt;
169  dEta2 /= sumPt;
170  dPhi2 /= sumPt;
171  }
172 
173  Float_t TauGammaEtaMom = TMath::Sqrt(dEta2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
174  Float_t TauGammaPhiMom = TMath::Sqrt(dPhi2)*TMath::Sqrt(TauGammaEnFrac)*TauPt;
175 
176  return MVAValue(TauEtaAtEcalEntrance,
177  TauPt,
178  TauLeadChargedPFCandEtaAtEcalEntrance,
179  TauLeadChargedPFCandPt,
180  TaudCrackEta,
181  TaudCrackPhi,
182  TauEmFraction,
183  TauSignalPFGammaCands,
184  TauLeadPFChargedHadrHoP,
185  TauLeadPFChargedHadrEoP,
186  TauVisMass,
187  TauHadrMva,
188  TauGammaEtaMom,
189  TauGammaPhiMom,
190  TauGammaEnFrac,
191  TauKFNumHits,
192  TauGSFNumHits,
193  TauGSFChi2,
194  TauGSFTrackResol,
195  TauGSFTracklnPt,
196  TauGSFTrackEta,
197  TauPhi,
198  TauSignalPFChargedCands,
199  TauHasGsf,
200  ElecEta,
201  ElecPhi,
202  ElecPt,
203  ElecEe,
204  ElecEgamma,
205  ElecPin,
206  ElecPout,
207  ElecFbrem,
208  ElecChi2GSF,
209  ElecGSFNumHits,
210  ElecGSFTrackResol,
211  ElecGSFTracklnPt,
212  ElecGSFTrackEta);
213 }
214 
215 double AntiElectronIDMVA5GBR::MVAValue(Float_t TauEtaAtEcalEntrance,
216  Float_t TauPt,
217  Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
218  Float_t TauLeadChargedPFCandPt,
219  Float_t TaudCrackEta,
220  Float_t TaudCrackPhi,
221  Float_t TauEmFract,
222  Float_t TauSignalPFGammaCands,
223  Float_t TauLeadPFChargedHadrHoP,
224  Float_t TauLeadPFChargedHadrEoP,
225  Float_t TauVisMass,
226  Float_t TauHadrMva,
227  Float_t TauGammaEtaMom,
228  Float_t TauGammaPhiMom,
229  Float_t TauGammaEnFrac,
230  Float_t TauKFNumHits,
231  Float_t TauGSFNumHits,
232  Float_t TauGSFChi2,
233  Float_t TauGSFTrackResol,
234  Float_t TauGSFTracklnPt,
235  Float_t TauGSFTrackEta,
236  Float_t TauPhi,
237  Float_t TauSignalPFChargedCands,
238  Float_t TauHasGsf,
239  Float_t ElecEta,
240  Float_t ElecPhi,
241  Float_t ElecPt,
242  Float_t ElecEe,
243  Float_t ElecEgamma,
244  Float_t ElecPin,
245  Float_t ElecPout,
246  Float_t ElecFbrem,
247  Float_t ElecChi2GSF,
248  Float_t ElecGSFNumHits,
249  Float_t ElecGSFTrackResol,
250  Float_t ElecGSFTracklnPt,
251  Float_t ElecGSFTrackEta)
252 {
253 
254  if ( !isInitialized_ ) {
255  throw cms::Exception("ClassNotInitialized") << "Error: AntiElectronMVA not properly initialized.\n";
256  }
257 
258  Float_t TauEmFraction = TMath::Max(TauEmFract, float(0.));
259  Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
260  Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
261  Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
262 
263  double mva = -99.;
264  if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
265  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
266  Var_NoEleMatch_woGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
267  Var_NoEleMatch_woGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
268  Var_NoEleMatch_woGwoGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
269  Var_NoEleMatch_woGwoGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
270  Var_NoEleMatch_woGwoGSF_Barrel_[4] = TauEmFraction;
271  Var_NoEleMatch_woGwoGSF_Barrel_[5] = TauLeadPFChargedHadrHoP;
272  Var_NoEleMatch_woGwoGSF_Barrel_[6] = TauLeadPFChargedHadrEoP;
273  Var_NoEleMatch_woGwoGSF_Barrel_[7] = TauVisMass;
274  Var_NoEleMatch_woGwoGSF_Barrel_[8] = TaudCrackEta;
275  Var_NoEleMatch_woGwoGSF_Barrel_[9] = TaudCrackPhi;
277  } else {
278  Var_NoEleMatch_woGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
279  Var_NoEleMatch_woGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
280  Var_NoEleMatch_woGwoGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
281  Var_NoEleMatch_woGwoGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
282  Var_NoEleMatch_woGwoGSF_Endcap_[4] = TauEmFraction;
283  Var_NoEleMatch_woGwoGSF_Endcap_[5] = TauLeadPFChargedHadrHoP;
284  Var_NoEleMatch_woGwoGSF_Endcap_[6] = TauLeadPFChargedHadrEoP;
285  Var_NoEleMatch_woGwoGSF_Endcap_[7] = TauVisMass;
286  Var_NoEleMatch_woGwoGSF_Endcap_[8] = TaudCrackEta;
288  }
289  } else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
290  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
291  Var_NoEleMatch_woGwGSF_Barrel_[0] = TauEtaAtEcalEntrance;
292  Var_NoEleMatch_woGwGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
293  Var_NoEleMatch_woGwGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
294  Var_NoEleMatch_woGwGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
295  Var_NoEleMatch_woGwGSF_Barrel_[4] = TauEmFraction;
296  Var_NoEleMatch_woGwGSF_Barrel_[5] = TauLeadPFChargedHadrHoP;
297  Var_NoEleMatch_woGwGSF_Barrel_[6] = TauLeadPFChargedHadrEoP;
298  Var_NoEleMatch_woGwGSF_Barrel_[7] = TauVisMass;
299  Var_NoEleMatch_woGwGSF_Barrel_[8] = TauHadrMva;
300  Var_NoEleMatch_woGwGSF_Barrel_[9] = TauGSFChi2;
301  Var_NoEleMatch_woGwGSF_Barrel_[10] = TauNumHitsVariable;
302  Var_NoEleMatch_woGwGSF_Barrel_[11] = TauGSFTrackResol;
303  Var_NoEleMatch_woGwGSF_Barrel_[12] = TauGSFTracklnPt;
304  Var_NoEleMatch_woGwGSF_Barrel_[13] = TauGSFTrackEta;
305  Var_NoEleMatch_woGwGSF_Barrel_[14] = TaudCrackEta;
306  Var_NoEleMatch_woGwGSF_Barrel_[15] = TaudCrackPhi;
308  } else {
309  Var_NoEleMatch_woGwGSF_Endcap_[0] = TauEtaAtEcalEntrance;
310  Var_NoEleMatch_woGwGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
311  Var_NoEleMatch_woGwGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
312  Var_NoEleMatch_woGwGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
313  Var_NoEleMatch_woGwGSF_Endcap_[4] = TauEmFraction;
314  Var_NoEleMatch_woGwGSF_Endcap_[5] = TauLeadPFChargedHadrHoP;
315  Var_NoEleMatch_woGwGSF_Endcap_[6] = TauLeadPFChargedHadrEoP;
316  Var_NoEleMatch_woGwGSF_Endcap_[7] = TauVisMass;
317  Var_NoEleMatch_woGwGSF_Endcap_[8] = TauHadrMva;
318  Var_NoEleMatch_woGwGSF_Endcap_[9] = TauGSFChi2;
319  Var_NoEleMatch_woGwGSF_Endcap_[10] = TauNumHitsVariable;
320  Var_NoEleMatch_woGwGSF_Endcap_[11] = TauGSFTrackResol;
321  Var_NoEleMatch_woGwGSF_Endcap_[12] = TauGSFTracklnPt;
322  Var_NoEleMatch_woGwGSF_Endcap_[13] = TauGSFTrackEta;
323  Var_NoEleMatch_woGwGSF_Endcap_[14] = TaudCrackEta;
325  }
326  } else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
327  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
328  Var_NoEleMatch_wGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
329  Var_NoEleMatch_wGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
330  Var_NoEleMatch_wGwoGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
331  Var_NoEleMatch_wGwoGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
332  Var_NoEleMatch_wGwoGSF_Barrel_[4] = TauEmFraction;
333  Var_NoEleMatch_wGwoGSF_Barrel_[5] = TauSignalPFGammaCands;
334  Var_NoEleMatch_wGwoGSF_Barrel_[6] = TauLeadPFChargedHadrHoP;
335  Var_NoEleMatch_wGwoGSF_Barrel_[7] = TauLeadPFChargedHadrEoP;
336  Var_NoEleMatch_wGwoGSF_Barrel_[8] = TauVisMass;
337  Var_NoEleMatch_wGwoGSF_Barrel_[9] = TauGammaEtaMom;
338  Var_NoEleMatch_wGwoGSF_Barrel_[10] = TauGammaPhiMom;
339  Var_NoEleMatch_wGwoGSF_Barrel_[11] = TauGammaEnFrac;
340  Var_NoEleMatch_wGwoGSF_Barrel_[12] = TaudCrackEta;
341  Var_NoEleMatch_wGwoGSF_Barrel_[13] = TaudCrackPhi;
343  } else {
344  Var_NoEleMatch_wGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
345  Var_NoEleMatch_wGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
346  Var_NoEleMatch_wGwoGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
347  Var_NoEleMatch_wGwoGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
348  Var_NoEleMatch_wGwoGSF_Endcap_[4] = TauEmFraction;
349  Var_NoEleMatch_wGwoGSF_Endcap_[5] = TauSignalPFGammaCands;
350  Var_NoEleMatch_wGwoGSF_Endcap_[6] = TauLeadPFChargedHadrHoP;
351  Var_NoEleMatch_wGwoGSF_Endcap_[7] = TauLeadPFChargedHadrEoP;
352  Var_NoEleMatch_wGwoGSF_Endcap_[8] = TauVisMass;
353  Var_NoEleMatch_wGwoGSF_Endcap_[9] = TauGammaEtaMom;
354  Var_NoEleMatch_wGwoGSF_Endcap_[10] = TauGammaPhiMom;
355  Var_NoEleMatch_wGwoGSF_Endcap_[11] = TauGammaEnFrac;
356  Var_NoEleMatch_wGwoGSF_Endcap_[12] = TaudCrackEta;
358  }
359  }
360  else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
361  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
362  Var_NoEleMatch_wGwGSF_Barrel_[0] = TauEtaAtEcalEntrance;
363  Var_NoEleMatch_wGwGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
364  Var_NoEleMatch_wGwGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
365  Var_NoEleMatch_wGwGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
366  Var_NoEleMatch_wGwGSF_Barrel_[4] = TauEmFraction;
367  Var_NoEleMatch_wGwGSF_Barrel_[5] = TauSignalPFGammaCands;
368  Var_NoEleMatch_wGwGSF_Barrel_[6] = TauLeadPFChargedHadrHoP;
369  Var_NoEleMatch_wGwGSF_Barrel_[7] = TauLeadPFChargedHadrEoP;
370  Var_NoEleMatch_wGwGSF_Barrel_[8] = TauVisMass;
371  Var_NoEleMatch_wGwGSF_Barrel_[9] = TauHadrMva;
372  Var_NoEleMatch_wGwGSF_Barrel_[10] = TauGammaEtaMom;
373  Var_NoEleMatch_wGwGSF_Barrel_[11] = TauGammaPhiMom;
374  Var_NoEleMatch_wGwGSF_Barrel_[12] = TauGammaEnFrac;
375  Var_NoEleMatch_wGwGSF_Barrel_[13] = TauGSFChi2;
376  Var_NoEleMatch_wGwGSF_Barrel_[14] = TauNumHitsVariable;
377  Var_NoEleMatch_wGwGSF_Barrel_[15] = TauGSFTrackResol;
378  Var_NoEleMatch_wGwGSF_Barrel_[16] = TauGSFTracklnPt;
379  Var_NoEleMatch_wGwGSF_Barrel_[17] = TauGSFTrackEta;
380  Var_NoEleMatch_wGwGSF_Barrel_[18] = TaudCrackEta;
381  Var_NoEleMatch_wGwGSF_Barrel_[19] = TaudCrackPhi;
383  } else {
384  Var_NoEleMatch_wGwGSF_Endcap_[0] = TauEtaAtEcalEntrance;
385  Var_NoEleMatch_wGwGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
386  Var_NoEleMatch_wGwGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
387  Var_NoEleMatch_wGwGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
388  Var_NoEleMatch_wGwGSF_Endcap_[4] = TauEmFraction;
389  Var_NoEleMatch_wGwGSF_Endcap_[5] = TauSignalPFGammaCands;
390  Var_NoEleMatch_wGwGSF_Endcap_[6] = TauLeadPFChargedHadrHoP;
391  Var_NoEleMatch_wGwGSF_Endcap_[7] = TauLeadPFChargedHadrEoP;
392  Var_NoEleMatch_wGwGSF_Endcap_[8] = TauVisMass;
393  Var_NoEleMatch_wGwGSF_Endcap_[9] = TauHadrMva;
394  Var_NoEleMatch_wGwGSF_Endcap_[10] = TauGammaEtaMom;
395  Var_NoEleMatch_wGwGSF_Endcap_[11] = TauGammaPhiMom;
396  Var_NoEleMatch_wGwGSF_Endcap_[12] = TauGammaEnFrac;
397  Var_NoEleMatch_wGwGSF_Endcap_[13] = TauGSFChi2;
398  Var_NoEleMatch_wGwGSF_Endcap_[14] = TauNumHitsVariable;
399  Var_NoEleMatch_wGwGSF_Endcap_[15] = TauGSFTrackResol;
400  Var_NoEleMatch_wGwGSF_Endcap_[16] = TauGSFTracklnPt;
401  Var_NoEleMatch_wGwGSF_Endcap_[17] = TauGSFTrackEta;
402  Var_NoEleMatch_wGwGSF_Endcap_[18] = TaudCrackEta;
404  }
405  } else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
406  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
407  Var_woGwoGSF_Barrel_[0] = ElecEtotOverPin;
408  Var_woGwoGSF_Barrel_[1] = ElecEgammaOverPdif;
409  Var_woGwoGSF_Barrel_[2] = ElecFbrem;
410  Var_woGwoGSF_Barrel_[3] = ElecChi2GSF;
411  Var_woGwoGSF_Barrel_[4] = ElecGSFNumHits;
412  Var_woGwoGSF_Barrel_[5] = ElecGSFTrackResol;
413  Var_woGwoGSF_Barrel_[6] = ElecGSFTracklnPt;
414  Var_woGwoGSF_Barrel_[7] = ElecGSFTrackEta;
415  Var_woGwoGSF_Barrel_[8] = TauEtaAtEcalEntrance;
416  Var_woGwoGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
417  Var_woGwoGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
418  Var_woGwoGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
419  Var_woGwoGSF_Barrel_[12] = TauEmFraction;
420  Var_woGwoGSF_Barrel_[13] = TauLeadPFChargedHadrHoP;
421  Var_woGwoGSF_Barrel_[14] = TauLeadPFChargedHadrEoP;
422  Var_woGwoGSF_Barrel_[15] = TauVisMass;
423  Var_woGwoGSF_Barrel_[16] = TaudCrackEta;
424  Var_woGwoGSF_Barrel_[17] = TaudCrackPhi;
426  } else {
427  Var_woGwoGSF_Endcap_[0] = ElecEtotOverPin;
428  Var_woGwoGSF_Endcap_[1] = ElecEgammaOverPdif;
429  Var_woGwoGSF_Endcap_[2] = ElecFbrem;
430  Var_woGwoGSF_Endcap_[3] = ElecChi2GSF;
431  Var_woGwoGSF_Endcap_[4] = ElecGSFNumHits;
432  Var_woGwoGSF_Endcap_[5] = ElecGSFTrackResol;
433  Var_woGwoGSF_Endcap_[6] = ElecGSFTracklnPt;
434  Var_woGwoGSF_Endcap_[7] = ElecGSFTrackEta;
435  Var_woGwoGSF_Endcap_[8] = TauEtaAtEcalEntrance;
436  Var_woGwoGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
437  Var_woGwoGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
438  Var_woGwoGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
439  Var_woGwoGSF_Endcap_[12] = TauEmFraction;
440  Var_woGwoGSF_Endcap_[13] = TauLeadPFChargedHadrHoP;
441  Var_woGwoGSF_Endcap_[14] = TauLeadPFChargedHadrEoP;
442  Var_woGwoGSF_Endcap_[15] = TauVisMass;
443  Var_woGwoGSF_Endcap_[16] = TaudCrackEta;
445  }
446  } else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
447  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
448  Var_woGwGSF_Barrel_[0] = ElecEtotOverPin;
449  Var_woGwGSF_Barrel_[1] = ElecEgammaOverPdif;
450  Var_woGwGSF_Barrel_[2] = ElecFbrem;
451  Var_woGwGSF_Barrel_[3] = ElecChi2GSF;
452  Var_woGwGSF_Barrel_[4] = ElecGSFNumHits;
453  Var_woGwGSF_Barrel_[5] = ElecGSFTrackResol;
454  Var_woGwGSF_Barrel_[6] = ElecGSFTracklnPt;
455  Var_woGwGSF_Barrel_[7] = ElecGSFTrackEta;
456  Var_woGwGSF_Barrel_[8] = TauEtaAtEcalEntrance;
457  Var_woGwGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
458  Var_woGwGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
459  Var_woGwGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
460  Var_woGwGSF_Barrel_[12] = TauEmFraction;
461  Var_woGwGSF_Barrel_[13] = TauLeadPFChargedHadrHoP;
462  Var_woGwGSF_Barrel_[14] = TauLeadPFChargedHadrEoP;
463  Var_woGwGSF_Barrel_[15] = TauVisMass;
464  Var_woGwGSF_Barrel_[16] = TauHadrMva;
465  Var_woGwGSF_Barrel_[17] = TauGSFChi2;
466  Var_woGwGSF_Barrel_[18] = TauNumHitsVariable;
467  Var_woGwGSF_Barrel_[19] = TauGSFTrackResol;
468  Var_woGwGSF_Barrel_[20] = TauGSFTracklnPt;
469  Var_woGwGSF_Barrel_[21] = TauGSFTrackEta;
470  Var_woGwGSF_Barrel_[22] = TaudCrackEta;
471  Var_woGwGSF_Barrel_[23] = TaudCrackPhi;
473  } else {
474  Var_woGwGSF_Endcap_[0] = ElecEtotOverPin;
475  Var_woGwGSF_Endcap_[1] = ElecEgammaOverPdif;
476  Var_woGwGSF_Endcap_[2] = ElecFbrem;
477  Var_woGwGSF_Endcap_[3] = ElecChi2GSF;
478  Var_woGwGSF_Endcap_[4] = ElecGSFNumHits;
479  Var_woGwGSF_Endcap_[5] = ElecGSFTrackResol;
480  Var_woGwGSF_Endcap_[6] = ElecGSFTracklnPt;
481  Var_woGwGSF_Endcap_[7] = ElecGSFTrackEta;
482  Var_woGwGSF_Endcap_[8] = TauEtaAtEcalEntrance;
483  Var_woGwGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
484  Var_woGwGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
485  Var_woGwGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
486  Var_woGwGSF_Endcap_[12] = TauEmFraction;
487  Var_woGwGSF_Endcap_[13] = TauLeadPFChargedHadrHoP;
488  Var_woGwGSF_Endcap_[14] = TauLeadPFChargedHadrEoP;
489  Var_woGwGSF_Endcap_[15] = TauVisMass;
490  Var_woGwGSF_Endcap_[16] = TauHadrMva;
491  Var_woGwGSF_Endcap_[17] = TauGSFChi2;
492  Var_woGwGSF_Endcap_[18] = TauNumHitsVariable;
493  Var_woGwGSF_Endcap_[19] = TauGSFTrackResol;
494  Var_woGwGSF_Endcap_[20] = TauGSFTracklnPt;
495  Var_woGwGSF_Endcap_[21] = TauGSFTrackEta;
496  Var_woGwGSF_Endcap_[22] = TaudCrackEta;
498  }
499  } else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
500  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
501  Var_wGwoGSF_Barrel_[0] = ElecEtotOverPin;
502  Var_wGwoGSF_Barrel_[1] = ElecEgammaOverPdif;
503  Var_wGwoGSF_Barrel_[2] = ElecFbrem;
504  Var_wGwoGSF_Barrel_[3] = ElecChi2GSF;
505  Var_wGwoGSF_Barrel_[4] = ElecGSFNumHits;
506  Var_wGwoGSF_Barrel_[5] = ElecGSFTrackResol;
507  Var_wGwoGSF_Barrel_[6] = ElecGSFTracklnPt;
508  Var_wGwoGSF_Barrel_[7] = ElecGSFTrackEta;
509  Var_wGwoGSF_Barrel_[8] = TauEtaAtEcalEntrance;
510  Var_wGwoGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
511  Var_wGwoGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
512  Var_wGwoGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
513  Var_wGwoGSF_Barrel_[12] = TauEmFraction;
514  Var_wGwoGSF_Barrel_[13] = TauSignalPFGammaCands;
515  Var_wGwoGSF_Barrel_[14] = TauLeadPFChargedHadrHoP;
516  Var_wGwoGSF_Barrel_[15] = TauLeadPFChargedHadrEoP;
517  Var_wGwoGSF_Barrel_[16] = TauVisMass;
518  Var_wGwoGSF_Barrel_[17] = TauGammaEtaMom;
519  Var_wGwoGSF_Barrel_[18] = TauGammaPhiMom;
520  Var_wGwoGSF_Barrel_[19] = TauGammaEnFrac;
521  Var_wGwoGSF_Barrel_[20] = TaudCrackEta;
522  Var_wGwoGSF_Barrel_[21] = TaudCrackPhi;
524  } else {
525  Var_wGwoGSF_Endcap_[0] = ElecEtotOverPin;
526  Var_wGwoGSF_Endcap_[1] = ElecEgammaOverPdif;
527  Var_wGwoGSF_Endcap_[2] = ElecFbrem;
528  Var_wGwoGSF_Endcap_[3] = ElecChi2GSF;
529  Var_wGwoGSF_Endcap_[4] = ElecGSFNumHits;
530  Var_wGwoGSF_Endcap_[5] = ElecGSFTrackResol;
531  Var_wGwoGSF_Endcap_[6] = ElecGSFTracklnPt;
532  Var_wGwoGSF_Endcap_[7] = ElecGSFTrackEta;
533  Var_wGwoGSF_Endcap_[8] = TauEtaAtEcalEntrance;
534  Var_wGwoGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
535  Var_wGwoGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
536  Var_wGwoGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
537  Var_wGwoGSF_Endcap_[12] = TauEmFraction;
538  Var_wGwoGSF_Endcap_[13] = TauSignalPFGammaCands;
539  Var_wGwoGSF_Endcap_[14] = TauLeadPFChargedHadrHoP;
540  Var_wGwoGSF_Endcap_[15] = TauLeadPFChargedHadrEoP;
541  Var_wGwoGSF_Endcap_[16] = TauVisMass;
542  Var_wGwoGSF_Endcap_[17] = TauGammaEtaMom;
543  Var_wGwoGSF_Endcap_[18] = TauGammaPhiMom;
544  Var_wGwoGSF_Endcap_[19] = TauGammaEnFrac;
545  Var_wGwoGSF_Endcap_[20] = TaudCrackEta;
547  }
548  } else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
549  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
550  Var_wGwGSF_Barrel_[0] = ElecEtotOverPin;
551  Var_wGwGSF_Barrel_[1] = ElecEgammaOverPdif;
552  Var_wGwGSF_Barrel_[2] = ElecFbrem;
553  Var_wGwGSF_Barrel_[3] = ElecChi2GSF;
554  Var_wGwGSF_Barrel_[4] = ElecGSFNumHits;
555  Var_wGwGSF_Barrel_[5] = ElecGSFTrackResol;
556  Var_wGwGSF_Barrel_[6] = ElecGSFTracklnPt;
557  Var_wGwGSF_Barrel_[7] = ElecGSFTrackEta;
558  Var_wGwGSF_Barrel_[8] = TauEtaAtEcalEntrance;
559  Var_wGwGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
560  Var_wGwGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
561  Var_wGwGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
562  Var_wGwGSF_Barrel_[12] = TauEmFraction;
563  Var_wGwGSF_Barrel_[13] = TauSignalPFGammaCands;
564  Var_wGwGSF_Barrel_[14] = TauLeadPFChargedHadrHoP;
565  Var_wGwGSF_Barrel_[15] = TauLeadPFChargedHadrEoP;
566  Var_wGwGSF_Barrel_[16] = TauVisMass;
567  Var_wGwGSF_Barrel_[17] = TauHadrMva;
568  Var_wGwGSF_Barrel_[18] = TauGammaEtaMom;
569  Var_wGwGSF_Barrel_[19] = TauGammaPhiMom;
570  Var_wGwGSF_Barrel_[20] = TauGammaEnFrac;
571  Var_wGwGSF_Barrel_[21] = TauGSFChi2;
572  Var_wGwGSF_Barrel_[22] = TauNumHitsVariable;
573  Var_wGwGSF_Barrel_[23] = TauGSFTrackResol;
574  Var_wGwGSF_Barrel_[24] = TauGSFTracklnPt;
575  Var_wGwGSF_Barrel_[25] = TauGSFTrackEta;
576  Var_wGwGSF_Barrel_[26] = TaudCrackEta;
577  Var_wGwGSF_Barrel_[27] = TaudCrackPhi;
579  } else {
580  Var_wGwGSF_Endcap_[0] = ElecEtotOverPin;
581  Var_wGwGSF_Endcap_[1] = ElecEgammaOverPdif;
582  Var_wGwGSF_Endcap_[2] = ElecFbrem;
583  Var_wGwGSF_Endcap_[3] = ElecChi2GSF;
584  Var_wGwGSF_Endcap_[4] = ElecGSFNumHits;
585  Var_wGwGSF_Endcap_[5] = ElecGSFTrackResol;
586  Var_wGwGSF_Endcap_[6] = ElecGSFTracklnPt;
587  Var_wGwGSF_Endcap_[7] = ElecGSFTrackEta;
588  Var_wGwGSF_Endcap_[8] = TauEtaAtEcalEntrance;
589  Var_wGwGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
590  Var_wGwGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
591  Var_wGwGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
592  Var_wGwGSF_Endcap_[12] = TauEmFraction;
593  Var_wGwGSF_Endcap_[13] = TauSignalPFGammaCands;
594  Var_wGwGSF_Endcap_[14] = TauLeadPFChargedHadrHoP;
595  Var_wGwGSF_Endcap_[15] = TauLeadPFChargedHadrEoP;
596  Var_wGwGSF_Endcap_[16] = TauVisMass;
597  Var_wGwGSF_Endcap_[17] = TauHadrMva;
598  Var_wGwGSF_Endcap_[18] = TauGammaEtaMom;
599  Var_wGwGSF_Endcap_[19] = TauGammaPhiMom;
600  Var_wGwGSF_Endcap_[20] = TauGammaEnFrac;
601  Var_wGwGSF_Endcap_[21] = TauGSFChi2;
602  Var_wGwGSF_Endcap_[22] = TauNumHitsVariable;
603  Var_wGwGSF_Endcap_[23] = TauGSFTrackResol;
604  Var_wGwGSF_Endcap_[24] = TauGSFTracklnPt;
605  Var_wGwGSF_Endcap_[25] = TauGSFTrackEta;
606  Var_wGwGSF_Endcap_[26] = TaudCrackEta;
608  }
609  }
610  return mva;
611 }
612 
614  const reco::GsfElectron& theGsfEle)
615 
616 {
617  Float_t TauEtaAtEcalEntrance = -99.;
618  float sumEtaTimesEnergy = 0.;
619  float sumEnergy = 0.;
620  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
621  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
622  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
623  sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
624  sumEnergy += (*pfCandidate)->energy();
625  }
626  if ( sumEnergy > 0. ) {
627  TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
628  }
629 
630  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
631  float TauLeadChargedPFCandPt = -99.;
632  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
633  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
634  const reco::Track* track = 0;
635  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
636  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
637  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
638  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
639  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
640  if ( track ) {
641  if ( track->pt() > TauLeadChargedPFCandPt ) {
642  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
643  TauLeadChargedPFCandPt = track->pt();
644  }
645  }
646  }
647 
648  Float_t TauPt = thePFTau.pt();
649  Float_t TauEmFraction = TMath::Max(thePFTau.emFraction(), (Float_t)0.);
650  Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size();
651  Float_t TauLeadPFChargedHadrHoP = 0.;
652  Float_t TauLeadPFChargedHadrEoP = 0.;
653  if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) {
654  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
655  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
656  }
657  Float_t TauVisMass = thePFTau.mass();
658  Float_t TauHadrMva = TMath::Max(thePFTau.electronPreIDOutput(), float(-1.0));
659  std::vector<Float_t> GammasdEta;
660  std::vector<Float_t> GammasdPhi;
661  std::vector<Float_t> GammasPt;
662  for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) {
663  reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i);
664  if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) {
665  GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta());
666  GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi());
667  } else {
668  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
669  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
670  }
671  GammasPt.push_back(gamma->pt());
672  }
673  Float_t TauKFNumHits = -99.;
674  if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) {
675  TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits();
676  }
677  Float_t TauGSFNumHits = -99.;
678  Float_t TauGSFChi2 = -99.;
679  Float_t TauGSFTrackResol = -99.;
680  Float_t TauGSFTracklnPt = -99.;
681  Float_t TauGSFTrackEta = -99.;
682  if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) {
683  TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2();
684  TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits();
685  if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) {
686  TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt();
687  TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*TMath::Ln10();
688  }
689  TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta();
690  }
691  Float_t TauPhi = thePFTau.phi();
692  float sumPhiTimesEnergy = 0.;
693  float sumEnergyPhi = 0.;
694  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
695  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
696  sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
697  sumEnergyPhi += (*pfCandidate)->energy();
698  }
699  if ( sumEnergyPhi > 0. ) {
700  TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
701  }
702  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
703  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
704  Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size();
705  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
706 
707  Float_t ElecEta = theGsfEle.eta();
708  Float_t ElecPhi = theGsfEle.phi();
709  Float_t ElecPt = theGsfEle.pt();
710  //Variables related to the electron Cluster
711  Float_t ElecEe = 0.;
712  Float_t ElecEgamma = 0.;
713  reco::SuperClusterRef pfSuperCluster = theGsfEle.parentSuperCluster();
714  if ( pfSuperCluster.isNonnull() && pfSuperCluster.isAvailable() ) {
715  for ( reco::CaloCluster_iterator pfCluster = pfSuperCluster->clustersBegin();
716  pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
717  double pfClusterEn = (*pfCluster)->energy();
718  if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
719  else ElecEgamma += pfClusterEn;
720  }
721  }
722  Float_t ElecPin = TMath::Sqrt(theGsfEle.trackMomentumAtVtx().Mag2());
723  Float_t ElecPout = TMath::Sqrt(theGsfEle.trackMomentumOut().Mag2());
724  Float_t ElecFbrem = theGsfEle.fbrem();
725  //Variables related to the GsfTrack
726  Float_t ElecChi2GSF = -99.;
727  Float_t ElecGSFNumHits = -99.;
728  Float_t ElecGSFTrackResol = -99.;
729  Float_t ElecGSFTracklnPt = -99.;
730  Float_t ElecGSFTrackEta = -99.;
731  if ( theGsfEle.gsfTrack().isNonnull() ) {
732  ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
733  ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
734  if ( theGsfEle.gsfTrack()->pt() > 0. ) {
735  ElecGSFTrackResol = theGsfEle.gsfTrack()->ptError()/theGsfEle.gsfTrack()->pt();
736  ElecGSFTracklnPt = log(theGsfEle.gsfTrack()->pt())*TMath::Ln10();
737  }
738  ElecGSFTrackEta = theGsfEle.gsfTrack()->eta();
739  }
740 
741  return MVAValue(TauEtaAtEcalEntrance,
742  TauPt,
743  TauLeadChargedPFCandEtaAtEcalEntrance,
744  TauLeadChargedPFCandPt,
745  TaudCrackEta,
746  TaudCrackPhi,
747  TauEmFraction,
748  TauSignalPFGammaCands,
749  TauLeadPFChargedHadrHoP,
750  TauLeadPFChargedHadrEoP,
751  TauVisMass,
752  TauHadrMva,
753  GammasdEta,
754  GammasdPhi,
755  GammasPt,
756  TauKFNumHits,
757  TauGSFNumHits,
758  TauGSFChi2,
759  TauGSFTrackResol,
760  TauGSFTracklnPt,
761  TauGSFTrackEta,
762  TauPhi,
763  TauSignalPFChargedCands,
764  TauHasGsf,
765  ElecEta,
766  ElecPhi,
767  ElecPt,
768  ElecEe,
769  ElecEgamma,
770  ElecPin,
771  ElecPout,
772  ElecFbrem,
773  ElecChi2GSF,
774  ElecGSFNumHits,
775  ElecGSFTrackResol,
776  ElecGSFTracklnPt,
777  ElecGSFTrackEta);
778 }
779 
781 {
782  Float_t TauEtaAtEcalEntrance = -99.;
783  float sumEtaTimesEnergy = 0.;
784  float sumEnergy = 0.;
785  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
786  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
787  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
788  sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
789  sumEnergy += (*pfCandidate)->energy();
790  }
791  if ( sumEnergy > 0. ) {
792  TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
793  }
794 
795  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
796  float TauLeadChargedPFCandPt = -99.;
797  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
798  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
799  const reco::Track* track = 0;
800  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
801  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
802  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
803  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
804  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
805  if ( track ) {
806  if ( track->pt() > TauLeadChargedPFCandPt ) {
807  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
808  TauLeadChargedPFCandPt = track->pt();
809  }
810  }
811  }
812 
813  Float_t TauPt = thePFTau.pt();
814  Float_t TauEmFraction = TMath::Max(thePFTau.emFraction(), (Float_t)0.);
815  Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size();
816  Float_t TauLeadPFChargedHadrHoP = 0.;
817  Float_t TauLeadPFChargedHadrEoP = 0.;
818  if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) {
819  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
820  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
821  }
822  Float_t TauVisMass = thePFTau.mass();
823  Float_t TauHadrMva = TMath::Max(thePFTau.electronPreIDOutput(),float(-1.0));
824  std::vector<Float_t> GammasdEta;
825  std::vector<Float_t> GammasdPhi;
826  std::vector<Float_t> GammasPt;
827  for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) {
828  reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i);
829  if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) {
830  GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta());
831  GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi());
832  } else {
833  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
834  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
835  }
836  GammasPt.push_back(gamma->pt());
837  }
838  Float_t TauKFNumHits = -99.;
839  if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) {
840  TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits();
841  }
842  Float_t TauGSFNumHits = -99.;
843  Float_t TauGSFChi2 = -99.;
844  Float_t TauGSFTrackResol = -99.;
845  Float_t TauGSFTracklnPt = -99.;
846  Float_t TauGSFTrackEta = -99.;
847  if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) {
848  TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2();
849  TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits();
850  if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) {
851  TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt();
852  TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*TMath::Ln10();
853  }
854  TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta();
855  }
856  Float_t TauPhi = thePFTau.phi();
857  float sumPhiTimesEnergy = 0.;
858  float sumEnergyPhi = 0.;
859  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
860  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
861  sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
862  sumEnergyPhi += (*pfCandidate)->energy();
863  }
864  if ( sumEnergyPhi > 0. ) {
865  TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
866  }
867  Float_t TaudCrackPhi = dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
868  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance) ;
869  Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size();
870  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
871 
872  Float_t dummyElecEta = 9.9;
873 
874  return MVAValue(TauEtaAtEcalEntrance,
875  TauPt,
876  TauLeadChargedPFCandEtaAtEcalEntrance,
877  TauLeadChargedPFCandPt,
878  TaudCrackEta,
879  TaudCrackPhi,
880  TauEmFraction,
881  TauSignalPFGammaCands,
882  TauLeadPFChargedHadrHoP,
883  TauLeadPFChargedHadrEoP,
884  TauVisMass,
885  TauHadrMva,
886  GammasdEta,
887  GammasdPhi,
888  GammasPt,
889  TauKFNumHits,
890  TauGSFNumHits,
891  TauGSFChi2,
892  TauGSFTrackResol,
893  TauGSFTracklnPt,
894  TauGSFTrackEta,
895  TauPhi,
896  TauSignalPFChargedCands,
897  TauHasGsf,
898  dummyElecEta,
899  0.,
900  0.,
901  0.,
902  0.,
903  0.,
904  0.,
905  0.,
906  0.,
907  0.,
908  0.,
909  0.,
910  0.);
911 }
912 
913 double AntiElectronIDMVA5GBR::minimum(double a, double b)
914 {
915  if ( TMath::Abs(b) < TMath::Abs(a) ) return b;
916  else return a;
917 }
918 
920 {
921 //--- compute the (unsigned) distance to the closest phi-crack in the ECAL barrel
922 
923  double pi = TMath::Pi(); // 3.14159265358979323846;
924 
925  // IN: define locations of the 18 phi-cracks
926  static std::vector<double> cPhi;
927  if ( cPhi.size() == 0 ) {
928  cPhi.resize(18, 0);
929  cPhi[0] = 2.97025;
930  for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) {
931  cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
932  }
933  }
934 
935  // IN: shift of this location if eta < 0
936  double delta_cPhi = 0.00638;
937 
938  double retVal = 99.;
939 
940  if ( eta >= -1.47464 && eta <= 1.47464 ) {
941 
942  // the location is shifted
943  if ( eta < 0. ) phi += delta_cPhi;
944 
945  // CV: need to bring-back phi into interval [-pi,+pi]
946  if ( phi > pi ) phi -= 2.*pi;
947  if ( phi < -pi ) phi += 2.*pi;
948 
949  if ( phi >= -pi && phi <= pi ) {
950 
951  // the problem of the extrema:
952  if ( phi < cPhi[17] || phi >= cPhi[0] ) {
953  if ( phi < 0. ) phi += 2.*pi;
954  retVal = minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
955  } else {
956  // between these extrema...
957  bool OK = false;
958  unsigned iCrack = 16;
959  while( !OK ) {
960  if ( phi < cPhi[iCrack] ) {
961  retVal = minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
962  OK = true;
963  } else {
964  iCrack -= 1;
965  }
966  }
967  }
968  } else {
969  retVal = 0.; // IN: if there is a problem, we assume that we are in a crack
970  }
971  } else {
972  return -99.;
973  }
974 
975  return TMath::Abs(retVal);
976 }
977 
979 {
980 //--- compute the (unsigned) distance to the closest eta-crack in the ECAL barrel
981 
982  // IN: define locations of the eta-cracks
983  double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
984 
985  double retVal = 99.;
986 
987  for ( int iCrack = 0; iCrack < 5 ; ++iCrack ) {
988  double d = minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
989  if ( TMath::Abs(d) < TMath::Abs(retVal) ) {
990  retVal = d;
991  }
992  }
993 
994  return TMath::Abs(retVal);
995 }
const double Pi
int i
Definition: DBlmapReader.cc:9
SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:188
const PFCandidatePtr & leadPFChargedHadrCand() const
Definition: PFTau.cc:61
virtual float pt() const
transverse momentum
void Initialize_from_file(const std::string &methodName, const std::string &gbrFile)
pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:72
virtual float phi() const
momentum azimuthal angle
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:286
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
Definition: PFTau.cc:78
float emFraction() const
Definition: PFTau.cc:203
float fbrem() const
Definition: GsfElectron.h:684
bool isAvailable() const
Definition: Ref.h:276
T Min(T a, T b)
Definition: MathUtil.h:39
T eta() const
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:72
double minimum(double a, double b)
const Double_t pi
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
virtual float eta() const
momentum pseudorapidity
math::XYZVectorF trackMomentumOut() const
Definition: GsfElectron.h:288
double pt() const
track transverse momentum
Definition: TrackBase.h:129
T Abs(T a)
Definition: MathUtil.h:49
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
T Max(T a, T b)
Definition: MathUtil.h:44
double b
Definition: hdecay.h:120
double dCrackPhi(double phi, double eta)
double a
Definition: hdecay.h:121
virtual float mass() const
mass
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauLeadChargedPFCandPt, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauEmFraction, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMass, Float_t TauHadrMva, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t TauKFNumHits, Float_t TauGSFNumHits, Float_t TauGSFChi2, Float_t TauGSFTrackResol, Float_t TauGSFTracklnPt, Float_t TauGSFTrackEta, Float_t TauPhi, Float_t TauSignalPFChargedCands, Float_t TauHasGsf, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecFbrem, Float_t ElecChi2GSF, Float_t ElecGSFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)
double GetClassifier(const float *vector) const
Definition: GBRForest.h:64
float electronPreIDOutput() const
Definition: PFTau.cc:210
double dCrackEta(double eta)
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:74
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
Definition: DDAxes.h:10