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  std::cout << "Error: AntiElectronMVA not properly initialized.\n";
256  return -99.;
257  }
258 
259  Float_t TauEmFraction = TMath::Max(TauEmFract, float(0.));
260  Float_t TauNumHitsVariable = (TauGSFNumHits - TauKFNumHits)/(TauGSFNumHits + TauKFNumHits);
261  Float_t ElecEtotOverPin = (ElecEe + ElecEgamma)/ElecPin;
262  Float_t ElecEgammaOverPdif = ElecEgamma/(ElecPin - ElecPout);
263 
264  double mva = -99.;
265  if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf < 0.5) {
266  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
267  Var_NoEleMatch_woGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
268  Var_NoEleMatch_woGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
269  Var_NoEleMatch_woGwoGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
270  Var_NoEleMatch_woGwoGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
271  Var_NoEleMatch_woGwoGSF_Barrel_[4] = TauEmFraction;
272  Var_NoEleMatch_woGwoGSF_Barrel_[5] = TauLeadPFChargedHadrHoP;
273  Var_NoEleMatch_woGwoGSF_Barrel_[6] = TauLeadPFChargedHadrEoP;
274  Var_NoEleMatch_woGwoGSF_Barrel_[7] = TauVisMass;
275  Var_NoEleMatch_woGwoGSF_Barrel_[8] = TaudCrackEta;
276  Var_NoEleMatch_woGwoGSF_Barrel_[9] = TaudCrackPhi;
278  } else {
279  Var_NoEleMatch_woGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
280  Var_NoEleMatch_woGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
281  Var_NoEleMatch_woGwoGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
282  Var_NoEleMatch_woGwoGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
283  Var_NoEleMatch_woGwoGSF_Endcap_[4] = TauEmFraction;
284  Var_NoEleMatch_woGwoGSF_Endcap_[5] = TauLeadPFChargedHadrHoP;
285  Var_NoEleMatch_woGwoGSF_Endcap_[6] = TauLeadPFChargedHadrEoP;
286  Var_NoEleMatch_woGwoGSF_Endcap_[7] = TauVisMass;
287  Var_NoEleMatch_woGwoGSF_Endcap_[8] = TaudCrackEta;
289  }
290  } else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands == 0 && TauHasGsf > 0.5) {
291  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
292  Var_NoEleMatch_woGwGSF_Barrel_[0] = TauEtaAtEcalEntrance;
293  Var_NoEleMatch_woGwGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
294  Var_NoEleMatch_woGwGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
295  Var_NoEleMatch_woGwGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
296  Var_NoEleMatch_woGwGSF_Barrel_[4] = TauEmFraction;
297  Var_NoEleMatch_woGwGSF_Barrel_[5] = TauLeadPFChargedHadrHoP;
298  Var_NoEleMatch_woGwGSF_Barrel_[6] = TauLeadPFChargedHadrEoP;
299  Var_NoEleMatch_woGwGSF_Barrel_[7] = TauVisMass;
300  Var_NoEleMatch_woGwGSF_Barrel_[8] = TauHadrMva;
301  Var_NoEleMatch_woGwGSF_Barrel_[9] = TauGSFChi2;
302  Var_NoEleMatch_woGwGSF_Barrel_[10] = TauNumHitsVariable;
303  Var_NoEleMatch_woGwGSF_Barrel_[11] = TauGSFTrackResol;
304  Var_NoEleMatch_woGwGSF_Barrel_[12] = TauGSFTracklnPt;
305  Var_NoEleMatch_woGwGSF_Barrel_[13] = TauGSFTrackEta;
306  Var_NoEleMatch_woGwGSF_Barrel_[14] = TaudCrackEta;
307  Var_NoEleMatch_woGwGSF_Barrel_[15] = TaudCrackPhi;
309  } else {
310  Var_NoEleMatch_woGwGSF_Endcap_[0] = TauEtaAtEcalEntrance;
311  Var_NoEleMatch_woGwGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
312  Var_NoEleMatch_woGwGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
313  Var_NoEleMatch_woGwGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
314  Var_NoEleMatch_woGwGSF_Endcap_[4] = TauEmFraction;
315  Var_NoEleMatch_woGwGSF_Endcap_[5] = TauLeadPFChargedHadrHoP;
316  Var_NoEleMatch_woGwGSF_Endcap_[6] = TauLeadPFChargedHadrEoP;
317  Var_NoEleMatch_woGwGSF_Endcap_[7] = TauVisMass;
318  Var_NoEleMatch_woGwGSF_Endcap_[8] = TauHadrMva;
319  Var_NoEleMatch_woGwGSF_Endcap_[9] = TauGSFChi2;
320  Var_NoEleMatch_woGwGSF_Endcap_[10] = TauNumHitsVariable;
321  Var_NoEleMatch_woGwGSF_Endcap_[11] = TauGSFTrackResol;
322  Var_NoEleMatch_woGwGSF_Endcap_[12] = TauGSFTracklnPt;
323  Var_NoEleMatch_woGwGSF_Endcap_[13] = TauGSFTrackEta;
324  Var_NoEleMatch_woGwGSF_Endcap_[14] = TaudCrackEta;
326  }
327  } else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
328  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ){
329  Var_NoEleMatch_wGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
330  Var_NoEleMatch_wGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
331  Var_NoEleMatch_wGwoGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
332  Var_NoEleMatch_wGwoGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
333  Var_NoEleMatch_wGwoGSF_Barrel_[4] = TauEmFraction;
334  Var_NoEleMatch_wGwoGSF_Barrel_[5] = TauSignalPFGammaCands;
335  Var_NoEleMatch_wGwoGSF_Barrel_[6] = TauLeadPFChargedHadrHoP;
336  Var_NoEleMatch_wGwoGSF_Barrel_[7] = TauLeadPFChargedHadrEoP;
337  Var_NoEleMatch_wGwoGSF_Barrel_[8] = TauVisMass;
338  Var_NoEleMatch_wGwoGSF_Barrel_[9] = TauGammaEtaMom;
339  Var_NoEleMatch_wGwoGSF_Barrel_[10] = TauGammaPhiMom;
340  Var_NoEleMatch_wGwoGSF_Barrel_[11] = TauGammaEnFrac;
341  Var_NoEleMatch_wGwoGSF_Barrel_[12] = TaudCrackEta;
342  Var_NoEleMatch_wGwoGSF_Barrel_[13] = TaudCrackPhi;
344  } else {
345  Var_NoEleMatch_wGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
346  Var_NoEleMatch_wGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
347  Var_NoEleMatch_wGwoGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
348  Var_NoEleMatch_wGwoGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
349  Var_NoEleMatch_wGwoGSF_Endcap_[4] = TauEmFraction;
350  Var_NoEleMatch_wGwoGSF_Endcap_[5] = TauSignalPFGammaCands;
351  Var_NoEleMatch_wGwoGSF_Endcap_[6] = TauLeadPFChargedHadrHoP;
352  Var_NoEleMatch_wGwoGSF_Endcap_[7] = TauLeadPFChargedHadrEoP;
353  Var_NoEleMatch_wGwoGSF_Endcap_[8] = TauVisMass;
354  Var_NoEleMatch_wGwoGSF_Endcap_[9] = TauGammaEtaMom;
355  Var_NoEleMatch_wGwoGSF_Endcap_[10] = TauGammaPhiMom;
356  Var_NoEleMatch_wGwoGSF_Endcap_[11] = TauGammaEnFrac;
357  Var_NoEleMatch_wGwoGSF_Endcap_[12] = TaudCrackEta;
359  }
360  }
361  else if ( deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
362  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
363  Var_NoEleMatch_wGwGSF_Barrel_[0] = TauEtaAtEcalEntrance;
364  Var_NoEleMatch_wGwGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
365  Var_NoEleMatch_wGwGSF_Barrel_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
366  Var_NoEleMatch_wGwGSF_Barrel_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
367  Var_NoEleMatch_wGwGSF_Barrel_[4] = TauEmFraction;
368  Var_NoEleMatch_wGwGSF_Barrel_[5] = TauSignalPFGammaCands;
369  Var_NoEleMatch_wGwGSF_Barrel_[6] = TauLeadPFChargedHadrHoP;
370  Var_NoEleMatch_wGwGSF_Barrel_[7] = TauLeadPFChargedHadrEoP;
371  Var_NoEleMatch_wGwGSF_Barrel_[8] = TauVisMass;
372  Var_NoEleMatch_wGwGSF_Barrel_[9] = TauHadrMva;
373  Var_NoEleMatch_wGwGSF_Barrel_[10] = TauGammaEtaMom;
374  Var_NoEleMatch_wGwGSF_Barrel_[11] = TauGammaPhiMom;
375  Var_NoEleMatch_wGwGSF_Barrel_[12] = TauGammaEnFrac;
376  Var_NoEleMatch_wGwGSF_Barrel_[13] = TauGSFChi2;
377  Var_NoEleMatch_wGwGSF_Barrel_[14] = TauNumHitsVariable;
378  Var_NoEleMatch_wGwGSF_Barrel_[15] = TauGSFTrackResol;
379  Var_NoEleMatch_wGwGSF_Barrel_[16] = TauGSFTracklnPt;
380  Var_NoEleMatch_wGwGSF_Barrel_[17] = TauGSFTrackEta;
381  Var_NoEleMatch_wGwGSF_Barrel_[18] = TaudCrackEta;
382  Var_NoEleMatch_wGwGSF_Barrel_[19] = TaudCrackPhi;
384  } else {
385  Var_NoEleMatch_wGwGSF_Endcap_[0] = TauEtaAtEcalEntrance;
386  Var_NoEleMatch_wGwGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
387  Var_NoEleMatch_wGwGSF_Endcap_[2] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
388  Var_NoEleMatch_wGwGSF_Endcap_[3] = TMath::Log(TMath::Max(float(1.), TauPt));
389  Var_NoEleMatch_wGwGSF_Endcap_[4] = TauEmFraction;
390  Var_NoEleMatch_wGwGSF_Endcap_[5] = TauSignalPFGammaCands;
391  Var_NoEleMatch_wGwGSF_Endcap_[6] = TauLeadPFChargedHadrHoP;
392  Var_NoEleMatch_wGwGSF_Endcap_[7] = TauLeadPFChargedHadrEoP;
393  Var_NoEleMatch_wGwGSF_Endcap_[8] = TauVisMass;
394  Var_NoEleMatch_wGwGSF_Endcap_[9] = TauHadrMva;
395  Var_NoEleMatch_wGwGSF_Endcap_[10] = TauGammaEtaMom;
396  Var_NoEleMatch_wGwGSF_Endcap_[11] = TauGammaPhiMom;
397  Var_NoEleMatch_wGwGSF_Endcap_[12] = TauGammaEnFrac;
398  Var_NoEleMatch_wGwGSF_Endcap_[13] = TauGSFChi2;
399  Var_NoEleMatch_wGwGSF_Endcap_[14] = TauNumHitsVariable;
400  Var_NoEleMatch_wGwGSF_Endcap_[15] = TauGSFTrackResol;
401  Var_NoEleMatch_wGwGSF_Endcap_[16] = TauGSFTracklnPt;
402  Var_NoEleMatch_wGwGSF_Endcap_[17] = TauGSFTrackEta;
403  Var_NoEleMatch_wGwGSF_Endcap_[18] = TaudCrackEta;
405  }
406  } else if ( TauSignalPFGammaCands == 0 && TauHasGsf < 0.5 ) {
407  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
408  Var_woGwoGSF_Barrel_[0] = ElecEtotOverPin;
409  Var_woGwoGSF_Barrel_[1] = ElecEgammaOverPdif;
410  Var_woGwoGSF_Barrel_[2] = ElecFbrem;
411  Var_woGwoGSF_Barrel_[3] = ElecChi2GSF;
412  Var_woGwoGSF_Barrel_[4] = ElecGSFNumHits;
413  Var_woGwoGSF_Barrel_[5] = ElecGSFTrackResol;
414  Var_woGwoGSF_Barrel_[6] = ElecGSFTracklnPt;
415  Var_woGwoGSF_Barrel_[7] = ElecGSFTrackEta;
416  Var_woGwoGSF_Barrel_[8] = TauEtaAtEcalEntrance;
417  Var_woGwoGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
418  Var_woGwoGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
419  Var_woGwoGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
420  Var_woGwoGSF_Barrel_[12] = TauEmFraction;
421  Var_woGwoGSF_Barrel_[13] = TauLeadPFChargedHadrHoP;
422  Var_woGwoGSF_Barrel_[14] = TauLeadPFChargedHadrEoP;
423  Var_woGwoGSF_Barrel_[15] = TauVisMass;
424  Var_woGwoGSF_Barrel_[16] = TaudCrackEta;
425  Var_woGwoGSF_Barrel_[17] = TaudCrackPhi;
427  } else {
428  Var_woGwoGSF_Endcap_[0] = ElecEtotOverPin;
429  Var_woGwoGSF_Endcap_[1] = ElecEgammaOverPdif;
430  Var_woGwoGSF_Endcap_[2] = ElecFbrem;
431  Var_woGwoGSF_Endcap_[3] = ElecChi2GSF;
432  Var_woGwoGSF_Endcap_[4] = ElecGSFNumHits;
433  Var_woGwoGSF_Endcap_[5] = ElecGSFTrackResol;
434  Var_woGwoGSF_Endcap_[6] = ElecGSFTracklnPt;
435  Var_woGwoGSF_Endcap_[7] = ElecGSFTrackEta;
436  Var_woGwoGSF_Endcap_[8] = TauEtaAtEcalEntrance;
437  Var_woGwoGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
438  Var_woGwoGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
439  Var_woGwoGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
440  Var_woGwoGSF_Endcap_[12] = TauEmFraction;
441  Var_woGwoGSF_Endcap_[13] = TauLeadPFChargedHadrHoP;
442  Var_woGwoGSF_Endcap_[14] = TauLeadPFChargedHadrEoP;
443  Var_woGwoGSF_Endcap_[15] = TauVisMass;
444  Var_woGwoGSF_Endcap_[16] = TaudCrackEta;
446  }
447  } else if ( TauSignalPFGammaCands == 0 && TauHasGsf > 0.5 ) {
448  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
449  Var_woGwGSF_Barrel_[0] = ElecEtotOverPin;
450  Var_woGwGSF_Barrel_[1] = ElecEgammaOverPdif;
451  Var_woGwGSF_Barrel_[2] = ElecFbrem;
452  Var_woGwGSF_Barrel_[3] = ElecChi2GSF;
453  Var_woGwGSF_Barrel_[4] = ElecGSFNumHits;
454  Var_woGwGSF_Barrel_[5] = ElecGSFTrackResol;
455  Var_woGwGSF_Barrel_[6] = ElecGSFTracklnPt;
456  Var_woGwGSF_Barrel_[7] = ElecGSFTrackEta;
457  Var_woGwGSF_Barrel_[8] = TauEtaAtEcalEntrance;
458  Var_woGwGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
459  Var_woGwGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
460  Var_woGwGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
461  Var_woGwGSF_Barrel_[12] = TauEmFraction;
462  Var_woGwGSF_Barrel_[13] = TauLeadPFChargedHadrHoP;
463  Var_woGwGSF_Barrel_[14] = TauLeadPFChargedHadrEoP;
464  Var_woGwGSF_Barrel_[15] = TauVisMass;
465  Var_woGwGSF_Barrel_[16] = TauHadrMva;
466  Var_woGwGSF_Barrel_[17] = TauGSFChi2;
467  Var_woGwGSF_Barrel_[18] = TauNumHitsVariable;
468  Var_woGwGSF_Barrel_[19] = TauGSFTrackResol;
469  Var_woGwGSF_Barrel_[20] = TauGSFTracklnPt;
470  Var_woGwGSF_Barrel_[21] = TauGSFTrackEta;
471  Var_woGwGSF_Barrel_[22] = TaudCrackEta;
472  Var_woGwGSF_Barrel_[23] = TaudCrackPhi;
474  } else {
475  Var_woGwGSF_Endcap_[0] = ElecEtotOverPin;
476  Var_woGwGSF_Endcap_[1] = ElecEgammaOverPdif;
477  Var_woGwGSF_Endcap_[2] = ElecFbrem;
478  Var_woGwGSF_Endcap_[3] = ElecChi2GSF;
479  Var_woGwGSF_Endcap_[4] = ElecGSFNumHits;
480  Var_woGwGSF_Endcap_[5] = ElecGSFTrackResol;
481  Var_woGwGSF_Endcap_[6] = ElecGSFTracklnPt;
482  Var_woGwGSF_Endcap_[7] = ElecGSFTrackEta;
483  Var_woGwGSF_Endcap_[8] = TauEtaAtEcalEntrance;
484  Var_woGwGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
485  Var_woGwGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
486  Var_woGwGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
487  Var_woGwGSF_Endcap_[12] = TauEmFraction;
488  Var_woGwGSF_Endcap_[13] = TauLeadPFChargedHadrHoP;
489  Var_woGwGSF_Endcap_[14] = TauLeadPFChargedHadrEoP;
490  Var_woGwGSF_Endcap_[15] = TauVisMass;
491  Var_woGwGSF_Endcap_[16] = TauHadrMva;
492  Var_woGwGSF_Endcap_[17] = TauGSFChi2;
493  Var_woGwGSF_Endcap_[18] = TauNumHitsVariable;
494  Var_woGwGSF_Endcap_[19] = TauGSFTrackResol;
495  Var_woGwGSF_Endcap_[20] = TauGSFTracklnPt;
496  Var_woGwGSF_Endcap_[21] = TauGSFTrackEta;
497  Var_woGwGSF_Endcap_[22] = TaudCrackEta;
499  }
500  } else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
501  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
502  Var_wGwoGSF_Barrel_[0] = ElecEtotOverPin;
503  Var_wGwoGSF_Barrel_[1] = ElecEgammaOverPdif;
504  Var_wGwoGSF_Barrel_[2] = ElecFbrem;
505  Var_wGwoGSF_Barrel_[3] = ElecChi2GSF;
506  Var_wGwoGSF_Barrel_[4] = ElecGSFNumHits;
507  Var_wGwoGSF_Barrel_[5] = ElecGSFTrackResol;
508  Var_wGwoGSF_Barrel_[6] = ElecGSFTracklnPt;
509  Var_wGwoGSF_Barrel_[7] = ElecGSFTrackEta;
510  Var_wGwoGSF_Barrel_[8] = TauEtaAtEcalEntrance;
511  Var_wGwoGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
512  Var_wGwoGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
513  Var_wGwoGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
514  Var_wGwoGSF_Barrel_[12] = TauEmFraction;
515  Var_wGwoGSF_Barrel_[13] = TauSignalPFGammaCands;
516  Var_wGwoGSF_Barrel_[14] = TauLeadPFChargedHadrHoP;
517  Var_wGwoGSF_Barrel_[15] = TauLeadPFChargedHadrEoP;
518  Var_wGwoGSF_Barrel_[16] = TauVisMass;
519  Var_wGwoGSF_Barrel_[17] = TauGammaEtaMom;
520  Var_wGwoGSF_Barrel_[18] = TauGammaPhiMom;
521  Var_wGwoGSF_Barrel_[19] = TauGammaEnFrac;
522  Var_wGwoGSF_Barrel_[20] = TaudCrackEta;
523  Var_wGwoGSF_Barrel_[21] = TaudCrackPhi;
525  } else {
526  Var_wGwoGSF_Endcap_[0] = ElecEtotOverPin;
527  Var_wGwoGSF_Endcap_[1] = ElecEgammaOverPdif;
528  Var_wGwoGSF_Endcap_[2] = ElecFbrem;
529  Var_wGwoGSF_Endcap_[3] = ElecChi2GSF;
530  Var_wGwoGSF_Endcap_[4] = ElecGSFNumHits;
531  Var_wGwoGSF_Endcap_[5] = ElecGSFTrackResol;
532  Var_wGwoGSF_Endcap_[6] = ElecGSFTracklnPt;
533  Var_wGwoGSF_Endcap_[7] = ElecGSFTrackEta;
534  Var_wGwoGSF_Endcap_[8] = TauEtaAtEcalEntrance;
535  Var_wGwoGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
536  Var_wGwoGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
537  Var_wGwoGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
538  Var_wGwoGSF_Endcap_[12] = TauEmFraction;
539  Var_wGwoGSF_Endcap_[13] = TauSignalPFGammaCands;
540  Var_wGwoGSF_Endcap_[14] = TauLeadPFChargedHadrHoP;
541  Var_wGwoGSF_Endcap_[15] = TauLeadPFChargedHadrEoP;
542  Var_wGwoGSF_Endcap_[16] = TauVisMass;
543  Var_wGwoGSF_Endcap_[17] = TauGammaEtaMom;
544  Var_wGwoGSF_Endcap_[18] = TauGammaPhiMom;
545  Var_wGwoGSF_Endcap_[19] = TauGammaEnFrac;
546  Var_wGwoGSF_Endcap_[20] = TaudCrackEta;
548  }
549  } else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 ) {
550  if ( TMath::Abs(TauEtaAtEcalEntrance) < 1.479 ) {
551  Var_wGwGSF_Barrel_[0] = ElecEtotOverPin;
552  Var_wGwGSF_Barrel_[1] = ElecEgammaOverPdif;
553  Var_wGwGSF_Barrel_[2] = ElecFbrem;
554  Var_wGwGSF_Barrel_[3] = ElecChi2GSF;
555  Var_wGwGSF_Barrel_[4] = ElecGSFNumHits;
556  Var_wGwGSF_Barrel_[5] = ElecGSFTrackResol;
557  Var_wGwGSF_Barrel_[6] = ElecGSFTracklnPt;
558  Var_wGwGSF_Barrel_[7] = ElecGSFTrackEta;
559  Var_wGwGSF_Barrel_[8] = TauEtaAtEcalEntrance;
560  Var_wGwGSF_Barrel_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
561  Var_wGwGSF_Barrel_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
562  Var_wGwGSF_Barrel_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
563  Var_wGwGSF_Barrel_[12] = TauEmFraction;
564  Var_wGwGSF_Barrel_[13] = TauSignalPFGammaCands;
565  Var_wGwGSF_Barrel_[14] = TauLeadPFChargedHadrHoP;
566  Var_wGwGSF_Barrel_[15] = TauLeadPFChargedHadrEoP;
567  Var_wGwGSF_Barrel_[16] = TauVisMass;
568  Var_wGwGSF_Barrel_[17] = TauHadrMva;
569  Var_wGwGSF_Barrel_[18] = TauGammaEtaMom;
570  Var_wGwGSF_Barrel_[19] = TauGammaPhiMom;
571  Var_wGwGSF_Barrel_[20] = TauGammaEnFrac;
572  Var_wGwGSF_Barrel_[21] = TauGSFChi2;
573  Var_wGwGSF_Barrel_[22] = TauNumHitsVariable;
574  Var_wGwGSF_Barrel_[23] = TauGSFTrackResol;
575  Var_wGwGSF_Barrel_[24] = TauGSFTracklnPt;
576  Var_wGwGSF_Barrel_[25] = TauGSFTrackEta;
577  Var_wGwGSF_Barrel_[26] = TaudCrackEta;
578  Var_wGwGSF_Barrel_[27] = TaudCrackPhi;
580  } else {
581  Var_wGwGSF_Endcap_[0] = ElecEtotOverPin;
582  Var_wGwGSF_Endcap_[1] = ElecEgammaOverPdif;
583  Var_wGwGSF_Endcap_[2] = ElecFbrem;
584  Var_wGwGSF_Endcap_[3] = ElecChi2GSF;
585  Var_wGwGSF_Endcap_[4] = ElecGSFNumHits;
586  Var_wGwGSF_Endcap_[5] = ElecGSFTrackResol;
587  Var_wGwGSF_Endcap_[6] = ElecGSFTracklnPt;
588  Var_wGwGSF_Endcap_[7] = ElecGSFTrackEta;
589  Var_wGwGSF_Endcap_[8] = TauEtaAtEcalEntrance;
590  Var_wGwGSF_Endcap_[9] = TauLeadChargedPFCandEtaAtEcalEntrance;
591  Var_wGwGSF_Endcap_[10] = TMath::Min(float(2.), TauLeadChargedPFCandPt/TMath::Max(float(1.), TauPt));
592  Var_wGwGSF_Endcap_[11] = TMath::Log(TMath::Max(float(1.), TauPt));
593  Var_wGwGSF_Endcap_[12] = TauEmFraction;
594  Var_wGwGSF_Endcap_[13] = TauSignalPFGammaCands;
595  Var_wGwGSF_Endcap_[14] = TauLeadPFChargedHadrHoP;
596  Var_wGwGSF_Endcap_[15] = TauLeadPFChargedHadrEoP;
597  Var_wGwGSF_Endcap_[16] = TauVisMass;
598  Var_wGwGSF_Endcap_[17] = TauHadrMva;
599  Var_wGwGSF_Endcap_[18] = TauGammaEtaMom;
600  Var_wGwGSF_Endcap_[19] = TauGammaPhiMom;
601  Var_wGwGSF_Endcap_[20] = TauGammaEnFrac;
602  Var_wGwGSF_Endcap_[21] = TauGSFChi2;
603  Var_wGwGSF_Endcap_[22] = TauNumHitsVariable;
604  Var_wGwGSF_Endcap_[23] = TauGSFTrackResol;
605  Var_wGwGSF_Endcap_[24] = TauGSFTracklnPt;
606  Var_wGwGSF_Endcap_[25] = TauGSFTrackEta;
607  Var_wGwGSF_Endcap_[26] = TaudCrackEta;
609  }
610  }
611  return mva;
612 }
613 
615  const reco::GsfElectron& theGsfEle)
616 
617 {
618  Float_t TauEtaAtEcalEntrance = -99.;
619  float sumEtaTimesEnergy = 0.;
620  float sumEnergy = 0.;
621  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
622  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
623  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
624  sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
625  sumEnergy += (*pfCandidate)->energy();
626  }
627  if ( sumEnergy > 0. ) {
628  TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
629  }
630 
631  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
632  float TauLeadChargedPFCandPt = -99.;
633  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
634  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
635  const reco::Track* track = 0;
636  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
637  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
638  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
639  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
640  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
641  if ( track ) {
642  if ( track->pt() > TauLeadChargedPFCandPt ) {
643  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
644  TauLeadChargedPFCandPt = track->pt();
645  }
646  }
647  }
648 
649  Float_t TauPt = thePFTau.pt();
650  Float_t TauEmFraction = TMath::Max(thePFTau.emFraction(), (Float_t)0.);
651  Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size();
652  Float_t TauLeadPFChargedHadrHoP = 0.;
653  Float_t TauLeadPFChargedHadrEoP = 0.;
654  if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) {
655  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
656  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
657  }
658  Float_t TauVisMass = thePFTau.mass();
659  Float_t TauHadrMva = TMath::Max(thePFTau.electronPreIDOutput(), float(-1.0));
660  std::vector<Float_t> GammasdEta;
661  std::vector<Float_t> GammasdPhi;
662  std::vector<Float_t> GammasPt;
663  for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) {
664  reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i);
665  if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) {
666  GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta());
667  GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi());
668  } else {
669  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
670  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
671  }
672  GammasPt.push_back(gamma->pt());
673  }
674  Float_t TauKFNumHits = -99.;
675  if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) {
676  TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits();
677  }
678  Float_t TauGSFNumHits = -99.;
679  Float_t TauGSFChi2 = -99.;
680  Float_t TauGSFTrackResol = -99.;
681  Float_t TauGSFTracklnPt = -99.;
682  Float_t TauGSFTrackEta = -99.;
683  if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) {
684  TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2();
685  TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits();
686  if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) {
687  TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt();
688  TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*TMath::Ln10();
689  }
690  TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta();
691  }
692  Float_t TauPhi = thePFTau.phi();
693  float sumPhiTimesEnergy = 0.;
694  float sumEnergyPhi = 0.;
695  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
696  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
697  sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
698  sumEnergyPhi += (*pfCandidate)->energy();
699  }
700  if ( sumEnergyPhi > 0. ) {
701  TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
702  }
703  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
704  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
705  Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size();
706  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
707 
708  Float_t ElecEta = theGsfEle.eta();
709  Float_t ElecPhi = theGsfEle.phi();
710  Float_t ElecPt = theGsfEle.pt();
711  //Variables related to the electron Cluster
712  Float_t ElecEe = 0.;
713  Float_t ElecEgamma = 0.;
714  reco::SuperClusterRef pfSuperCluster = theGsfEle.parentSuperCluster();
715  if ( pfSuperCluster.isNonnull() && pfSuperCluster.isAvailable() ) {
716  for ( reco::CaloCluster_iterator pfCluster = pfSuperCluster->clustersBegin();
717  pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
718  double pfClusterEn = (*pfCluster)->energy();
719  if ( pfCluster == pfSuperCluster->clustersBegin() ) ElecEe += pfClusterEn;
720  else ElecEgamma += pfClusterEn;
721  }
722  }
723  Float_t ElecPin = TMath::Sqrt(theGsfEle.trackMomentumAtVtx().Mag2());
724  Float_t ElecPout = TMath::Sqrt(theGsfEle.trackMomentumOut().Mag2());
725  Float_t ElecFbrem = theGsfEle.fbrem();
726  //Variables related to the GsfTrack
727  Float_t ElecChi2GSF = -99.;
728  Float_t ElecGSFNumHits = -99.;
729  Float_t ElecGSFTrackResol = -99.;
730  Float_t ElecGSFTracklnPt = -99.;
731  Float_t ElecGSFTrackEta = -99.;
732  if ( theGsfEle.gsfTrack().isNonnull() ) {
733  ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
734  ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
735  if ( theGsfEle.gsfTrack()->pt() > 0. ) {
736  ElecGSFTrackResol = theGsfEle.gsfTrack()->ptError()/theGsfEle.gsfTrack()->pt();
737  ElecGSFTracklnPt = log(theGsfEle.gsfTrack()->pt())*TMath::Ln10();
738  }
739  ElecGSFTrackEta = theGsfEle.gsfTrack()->eta();
740  }
741 
742  return MVAValue(TauEtaAtEcalEntrance,
743  TauPt,
744  TauLeadChargedPFCandEtaAtEcalEntrance,
745  TauLeadChargedPFCandPt,
746  TaudCrackEta,
747  TaudCrackPhi,
748  TauEmFraction,
749  TauSignalPFGammaCands,
750  TauLeadPFChargedHadrHoP,
751  TauLeadPFChargedHadrEoP,
752  TauVisMass,
753  TauHadrMva,
754  GammasdEta,
755  GammasdPhi,
756  GammasPt,
757  TauKFNumHits,
758  TauGSFNumHits,
759  TauGSFChi2,
760  TauGSFTrackResol,
761  TauGSFTracklnPt,
762  TauGSFTrackEta,
763  TauPhi,
764  TauSignalPFChargedCands,
765  TauHasGsf,
766  ElecEta,
767  ElecPhi,
768  ElecPt,
769  ElecEe,
770  ElecEgamma,
771  ElecPin,
772  ElecPout,
773  ElecFbrem,
774  ElecChi2GSF,
775  ElecGSFNumHits,
776  ElecGSFTrackResol,
777  ElecGSFTracklnPt,
778  ElecGSFTrackEta);
779 }
780 
782 {
783  Float_t TauEtaAtEcalEntrance = -99.;
784  float sumEtaTimesEnergy = 0.;
785  float sumEnergy = 0.;
786  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
787  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
788  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
789  sumEtaTimesEnergy += (*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy();
790  sumEnergy += (*pfCandidate)->energy();
791  }
792  if ( sumEnergy > 0. ) {
793  TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
794  }
795 
796  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
797  float TauLeadChargedPFCandPt = -99.;
798  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
799  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
800  const reco::Track* track = 0;
801  if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
802  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
803  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
804  else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
805  else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
806  if ( track ) {
807  if ( track->pt() > TauLeadChargedPFCandPt ) {
808  TauLeadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().eta();
809  TauLeadChargedPFCandPt = track->pt();
810  }
811  }
812  }
813 
814  Float_t TauPt = thePFTau.pt();
815  Float_t TauEmFraction = TMath::Max(thePFTau.emFraction(), (Float_t)0.);
816  Float_t TauSignalPFGammaCands = thePFTau.signalPFGammaCands().size();
817  Float_t TauLeadPFChargedHadrHoP = 0.;
818  Float_t TauLeadPFChargedHadrEoP = 0.;
819  if ( thePFTau.leadPFChargedHadrCand()->p() > 0. ) {
820  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
821  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy()/thePFTau.leadPFChargedHadrCand()->p();
822  }
823  Float_t TauVisMass = thePFTau.mass();
824  Float_t TauHadrMva = TMath::Max(thePFTau.electronPreIDOutput(),float(-1.0));
825  std::vector<Float_t> GammasdEta;
826  std::vector<Float_t> GammasdPhi;
827  std::vector<Float_t> GammasPt;
828  for ( unsigned i = 0 ; i < thePFTau.signalPFGammaCands().size(); ++i ) {
829  reco::PFCandidatePtr gamma = thePFTau.signalPFGammaCands().at(i);
830  if ( thePFTau.leadPFChargedHadrCand().isNonnull() ) {
831  GammasdEta.push_back(gamma->eta() - thePFTau.leadPFChargedHadrCand()->eta());
832  GammasdPhi.push_back(gamma->phi() - thePFTau.leadPFChargedHadrCand()->phi());
833  } else {
834  GammasdEta.push_back(gamma->eta() - thePFTau.eta());
835  GammasdPhi.push_back(gamma->phi() - thePFTau.phi());
836  }
837  GammasPt.push_back(gamma->pt());
838  }
839  Float_t TauKFNumHits = -99.;
840  if ( (thePFTau.leadPFChargedHadrCand()->trackRef()).isNonnull() ) {
841  TauKFNumHits = thePFTau.leadPFChargedHadrCand()->trackRef()->numberOfValidHits();
842  }
843  Float_t TauGSFNumHits = -99.;
844  Float_t TauGSFChi2 = -99.;
845  Float_t TauGSFTrackResol = -99.;
846  Float_t TauGSFTracklnPt = -99.;
847  Float_t TauGSFTrackEta = -99.;
848  if ( (thePFTau.leadPFChargedHadrCand()->gsfTrackRef()).isNonnull() ) {
849  TauGSFChi2 = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->normalizedChi2();
850  TauGSFNumHits = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->numberOfValidHits();
851  if ( thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt() > 0. ) {
852  TauGSFTrackResol = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->ptError()/thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt();
853  TauGSFTracklnPt = log(thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->pt())*TMath::Ln10();
854  }
855  TauGSFTrackEta = thePFTau.leadPFChargedHadrCand()->gsfTrackRef()->eta();
856  }
857  Float_t TauPhi = thePFTau.phi();
858  float sumPhiTimesEnergy = 0.;
859  float sumEnergyPhi = 0.;
860  for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
861  pfCandidate != signalPFCands.end(); ++pfCandidate ) {
862  sumPhiTimesEnergy += (*pfCandidate)->positionAtECALEntrance().phi()*(*pfCandidate)->energy();
863  sumEnergyPhi += (*pfCandidate)->energy();
864  }
865  if ( sumEnergyPhi > 0. ) {
866  TauPhi = sumPhiTimesEnergy/sumEnergyPhi;
867  }
868  Float_t TaudCrackPhi = dCrackPhi(TauPhi,TauEtaAtEcalEntrance) ;
869  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance) ;
870  Float_t TauSignalPFChargedCands = thePFTau.signalPFChargedHadrCands().size();
871  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
872 
873  Float_t dummyElecEta = 9.9;
874 
875  return MVAValue(TauEtaAtEcalEntrance,
876  TauPt,
877  TauLeadChargedPFCandEtaAtEcalEntrance,
878  TauLeadChargedPFCandPt,
879  TaudCrackEta,
880  TaudCrackPhi,
881  TauEmFraction,
882  TauSignalPFGammaCands,
883  TauLeadPFChargedHadrHoP,
884  TauLeadPFChargedHadrEoP,
885  TauVisMass,
886  TauHadrMva,
887  GammasdEta,
888  GammasdPhi,
889  GammasPt,
890  TauKFNumHits,
891  TauGSFNumHits,
892  TauGSFChi2,
893  TauGSFTrackResol,
894  TauGSFTracklnPt,
895  TauGSFTrackEta,
896  TauPhi,
897  TauSignalPFChargedCands,
898  TauHasGsf,
899  dummyElecEta,
900  0.,
901  0.,
902  0.,
903  0.,
904  0.,
905  0.,
906  0.,
907  0.,
908  0.,
909  0.,
910  0.,
911  0.);
912 }
913 
914 double AntiElectronIDMVA5GBR::minimum(double a, double b)
915 {
916  if ( TMath::Abs(b) < TMath::Abs(a) ) return b;
917  else return a;
918 }
919 
921 {
922 //--- compute the (unsigned) distance to the closest phi-crack in the ECAL barrel
923 
924  double pi = TMath::Pi(); // 3.14159265358979323846;
925 
926  // IN: define locations of the 18 phi-cracks
927  static std::vector<double> cPhi;
928  if ( cPhi.size() == 0 ) {
929  cPhi.resize(18, 0);
930  cPhi[0] = 2.97025;
931  for ( unsigned iCrack = 1; iCrack <= 17; ++iCrack ) {
932  cPhi[iCrack] = cPhi[0] - 2.*iCrack*pi/18;
933  }
934  }
935 
936  // IN: shift of this location if eta < 0
937  double delta_cPhi = 0.00638;
938 
939  double retVal = 99.;
940 
941  if ( eta >= -1.47464 && eta <= 1.47464 ) {
942 
943  // the location is shifted
944  if ( eta < 0. ) phi += delta_cPhi;
945 
946  // CV: need to bring-back phi into interval [-pi,+pi]
947  if ( phi > pi ) phi -= 2.*pi;
948  if ( phi < -pi ) phi += 2.*pi;
949 
950  if ( phi >= -pi && phi <= pi ) {
951 
952  // the problem of the extrema:
953  if ( phi < cPhi[17] || phi >= cPhi[0] ) {
954  if ( phi < 0. ) phi += 2.*pi;
955  retVal = minimum(phi - cPhi[0], phi - cPhi[17] - 2.*pi);
956  } else {
957  // between these extrema...
958  bool OK = false;
959  unsigned iCrack = 16;
960  while( !OK ) {
961  if ( phi < cPhi[iCrack] ) {
962  retVal = minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
963  OK = true;
964  } else {
965  iCrack -= 1;
966  }
967  }
968  }
969  } else {
970  retVal = 0.; // IN: if there is a problem, we assume that we are in a crack
971  }
972  } else {
973  return -99.;
974  }
975 
976  return TMath::Abs(retVal);
977 }
978 
980 {
981 //--- compute the (unsigned) distance to the closest eta-crack in the ECAL barrel
982 
983  // IN: define locations of the eta-cracks
984  double cracks[5] = { 0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00 };
985 
986  double retVal = 99.;
987 
988  for ( int iCrack = 0; iCrack < 5 ; ++iCrack ) {
989  double d = minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
990  if ( TMath::Abs(d) < TMath::Abs(retVal) ) {
991  retVal = d;
992  }
993  }
994 
995  return TMath::Abs(retVal);
996 }
const double Pi
int i
Definition: DBlmapReader.cc:9
SuperClusterRef parentSuperCluster() const
Definition: GsfElectron.h:175
const PFCandidatePtr & leadPFChargedHadrCand() const
Definition: PFTau.cc:61
void Initialize_from_file(const std::string &methodName, const std::string &gbrFile)
pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:70
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:273
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:653
bool isAvailable() const
Definition: Ref.h:276
T eta() const
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:72
double minimum(double a, double b)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
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
math::XYZVectorF trackMomentumOut() const
Definition: GsfElectron.h:275
double pt() const
track transverse momentum
Definition: TrackBase.h:129
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual float mass() const GCC11_FINAL
mass
double b
Definition: hdecay.h:120
double dCrackPhi(double phi, double eta)
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
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 pi
virtual float pt() const GCC11_FINAL
transverse momentum
double GetClassifier(const float *vector) const
Definition: GBRForest.h:60
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:170
Definition: DDAxes.h:10