CMS 3D CMS Logo

AntiElectronIDMVA6.cc
Go to the documentation of this file.
2 
4 
10 
13 
16 
17 #include <TMath.h>
18 #include <TFile.h>
19 #include <array>
20 
22  : isInitialized_(false),
23  mva_NoEleMatch_woGwoGSF_BL_(nullptr),
24  mva_NoEleMatch_wGwoGSF_BL_(nullptr),
25  mva_woGwGSF_BL_(nullptr),
26  mva_wGwGSF_BL_(nullptr),
27  mva_NoEleMatch_woGwoGSF_EC_(nullptr),
28  mva_NoEleMatch_wGwoGSF_EC_(nullptr),
29  mva_woGwGSF_EC_(nullptr),
30  mva_wGwGSF_EC_(nullptr) {
31  loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter<bool>("loadMVAfromDB") : false;
32  if (!loadMVAfromDB_) {
33  if (cfg.exists("inputFileName")) {
34  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
35  } else
36  throw cms::Exception("MVA input not defined")
37  << "Requested to load tau MVA input from ROOT file but no file provided in cfg file";
38  }
39 
40  mvaName_NoEleMatch_woGwoGSF_BL_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_woGwoGSF_BL");
41  mvaName_NoEleMatch_wGwoGSF_BL_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_wGwoGSF_BL");
42  mvaName_woGwGSF_BL_ = cfg.getParameter<std::string>("mvaName_woGwGSF_BL");
43  mvaName_wGwGSF_BL_ = cfg.getParameter<std::string>("mvaName_wGwGSF_BL");
44  mvaName_NoEleMatch_woGwoGSF_EC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_woGwoGSF_EC");
45  mvaName_NoEleMatch_wGwoGSF_EC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_wGwoGSF_EC");
46  mvaName_woGwGSF_EC_ = cfg.getParameter<std::string>("mvaName_woGwGSF_EC");
47  mvaName_wGwGSF_EC_ = cfg.getParameter<std::string>("mvaName_wGwGSF_EC");
48 
49  usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter<bool>("usePhiAtEcalEntranceExtrapolation");
50 
51  Var_NoEleMatch_woGwoGSF_Barrel_ = new Float_t[10];
52  Var_NoEleMatch_wGwoGSF_Barrel_ = new Float_t[18];
53  Var_woGwGSF_Barrel_ = new Float_t[24];
54  Var_wGwGSF_Barrel_ = new Float_t[32];
55  Var_NoEleMatch_woGwoGSF_Endcap_ = new Float_t[9];
56  Var_NoEleMatch_wGwoGSF_Endcap_ = new Float_t[17];
57  Var_woGwGSF_Endcap_ = new Float_t[23];
58  Var_wGwGSF_Endcap_ = new Float_t[31];
59 
60  bField_ = 0;
61  verbosity_ = 0;
62 }
63 
67  delete[] Var_woGwGSF_Barrel_;
68  delete[] Var_wGwGSF_Barrel_;
71  delete[] Var_woGwGSF_Endcap_;
72  delete[] Var_wGwGSF_Endcap_;
73 
74  if (!loadMVAfromDB_) {
77  delete mva_woGwGSF_BL_;
78  delete mva_wGwGSF_BL_;
81  delete mva_woGwGSF_EC_;
82  delete mva_wGwGSF_EC_;
83  }
84 
85  for (std::vector<TFile*>::iterator it = inputFilesToDelete_.begin(); it != inputFilesToDelete_.end(); ++it) {
86  delete (*it);
87  }
88 }
89 
90 namespace {
91  const GBRForest* loadMVAfromFile(TFile* inputFile, const std::string& mvaName) {
92  const GBRForest* mva = (GBRForest*)inputFile->Get(mvaName.data());
93  if (!mva)
94  throw cms::Exception("PFRecoTauDiscriminationAgainstElectronMVA6::loadMVA")
95  << " Failed to load MVA = " << mvaName.data() << " from file "
96  << " !!\n";
97 
98  return mva;
99  }
100 
101  const GBRForest* loadMVAfromDB(const edm::EventSetup& es, const std::string& mvaName) {
103  es.get<GBRWrapperRcd>().get(mvaName, mva);
104  return mva.product();
105  }
106 } // namespace
107 
109  if (!isInitialized_) {
110  if (loadMVAfromDB_) {
119  } else {
121  throw cms::Exception("PFRecoTauDiscriminationAgainstElectronMVA6::loadMVA")
122  << " Failed to find File = " << inputFileName_ << " !!\n";
123  TFile* inputFile = new TFile(inputFileName_.fullPath().data());
124 
125  mva_NoEleMatch_woGwoGSF_BL_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_woGwoGSF_BL_);
126  mva_NoEleMatch_wGwoGSF_BL_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_wGwoGSF_BL_);
127  mva_woGwGSF_BL_ = loadMVAfromFile(inputFile, mvaName_woGwGSF_BL_);
128  mva_wGwGSF_BL_ = loadMVAfromFile(inputFile, mvaName_wGwGSF_BL_);
129  mva_NoEleMatch_woGwoGSF_EC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_woGwoGSF_EC_);
130  mva_NoEleMatch_wGwoGSF_EC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_wGwoGSF_EC_);
131  mva_woGwGSF_EC_ = loadMVAfromFile(inputFile, mvaName_woGwGSF_EC_);
132  mva_wGwGSF_EC_ = loadMVAfromFile(inputFile, mvaName_wGwGSF_EC_);
133  inputFilesToDelete_.push_back(inputFile);
134  }
135  isInitialized_ = true;
136  }
137 
139  es.get<IdealMagneticFieldRecord>().get(pSetup);
140  bField_ = pSetup->inTesla(GlobalPoint(0, 0, 0)).z();
141 }
142 
143 double AntiElectronIDMVA6::MVAValue(Float_t TauPt,
144  Float_t TauEtaAtEcalEntrance,
145  Float_t TauPhi,
146  Float_t TauLeadChargedPFCandPt,
147  Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
148  Float_t TauEmFraction,
149  Float_t TauLeadPFChargedHadrHoP,
150  Float_t TauLeadPFChargedHadrEoP,
151  Float_t TauVisMassIn,
152  Float_t TaudCrackEta,
153  Float_t TaudCrackPhi,
154  Float_t TauHasGsf,
155  Int_t TauSignalPFGammaCandsIn,
156  Int_t TauSignalPFGammaCandsOut,
157  const std::vector<Float_t>& GammasdEtaInSigCone,
158  const std::vector<Float_t>& GammasdPhiInSigCone,
159  const std::vector<Float_t>& GammasPtInSigCone,
160  const std::vector<Float_t>& GammasdEtaOutSigCone,
161  const std::vector<Float_t>& GammasdPhiOutSigCone,
162  const std::vector<Float_t>& GammasPtOutSigCone,
163  Float_t ElecEta,
164  Float_t ElecPhi,
165  Float_t ElecEtotOverPin,
166  Float_t ElecChi2NormGSF,
167  Float_t ElecChi2NormKF,
168  Float_t ElecGSFNumHits,
169  Float_t ElecKFNumHits,
170  Float_t ElecGSFTrackResol,
171  Float_t ElecGSFTracklnPt,
172  Float_t ElecPin,
173  Float_t ElecPout,
174  Float_t ElecEecal,
175  Float_t ElecDeltaEta,
176  Float_t ElecDeltaPhi,
177  Float_t ElecMvaInSigmaEtaEta,
178  Float_t ElecMvaInHadEnergy,
179  Float_t ElecMvaInDeltaEta) {
180  double sumPt = 0.;
181  double dEta2 = 0.;
182  double dPhi2 = 0.;
183  double sumPt2 = 0.;
184  for (unsigned int i = 0; i < GammasPtInSigCone.size(); ++i) {
185  double pt_i = GammasPtInSigCone[i];
186  double phi_i = GammasdPhiInSigCone[i];
187  if (GammasdPhiInSigCone[i] > M_PI)
188  phi_i = GammasdPhiInSigCone[i] - 2 * M_PI;
189  else if (GammasdPhiInSigCone[i] < -M_PI)
190  phi_i = GammasdPhiInSigCone[i] + 2 * M_PI;
191  double eta_i = GammasdEtaInSigCone[i];
192  sumPt += pt_i;
193  sumPt2 += (pt_i * pt_i);
194  dEta2 += (pt_i * eta_i * eta_i);
195  dPhi2 += (pt_i * phi_i * phi_i);
196  }
197  Float_t TauGammaEnFracIn = -99.;
198  if (TauPt > 0.) {
199  TauGammaEnFracIn = sumPt / TauPt;
200  }
201  if (sumPt > 0.) {
202  dEta2 /= sumPt;
203  dPhi2 /= sumPt;
204  }
205  Float_t TauGammaEtaMomIn = std::sqrt(dEta2) * std::sqrt(TauGammaEnFracIn) * TauPt;
206  Float_t TauGammaPhiMomIn = std::sqrt(dPhi2) * std::sqrt(TauGammaEnFracIn) * TauPt;
207 
208  sumPt = 0.;
209  dEta2 = 0.;
210  dPhi2 = 0.;
211  sumPt2 = 0.;
212  for (unsigned int i = 0; i < GammasPtOutSigCone.size(); ++i) {
213  double pt_i = GammasPtOutSigCone[i];
214  double phi_i = GammasdPhiOutSigCone[i];
215  if (GammasdPhiOutSigCone[i] > M_PI)
216  phi_i = GammasdPhiOutSigCone[i] - 2 * M_PI;
217  else if (GammasdPhiOutSigCone[i] < -M_PI)
218  phi_i = GammasdPhiOutSigCone[i] + 2 * M_PI;
219  double eta_i = GammasdEtaOutSigCone[i];
220  sumPt += pt_i;
221  sumPt2 += (pt_i * pt_i);
222  dEta2 += (pt_i * eta_i * eta_i);
223  dPhi2 += (pt_i * phi_i * phi_i);
224  }
225  Float_t TauGammaEnFracOut = sumPt / TauPt;
226  if (sumPt > 0.) {
227  dEta2 /= sumPt;
228  dPhi2 /= sumPt;
229  }
230  Float_t TauGammaEtaMomOut = std::sqrt(dEta2) * std::sqrt(TauGammaEnFracOut) * TauPt;
231  Float_t TauGammaPhiMomOut = std::sqrt(dPhi2) * std::sqrt(TauGammaEnFracOut) * TauPt;
232 
233  return MVAValue(TauPt,
234  TauEtaAtEcalEntrance,
235  TauPhi,
236  TauLeadChargedPFCandPt,
237  TauLeadChargedPFCandEtaAtEcalEntrance,
238  TauEmFraction,
239  TauLeadPFChargedHadrHoP,
240  TauLeadPFChargedHadrEoP,
241  TauVisMassIn,
242  TaudCrackEta,
243  TaudCrackPhi,
244  TauHasGsf,
245  TauSignalPFGammaCandsIn,
246  TauSignalPFGammaCandsOut,
247  TauGammaEtaMomIn,
248  TauGammaEtaMomOut,
249  TauGammaPhiMomIn,
250  TauGammaPhiMomOut,
251  TauGammaEnFracIn,
252  TauGammaEnFracOut,
253  ElecEta,
254  ElecPhi,
255  ElecEtotOverPin,
256  ElecChi2NormGSF,
257  ElecChi2NormKF,
258  ElecGSFNumHits,
259  ElecKFNumHits,
260  ElecGSFTrackResol,
261  ElecGSFTracklnPt,
262  ElecPin,
263  ElecPout,
264  ElecEecal,
265  ElecDeltaEta,
266  ElecDeltaPhi,
267  ElecMvaInSigmaEtaEta,
268  ElecMvaInHadEnergy,
269  ElecMvaInDeltaEta);
270 }
271 
272 double AntiElectronIDMVA6::MVAValue(Float_t TauPt,
273  Float_t TauEtaAtEcalEntrance,
274  Float_t TauPhi,
275  Float_t TauLeadChargedPFCandPt,
276  Float_t TauLeadChargedPFCandEtaAtEcalEntrance,
277  Float_t TauEmFraction,
278  Float_t TauLeadPFChargedHadrHoP,
279  Float_t TauLeadPFChargedHadrEoP,
280  Float_t TauVisMassIn,
281  Float_t TaudCrackEta,
282  Float_t TaudCrackPhi,
283  Float_t TauHasGsf,
284  Int_t TauSignalPFGammaCandsIn,
285  Int_t TauSignalPFGammaCandsOut,
286  Float_t TauGammaEtaMomIn,
287  Float_t TauGammaEtaMomOut,
288  Float_t TauGammaPhiMomIn,
289  Float_t TauGammaPhiMomOut,
290  Float_t TauGammaEnFracIn,
291  Float_t TauGammaEnFracOut,
292  Float_t ElecEta,
293  Float_t ElecPhi,
294  Float_t ElecEtotOverPin,
295  Float_t ElecChi2NormGSF,
296  Float_t ElecChi2NormKF,
297  Float_t ElecGSFNumHits,
298  Float_t ElecKFNumHits,
299  Float_t ElecGSFTrackResol,
300  Float_t ElecGSFTracklnPt,
301  Float_t ElecPin,
302  Float_t ElecPout,
303  Float_t ElecEecal,
304  Float_t ElecDeltaEta,
305  Float_t ElecDeltaPhi,
306  Float_t ElecMvaInSigmaEtaEta,
307  Float_t ElecMvaInHadEnergy,
308  Float_t ElecMvaInDeltaEta) {
309  if (!isInitialized_) {
310  throw cms::Exception("ClassNotInitialized") << " AntiElectronMVA not properly initialized !!\n";
311  }
312 
313  double mvaValue = -99.;
314 
315  const float ECALBarrelEndcapEtaBorder = 1.479;
316  float ElecDeltaPinPoutOverPin = (ElecPin > 0.0) ? (std::abs(ElecPin - ElecPout) / ElecPin) : 1.0;
317  float ElecEecalOverPout = (ElecPout > 0.0) ? (ElecEecal / ElecPout) : 20.0;
318  float ElecNumHitsDiffOverSum = ((ElecGSFNumHits + ElecKFNumHits) > 0.0)
319  ? ((ElecGSFNumHits - ElecKFNumHits) / (ElecGSFNumHits + ElecKFNumHits))
320  : 1.0;
321 
322  if (deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCandsIn == 0 && TauHasGsf < 0.5) {
323  if (std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
324  Var_NoEleMatch_woGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
325  Var_NoEleMatch_woGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
326  Var_NoEleMatch_woGwoGSF_Barrel_[2] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
327  Var_NoEleMatch_woGwoGSF_Barrel_[3] = std::log(std::max(float(1.), TauPt));
328  Var_NoEleMatch_woGwoGSF_Barrel_[4] = TauEmFraction;
329  Var_NoEleMatch_woGwoGSF_Barrel_[5] = TauLeadPFChargedHadrHoP;
330  Var_NoEleMatch_woGwoGSF_Barrel_[6] = TauLeadPFChargedHadrEoP;
331  Var_NoEleMatch_woGwoGSF_Barrel_[7] = TauVisMassIn;
332  Var_NoEleMatch_woGwoGSF_Barrel_[8] = TaudCrackEta;
333  Var_NoEleMatch_woGwoGSF_Barrel_[9] = TaudCrackPhi;
335  } else {
336  Var_NoEleMatch_woGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
337  Var_NoEleMatch_woGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
338  Var_NoEleMatch_woGwoGSF_Endcap_[2] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
339  Var_NoEleMatch_woGwoGSF_Endcap_[3] = std::log(std::max(float(1.), TauPt));
340  Var_NoEleMatch_woGwoGSF_Endcap_[4] = TauEmFraction;
341  Var_NoEleMatch_woGwoGSF_Endcap_[5] = TauLeadPFChargedHadrHoP;
342  Var_NoEleMatch_woGwoGSF_Endcap_[6] = TauLeadPFChargedHadrEoP;
343  Var_NoEleMatch_woGwoGSF_Endcap_[7] = TauVisMassIn;
344  Var_NoEleMatch_woGwoGSF_Endcap_[8] = TaudCrackEta;
346  }
347  } else if (deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 && TauSignalPFGammaCandsIn > 0 &&
348  TauHasGsf < 0.5) {
349  if (std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
350  Var_NoEleMatch_wGwoGSF_Barrel_[0] = TauEtaAtEcalEntrance;
351  Var_NoEleMatch_wGwoGSF_Barrel_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
352  Var_NoEleMatch_wGwoGSF_Barrel_[2] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
353  Var_NoEleMatch_wGwoGSF_Barrel_[3] = std::log(std::max(float(1.), TauPt));
354  Var_NoEleMatch_wGwoGSF_Barrel_[4] = TauEmFraction;
355  Var_NoEleMatch_wGwoGSF_Barrel_[5] = TauSignalPFGammaCandsIn;
356  Var_NoEleMatch_wGwoGSF_Barrel_[6] = TauSignalPFGammaCandsOut;
357  Var_NoEleMatch_wGwoGSF_Barrel_[7] = TauLeadPFChargedHadrHoP;
358  Var_NoEleMatch_wGwoGSF_Barrel_[8] = TauLeadPFChargedHadrEoP;
359  Var_NoEleMatch_wGwoGSF_Barrel_[9] = TauVisMassIn;
360  Var_NoEleMatch_wGwoGSF_Barrel_[10] = TauGammaEtaMomIn;
361  Var_NoEleMatch_wGwoGSF_Barrel_[11] = TauGammaEtaMomOut;
362  Var_NoEleMatch_wGwoGSF_Barrel_[12] = TauGammaPhiMomIn;
363  Var_NoEleMatch_wGwoGSF_Barrel_[13] = TauGammaPhiMomOut;
364  Var_NoEleMatch_wGwoGSF_Barrel_[14] = TauGammaEnFracIn;
365  Var_NoEleMatch_wGwoGSF_Barrel_[15] = TauGammaEnFracOut;
366  Var_NoEleMatch_wGwoGSF_Barrel_[16] = TaudCrackEta;
367  Var_NoEleMatch_wGwoGSF_Barrel_[17] = TaudCrackPhi;
369  } else {
370  Var_NoEleMatch_wGwoGSF_Endcap_[0] = TauEtaAtEcalEntrance;
371  Var_NoEleMatch_wGwoGSF_Endcap_[1] = TauLeadChargedPFCandEtaAtEcalEntrance;
372  Var_NoEleMatch_wGwoGSF_Endcap_[2] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
373  Var_NoEleMatch_wGwoGSF_Endcap_[3] = std::log(std::max(float(1.), TauPt));
374  Var_NoEleMatch_wGwoGSF_Endcap_[4] = TauEmFraction;
375  Var_NoEleMatch_wGwoGSF_Endcap_[5] = TauSignalPFGammaCandsIn;
376  Var_NoEleMatch_wGwoGSF_Endcap_[6] = TauSignalPFGammaCandsOut;
377  Var_NoEleMatch_wGwoGSF_Endcap_[7] = TauLeadPFChargedHadrHoP;
378  Var_NoEleMatch_wGwoGSF_Endcap_[8] = TauLeadPFChargedHadrEoP;
379  Var_NoEleMatch_wGwoGSF_Endcap_[9] = TauVisMassIn;
380  Var_NoEleMatch_wGwoGSF_Endcap_[10] = TauGammaEtaMomIn;
381  Var_NoEleMatch_wGwoGSF_Endcap_[11] = TauGammaEtaMomOut;
382  Var_NoEleMatch_wGwoGSF_Endcap_[12] = TauGammaPhiMomIn;
383  Var_NoEleMatch_wGwoGSF_Endcap_[13] = TauGammaPhiMomOut;
384  Var_NoEleMatch_wGwoGSF_Endcap_[14] = TauGammaEnFracIn;
385  Var_NoEleMatch_wGwoGSF_Endcap_[15] = TauGammaEnFracOut;
386  Var_NoEleMatch_wGwoGSF_Endcap_[16] = TaudCrackEta;
388  }
389  } else if (TauSignalPFGammaCandsIn == 0 && TauHasGsf > 0.5) {
390  if (std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
391  Var_woGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin);
392  Var_woGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF));
393  Var_woGwGSF_Barrel_[2] = ElecGSFNumHits;
394  Var_woGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol));
395  Var_woGwGSF_Barrel_[4] = ElecGSFTracklnPt;
396  Var_woGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum;
397  Var_woGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF));
398  Var_woGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.));
399  Var_woGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.));
400  Var_woGwGSF_Barrel_[9] = ElecDeltaEta;
401  Var_woGwGSF_Barrel_[10] = ElecDeltaPhi;
402  Var_woGwGSF_Barrel_[11] = std::min(ElecMvaInSigmaEtaEta, float(0.01));
403  Var_woGwGSF_Barrel_[12] = std::min(ElecMvaInHadEnergy, float(20.));
404  Var_woGwGSF_Barrel_[13] = std::min(ElecMvaInDeltaEta, float(0.1));
405  Var_woGwGSF_Barrel_[14] = TauEtaAtEcalEntrance;
406  Var_woGwGSF_Barrel_[15] = TauLeadChargedPFCandEtaAtEcalEntrance;
407  Var_woGwGSF_Barrel_[16] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
408  Var_woGwGSF_Barrel_[17] = std::log(std::max(float(1.), TauPt));
409  Var_woGwGSF_Barrel_[18] = TauEmFraction;
410  Var_woGwGSF_Barrel_[19] = TauLeadPFChargedHadrHoP;
411  Var_woGwGSF_Barrel_[20] = TauLeadPFChargedHadrEoP;
412  Var_woGwGSF_Barrel_[21] = TauVisMassIn;
413  Var_woGwGSF_Barrel_[22] = TaudCrackEta;
414  Var_woGwGSF_Barrel_[23] = TaudCrackPhi;
416  } else {
417  Var_woGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin);
418  Var_woGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF));
419  Var_woGwGSF_Endcap_[2] = ElecGSFNumHits;
420  Var_woGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol));
421  Var_woGwGSF_Endcap_[4] = ElecGSFTracklnPt;
422  Var_woGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum;
423  Var_woGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF));
424  Var_woGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.));
425  Var_woGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.));
426  Var_woGwGSF_Endcap_[9] = ElecDeltaEta;
427  Var_woGwGSF_Endcap_[10] = ElecDeltaPhi;
428  Var_woGwGSF_Endcap_[11] = std::min(ElecMvaInSigmaEtaEta, float(0.01));
429  Var_woGwGSF_Endcap_[12] = std::min(ElecMvaInHadEnergy, float(20.));
430  Var_woGwGSF_Endcap_[13] = std::min(ElecMvaInDeltaEta, float(0.1));
431  Var_woGwGSF_Endcap_[14] = TauEtaAtEcalEntrance;
432  Var_woGwGSF_Endcap_[15] = TauLeadChargedPFCandEtaAtEcalEntrance;
433  Var_woGwGSF_Endcap_[16] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
434  Var_woGwGSF_Endcap_[17] = std::log(std::max(float(1.), TauPt));
435  Var_woGwGSF_Endcap_[18] = TauEmFraction;
436  Var_woGwGSF_Endcap_[19] = TauLeadPFChargedHadrHoP;
437  Var_woGwGSF_Endcap_[20] = TauLeadPFChargedHadrEoP;
438  Var_woGwGSF_Endcap_[21] = TauVisMassIn;
439  Var_woGwGSF_Endcap_[22] = TaudCrackEta;
441  }
442  } else if (TauSignalPFGammaCandsIn > 0 && TauHasGsf > 0.5) {
443  if (std::abs(TauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
444  Var_wGwGSF_Barrel_[0] = std::max(float(-0.1), ElecEtotOverPin);
445  Var_wGwGSF_Barrel_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF));
446  Var_wGwGSF_Barrel_[2] = ElecGSFNumHits;
447  Var_wGwGSF_Barrel_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol));
448  Var_wGwGSF_Barrel_[4] = ElecGSFTracklnPt;
449  Var_wGwGSF_Barrel_[5] = ElecNumHitsDiffOverSum;
450  Var_wGwGSF_Barrel_[6] = std::log(std::max(float(0.01), ElecChi2NormKF));
451  Var_wGwGSF_Barrel_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.));
452  Var_wGwGSF_Barrel_[8] = std::min(ElecEecalOverPout, float(20.));
453  Var_wGwGSF_Barrel_[9] = ElecDeltaEta;
454  Var_wGwGSF_Barrel_[10] = ElecDeltaPhi;
455  Var_wGwGSF_Barrel_[11] = std::min(ElecMvaInSigmaEtaEta, float(0.01));
456  Var_wGwGSF_Barrel_[12] = std::min(ElecMvaInHadEnergy, float(20.));
457  Var_wGwGSF_Barrel_[13] = std::min(ElecMvaInDeltaEta, float(0.1));
458  Var_wGwGSF_Barrel_[14] = TauEtaAtEcalEntrance;
459  Var_wGwGSF_Barrel_[15] = TauLeadChargedPFCandEtaAtEcalEntrance;
460  Var_wGwGSF_Barrel_[16] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
461  Var_wGwGSF_Barrel_[17] = std::log(std::max(float(1.), TauPt));
462  Var_wGwGSF_Barrel_[18] = TauEmFraction;
463  Var_wGwGSF_Barrel_[19] = TauSignalPFGammaCandsIn;
464  Var_wGwGSF_Barrel_[20] = TauSignalPFGammaCandsOut;
465  Var_wGwGSF_Barrel_[21] = TauLeadPFChargedHadrHoP;
466  Var_wGwGSF_Barrel_[22] = TauLeadPFChargedHadrEoP;
467  Var_wGwGSF_Barrel_[23] = TauVisMassIn;
468  Var_wGwGSF_Barrel_[24] = TauGammaEtaMomIn;
469  Var_wGwGSF_Barrel_[25] = TauGammaEtaMomOut;
470  Var_wGwGSF_Barrel_[26] = TauGammaPhiMomIn;
471  Var_wGwGSF_Barrel_[27] = TauGammaPhiMomOut;
472  Var_wGwGSF_Barrel_[28] = TauGammaEnFracIn;
473  Var_wGwGSF_Barrel_[29] = TauGammaEnFracOut;
474  Var_wGwGSF_Barrel_[30] = TaudCrackEta;
475  Var_wGwGSF_Barrel_[31] = TaudCrackPhi;
477  } else {
478  Var_wGwGSF_Endcap_[0] = std::max(float(-0.1), ElecEtotOverPin);
479  Var_wGwGSF_Endcap_[1] = std::log(std::max(float(0.01), ElecChi2NormGSF));
480  Var_wGwGSF_Endcap_[2] = ElecGSFNumHits;
481  Var_wGwGSF_Endcap_[3] = std::log(std::max(float(0.01), ElecGSFTrackResol));
482  Var_wGwGSF_Endcap_[4] = ElecGSFTracklnPt;
483  Var_wGwGSF_Endcap_[5] = ElecNumHitsDiffOverSum;
484  Var_wGwGSF_Endcap_[6] = std::log(std::max(float(0.01), ElecChi2NormKF));
485  Var_wGwGSF_Endcap_[7] = std::min(ElecDeltaPinPoutOverPin, float(1.));
486  Var_wGwGSF_Endcap_[8] = std::min(ElecEecalOverPout, float(20.));
487  Var_wGwGSF_Endcap_[9] = ElecDeltaEta;
488  Var_wGwGSF_Endcap_[10] = ElecDeltaPhi;
489  Var_wGwGSF_Endcap_[11] = std::min(ElecMvaInSigmaEtaEta, float(0.01));
490  Var_wGwGSF_Endcap_[12] = std::min(ElecMvaInHadEnergy, float(20.));
491  Var_wGwGSF_Endcap_[13] = std::min(ElecMvaInDeltaEta, float(0.1));
492  Var_wGwGSF_Endcap_[14] = TauEtaAtEcalEntrance;
493  Var_wGwGSF_Endcap_[15] = TauLeadChargedPFCandEtaAtEcalEntrance;
494  Var_wGwGSF_Endcap_[16] = std::min(float(2.), TauLeadChargedPFCandPt / std::max(float(1.), TauPt));
495  Var_wGwGSF_Endcap_[17] = std::log(std::max(float(1.), TauPt));
496  Var_wGwGSF_Endcap_[18] = TauEmFraction;
497  Var_wGwGSF_Endcap_[19] = TauSignalPFGammaCandsIn;
498  Var_wGwGSF_Endcap_[20] = TauSignalPFGammaCandsOut;
499  Var_wGwGSF_Endcap_[21] = TauLeadPFChargedHadrHoP;
500  Var_wGwGSF_Endcap_[22] = TauLeadPFChargedHadrEoP;
501  Var_wGwGSF_Endcap_[23] = TauVisMassIn;
502  Var_wGwGSF_Endcap_[24] = TauGammaEtaMomIn;
503  Var_wGwGSF_Endcap_[25] = TauGammaEtaMomOut;
504  Var_wGwGSF_Endcap_[26] = TauGammaPhiMomIn;
505  Var_wGwGSF_Endcap_[27] = TauGammaPhiMomOut;
506  Var_wGwGSF_Endcap_[28] = TauGammaEnFracIn;
507  Var_wGwGSF_Endcap_[29] = TauGammaEnFracOut;
508  Var_wGwGSF_Endcap_[30] = TaudCrackEta;
510  }
511  }
512  return mvaValue;
513 }
514 
515 double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau, const reco::GsfElectron& theGsfEle)
516 
517 {
518  // === tau variables ===
519  float TauEtaAtEcalEntrance = -99.;
520  float sumEtaTimesEnergy = 0.;
521  float sumEnergy = 0.;
522  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
523  for (const auto& pfCandidate : signalPFCands) {
524  sumEtaTimesEnergy += pfCandidate->positionAtECALEntrance().eta() * pfCandidate->energy();
525  sumEnergy += pfCandidate->energy();
526  }
527  if (sumEnergy > 0.) {
528  TauEtaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
529  }
530 
531  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
532  float TauLeadChargedPFCandPt = -99.;
533  for (const auto& pfCandidate : signalPFCands) {
534  const reco::Track* track = nullptr;
535  if (pfCandidate->trackRef().isNonnull())
536  track = pfCandidate->trackRef().get();
537  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
538  track = pfCandidate->muonRef()->innerTrack().get();
539  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
540  track = pfCandidate->muonRef()->globalTrack().get();
541  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
542  track = pfCandidate->muonRef()->outerTrack().get();
543  else if (pfCandidate->gsfTrackRef().isNonnull())
544  track = pfCandidate->gsfTrackRef().get();
545  if (track) {
546  if (track->pt() > TauLeadChargedPFCandPt) {
547  TauLeadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta();
548  TauLeadChargedPFCandPt = track->pt();
549  }
550  }
551  }
552 
553  Float_t TauPt = thePFTau.pt();
554  Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.);
555  Float_t TauLeadPFChargedHadrHoP = 0.;
556  Float_t TauLeadPFChargedHadrEoP = 0.;
557  if (thePFTau.leadPFChargedHadrCand()->p() > 0.) {
558  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
559  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
560  }
561 
562  std::vector<Float_t> GammasdEtaInSigCone;
563  std::vector<Float_t> GammasdPhiInSigCone;
564  std::vector<Float_t> GammasPtInSigCone;
565  std::vector<Float_t> GammasdEtaOutSigCone;
566  std::vector<Float_t> GammasdPhiOutSigCone;
567  std::vector<Float_t> GammasPtOutSigCone;
568  reco::Candidate::LorentzVector pfGammaSum(0, 0, 0, 0);
569  reco::Candidate::LorentzVector pfChargedSum(0, 0, 0, 0);
570 
571  for (const auto& gamma : thePFTau.signalGammaCands()) {
572  float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4());
573  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, thePFTau.pt())));
574 
575  // pfGammas inside the tau signal cone
576  if (dR < signalrad) {
577  if (thePFTau.leadChargedHadrCand().isNonnull()) {
578  GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
579  GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
580  } else {
581  GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.eta());
582  GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.phi());
583  }
584  GammasPtInSigCone.push_back(gamma->pt());
585  pfGammaSum += gamma->p4();
586  }
587  // pfGammas outside the tau signal cone
588  else {
589  if (thePFTau.leadChargedHadrCand().isNonnull()) {
590  GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
591  GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
592  } else {
593  GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.eta());
594  GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.phi());
595  }
596  GammasPtOutSigCone.push_back(gamma->pt());
597  }
598  }
599 
600  for (const auto& charged : thePFTau.signalChargedHadrCands()) {
601  float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4());
602  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, thePFTau.pt())));
603 
604  // charged particles inside the tau signal cone
605  if (dR < signalrad) {
606  pfChargedSum += charged->p4();
607  }
608  }
609 
610  Int_t TauSignalPFGammaCandsIn = GammasPtInSigCone.size();
611  Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size();
612  Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass();
613 
614  Float_t TauPhi = thePFTau.phi();
615  float sumPhiTimesEnergy = 0.;
616  float sumEnergyPhi = 0.;
618  for (const auto& pfc : signalPFCands) {
619  sumPhiTimesEnergy += pfc->positionAtECALEntrance().phi() * pfc->energy();
620  sumEnergyPhi += pfc->energy();
621  }
622  } else {
623  TauPhi = -99.;
624  for (const auto& signalPFCand : signalPFCands) {
625  reco::Candidate const* signalCand = signalPFCand.get();
626  float phi = thePFTau.phi();
627  math::XYZPoint aPos;
628  if (atECalEntrance(signalCand, aPos))
629  phi = aPos.Phi();
630  sumPhiTimesEnergy += phi * signalCand->energy();
631  sumEnergy += signalCand->energy();
632  }
633  }
634  if (sumEnergyPhi > 0.) {
635  TauPhi = sumPhiTimesEnergy / sumEnergyPhi;
636  }
637  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
638  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
639  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
640 
641  // === electron variables ===
642  Float_t ElecEta = theGsfEle.eta();
643  Float_t ElecPhi = theGsfEle.phi();
644 
645  //Variables related to the electron Cluster
646  Float_t ElecEe = 0.;
647  Float_t ElecEgamma = 0.;
648  reco::SuperClusterRef pfSuperCluster = theGsfEle.superCluster();
649  if (pfSuperCluster.isNonnull() && pfSuperCluster.isAvailable()) {
650  for (reco::CaloCluster_iterator pfCluster = pfSuperCluster->clustersBegin();
651  pfCluster != pfSuperCluster->clustersEnd();
652  ++pfCluster) {
653  double pfClusterEn = (*pfCluster)->energy();
654  if (pfCluster == pfSuperCluster->clustersBegin())
655  ElecEe += pfClusterEn;
656  else
657  ElecEgamma += pfClusterEn;
658  }
659  }
660 
661  Float_t ElecPin = std::sqrt(theGsfEle.trackMomentumAtVtx().Mag2());
662  Float_t ElecPout = std::sqrt(theGsfEle.trackMomentumOut().Mag2());
663  Float_t ElecEtotOverPin = (ElecPin > 0.0) ? ((ElecEe + ElecEgamma) / ElecPin) : -0.1;
664  Float_t ElecEecal = theGsfEle.ecalEnergy();
665  Float_t ElecDeltaEta = theGsfEle.deltaEtaSeedClusterTrackAtCalo();
666  Float_t ElecDeltaPhi = theGsfEle.deltaPhiSeedClusterTrackAtCalo();
667  Float_t ElecMvaInSigmaEtaEta = (theGsfEle).mvaInput().sigmaEtaEta;
668  Float_t ElecMvaInHadEnergy = (theGsfEle).mvaInput().hadEnergy;
669  Float_t ElecMvaInDeltaEta = (theGsfEle).mvaInput().deltaEta;
670 
671  //Variables related to the GsfTrack
672  Float_t ElecChi2NormGSF = -99.;
673  Float_t ElecGSFNumHits = -99.;
674  Float_t ElecGSFTrackResol = -99.;
675  Float_t ElecGSFTracklnPt = -99.;
676  if (theGsfEle.gsfTrack().isNonnull()) {
677  ElecChi2NormGSF = (theGsfEle).gsfTrack()->normalizedChi2();
678  ElecGSFNumHits = (theGsfEle).gsfTrack()->numberOfValidHits();
679  if (theGsfEle.gsfTrack()->pt() > 0.) {
680  ElecGSFTrackResol = theGsfEle.gsfTrack()->ptError() / theGsfEle.gsfTrack()->pt();
681  ElecGSFTracklnPt = log(theGsfEle.gsfTrack()->pt()) * M_LN10;
682  }
683  }
684 
685  //Variables related to the CtfTrack
686  Float_t ElecChi2NormKF = -99.;
687  Float_t ElecKFNumHits = -99.;
688  if (theGsfEle.closestCtfTrackRef().isNonnull()) {
689  ElecChi2NormKF = (theGsfEle).closestCtfTrackRef()->normalizedChi2();
690  ElecKFNumHits = (theGsfEle).closestCtfTrackRef()->numberOfValidHits();
691  }
692 
693  return MVAValue(TauPt,
694  TauEtaAtEcalEntrance,
695  TauPhi,
696  TauLeadChargedPFCandPt,
697  TauLeadChargedPFCandEtaAtEcalEntrance,
698  TauEmFraction,
699  TauLeadPFChargedHadrHoP,
700  TauLeadPFChargedHadrEoP,
701  TauVisMassIn,
702  TaudCrackEta,
703  TaudCrackPhi,
704  TauHasGsf,
705  TauSignalPFGammaCandsIn,
706  TauSignalPFGammaCandsOut,
707  GammasdEtaInSigCone,
708  GammasdPhiInSigCone,
709  GammasPtInSigCone,
710  GammasdEtaOutSigCone,
711  GammasdPhiOutSigCone,
712  GammasPtOutSigCone,
713  ElecEta,
714  ElecPhi,
715  ElecEtotOverPin,
716  ElecChi2NormGSF,
717  ElecChi2NormKF,
718  ElecGSFNumHits,
719  ElecKFNumHits,
720  ElecGSFTrackResol,
721  ElecGSFTracklnPt,
722  ElecPin,
723  ElecPout,
724  ElecEecal,
725  ElecDeltaEta,
726  ElecDeltaPhi,
727  ElecMvaInSigmaEtaEta,
728  ElecMvaInHadEnergy,
729  ElecMvaInDeltaEta);
730 }
731 
732 double AntiElectronIDMVA6::MVAValue(const reco::PFTau& thePFTau) {
733  // === tau variables ===
734  float TauEtaAtEcalEntrance = -99.;
735  float sumEtaTimesEnergy = 0.;
736  float sumEnergy = 0.;
737  const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTau.signalPFCands();
738  for (const auto& pfCandidate : signalPFCands) {
739  sumEtaTimesEnergy += pfCandidate->positionAtECALEntrance().eta() * pfCandidate->energy();
740  sumEnergy += pfCandidate->energy();
741  }
742  if (sumEnergy > 0.) {
743  TauEtaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
744  }
745 
746  float TauLeadChargedPFCandEtaAtEcalEntrance = -99.;
747  float TauLeadChargedPFCandPt = -99.;
748  for (const auto& pfCandidate : signalPFCands) {
749  const reco::Track* track = nullptr;
750  if (pfCandidate->trackRef().isNonnull())
751  track = pfCandidate->trackRef().get();
752  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
753  track = pfCandidate->muonRef()->innerTrack().get();
754  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
755  track = pfCandidate->muonRef()->globalTrack().get();
756  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
757  track = pfCandidate->muonRef()->outerTrack().get();
758  else if (pfCandidate->gsfTrackRef().isNonnull())
759  track = pfCandidate->gsfTrackRef().get();
760  if (track) {
761  if (track->pt() > TauLeadChargedPFCandPt) {
762  TauLeadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta();
763  TauLeadChargedPFCandPt = track->pt();
764  }
765  }
766  }
767 
768  Float_t TauPt = thePFTau.pt();
769  Float_t TauEmFraction = std::max(thePFTau.emFraction(), (Float_t)0.);
770  Float_t TauLeadPFChargedHadrHoP = 0.;
771  Float_t TauLeadPFChargedHadrEoP = 0.;
772  if (thePFTau.leadPFChargedHadrCand()->p() > 0.) {
773  TauLeadPFChargedHadrHoP = thePFTau.leadPFChargedHadrCand()->hcalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
774  TauLeadPFChargedHadrEoP = thePFTau.leadPFChargedHadrCand()->ecalEnergy() / thePFTau.leadPFChargedHadrCand()->p();
775  }
776 
777  std::vector<Float_t> GammasdEtaInSigCone;
778  std::vector<Float_t> GammasdPhiInSigCone;
779  std::vector<Float_t> GammasPtInSigCone;
780  std::vector<Float_t> GammasdEtaOutSigCone;
781  std::vector<Float_t> GammasdPhiOutSigCone;
782  std::vector<Float_t> GammasPtOutSigCone;
783  reco::Candidate::LorentzVector pfGammaSum(0, 0, 0, 0);
784  reco::Candidate::LorentzVector pfChargedSum(0, 0, 0, 0);
785 
786  for (const auto& gamma : thePFTau.signalGammaCands()) {
787  float dR = deltaR(gamma->p4(), thePFTau.leadChargedHadrCand()->p4());
788  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, thePFTau.pt())));
789 
790  // pfGammas inside the tau signal cone
791  if (dR < signalrad) {
792  if (thePFTau.leadChargedHadrCand().isNonnull()) {
793  GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
794  GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
795  } else {
796  GammasdEtaInSigCone.push_back(gamma->eta() - thePFTau.eta());
797  GammasdPhiInSigCone.push_back(gamma->phi() - thePFTau.phi());
798  }
799  GammasPtInSigCone.push_back(gamma->pt());
800  pfGammaSum += gamma->p4();
801  }
802  // pfGammas outside the tau signal cone
803  else {
804  if (thePFTau.leadChargedHadrCand().isNonnull()) {
805  GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.leadChargedHadrCand()->eta());
806  GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.leadChargedHadrCand()->phi());
807  } else {
808  GammasdEtaOutSigCone.push_back(gamma->eta() - thePFTau.eta());
809  GammasdPhiOutSigCone.push_back(gamma->phi() - thePFTau.phi());
810  }
811  GammasPtOutSigCone.push_back(gamma->pt());
812  }
813  }
814 
815  for (const auto& charged : thePFTau.signalChargedHadrCands()) {
816  float dR = deltaR(charged->p4(), thePFTau.leadChargedHadrCand()->p4());
817  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, thePFTau.pt())));
818 
819  // charged particles inside the tau signal cone
820  if (dR < signalrad) {
821  pfChargedSum += charged->p4();
822  }
823  }
824 
825  Int_t TauSignalPFGammaCandsIn = GammasPtInSigCone.size();
826  Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size();
827  Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass();
828 
829  Float_t TauPhi = thePFTau.phi();
830  float sumPhiTimesEnergy = 0.;
831  float sumEnergyPhi = 0.;
833  for (const auto& pfCandidate : signalPFCands) {
834  sumPhiTimesEnergy += pfCandidate->positionAtECALEntrance().phi() * pfCandidate->energy();
835  sumEnergyPhi += pfCandidate->energy();
836  }
837  } else {
838  TauPhi = -99.;
839  for (const auto& signalPFCand : signalPFCands) {
840  reco::Candidate const* signalCand = signalPFCand.get();
841  float phi = thePFTau.phi();
842  math::XYZPoint aPos;
843  if (atECalEntrance(signalCand, aPos) == true)
844  phi = aPos.Phi();
845  sumPhiTimesEnergy += phi * signalCand->energy();
846  sumEnergy += signalCand->energy();
847  }
848  }
849  if (sumEnergyPhi > 0.) {
850  TauPhi = sumPhiTimesEnergy / sumEnergyPhi;
851  }
852  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
853  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
854  Float_t TauHasGsf = thePFTau.leadPFChargedHadrCand()->gsfTrackRef().isNonnull();
855 
856  // === electron variables ===
857  Float_t dummyElecEta = 9.9;
858 
859  return MVAValue(TauPt,
860  TauEtaAtEcalEntrance,
861  TauPhi,
862  TauLeadChargedPFCandPt,
863  TauLeadChargedPFCandEtaAtEcalEntrance,
864  TauEmFraction,
865  TauLeadPFChargedHadrHoP,
866  TauLeadPFChargedHadrEoP,
867  TauVisMassIn,
868  TaudCrackEta,
869  TaudCrackPhi,
870  TauHasGsf,
871  TauSignalPFGammaCandsIn,
872  TauSignalPFGammaCandsOut,
873  GammasdEtaInSigCone,
874  GammasdPhiInSigCone,
875  GammasPtInSigCone,
876  GammasdEtaOutSigCone,
877  GammasdPhiOutSigCone,
878  GammasPtOutSigCone,
879  dummyElecEta,
880  0.,
881  0.,
882  0.,
883  0.,
884  0.,
885  0.,
886  0.,
887  0.,
888  0.,
889  0.,
890  0.,
891  0.,
892  0.,
893  0.,
894  0.,
895  0.);
896 }
897 
898 double AntiElectronIDMVA6::MVAValue(const pat::Tau& theTau, const pat::Electron& theEle) {
899  // === tau variables ===
900  float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance();
901 
902  float TauLeadChargedPFCandEtaAtEcalEntrance = theTau.etaAtEcalEntranceLeadChargedCand();
903  float TauLeadChargedPFCandPt = theTau.ptLeadChargedCand();
904 
905  Float_t TauPt = theTau.pt();
906  //Float_t TauEmFraction = std::max(theTau.ecalEnergy()/(theTau.ecalEnergy()+theTau.hcalEnergy()), (Float_t)0.);
907  Float_t TauEmFraction = std::max(theTau.emFraction_MVA(), (Float_t)0.);
908  Float_t TauLeadPFChargedHadrHoP = 0.;
909  Float_t TauLeadPFChargedHadrEoP = 0.;
910  if (theTau.leadChargedHadrCand()->p() > 0.) {
911  TauLeadPFChargedHadrHoP = theTau.hcalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
912  TauLeadPFChargedHadrEoP = theTau.ecalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
913  }
914 
915  std::vector<Float_t> GammasdEtaInSigCone;
916  std::vector<Float_t> GammasdPhiInSigCone;
917  std::vector<Float_t> GammasPtInSigCone;
918  std::vector<Float_t> GammasdEtaOutSigCone;
919  std::vector<Float_t> GammasdPhiOutSigCone;
920  std::vector<Float_t> GammasPtOutSigCone;
921  reco::Candidate::LorentzVector pfGammaSum(0, 0, 0, 0);
922  reco::Candidate::LorentzVector pfChargedSum(0, 0, 0, 0);
923 
924  const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands();
925  for (const auto& gamma : signalGammaCands) {
926  float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4());
927  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTau.pt())));
928 
929  // pfGammas inside the tau signal cone
930  if (dR < signalrad) {
931  if (theTau.leadChargedHadrCand().isNonnull()) {
932  GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
933  GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
934  //A.-C. please check whether this change is safe against future trainings
935  //GammasdPhiInSigCone.push_back(deltaPhi((*gamma)->phi(), theTau.leadChargedHadrCand()->phi()));
936  } else {
937  GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta());
938  GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi());
939  //A.-C. please check whether this change is safe against future trainings
940  //GammasdPhiInSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi()));
941  }
942  GammasPtInSigCone.push_back(gamma->pt());
943  pfGammaSum += gamma->p4();
944  }
945  // pfGammas outside the tau signal cone
946  else {
947  if (theTau.leadChargedHadrCand().isNonnull()) {
948  GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
949  GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
950  //A.-C. please check whether this change is safe against future trainings
951  //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.leadChargedHadrCand()->phi()));
952  } else {
953  GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta());
954  GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi());
955  //A.-C. please chaekc whether this change is safe against future trainings
956  //GammasdPhiOutSigCone.push_back(deltaPhi(gamma->phi(), theTau.phi()));
957  }
958  GammasPtOutSigCone.push_back(gamma->pt());
959  }
960  }
961 
962  const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands();
963  for (const auto& charged : signalChargedCands) {
964  float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4());
965  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTau.pt())));
966 
967  // charged particles inside the tau signal cone
968  if (dR < signalrad) {
969  pfChargedSum += charged->p4();
970  }
971  }
972 
973  Int_t TauSignalPFGammaCandsIn = GammasPtInSigCone.size();
974  Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size();
975  Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass();
976  Float_t TauPhi = -99.;
978  float sumPhiTimesEnergy = 0.;
979  float sumEnergy = 0.;
980  const reco::CandidatePtrVector signalCands = theTau.signalCands();
981  for (const auto& signalCandPtr : signalCands) {
982  reco::Candidate const* signalCand = signalCandPtr.get();
983  float phi = theTau.phi();
984  math::XYZPoint aPos;
985  if (atECalEntrance(signalCand, aPos) == true)
986  phi = aPos.Phi();
987  sumPhiTimesEnergy += phi * signalCand->energy();
988  sumEnergy += signalCand->energy();
989  }
990  if (sumEnergy > 0.) {
991  TauPhi = sumPhiTimesEnergy / sumEnergy;
992  }
993  } else {
994  TauPhi = theTau.phiAtEcalEntrance();
995  }
996 
997  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
998  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
999 
1000  Float_t TauHasGsf = 0;
1001  pat::PackedCandidate const* packedLeadTauCand =
1002  dynamic_cast<pat::PackedCandidate const*>(theTau.leadChargedHadrCand().get());
1003  if (abs(packedLeadTauCand->pdgId()) == 11)
1004  TauHasGsf = 1;
1005 
1006  // === electron variables ===
1007  Float_t ElecEta = theEle.eta();
1008  Float_t ElecPhi = theEle.phi();
1009 
1010  //Variables related to the electron Cluster
1011  Float_t ElecEe = 0.;
1012  Float_t ElecEgamma = 0.;
1013  reco::SuperClusterRef pfSuperCluster = theEle.superCluster();
1014  if (pfSuperCluster.isNonnull() && pfSuperCluster.isAvailable()) {
1015  for (reco::CaloCluster_iterator pfCluster = pfSuperCluster->clustersBegin();
1016  pfCluster != pfSuperCluster->clustersEnd();
1017  ++pfCluster) {
1018  double pfClusterEn = (*pfCluster)->energy();
1019  if (pfCluster == pfSuperCluster->clustersBegin())
1020  ElecEe += pfClusterEn;
1021  else
1022  ElecEgamma += pfClusterEn;
1023  }
1024  }
1025 
1026  Float_t ElecPin = std::sqrt(theEle.trackMomentumAtVtx().Mag2());
1027  Float_t ElecPout = std::sqrt(theEle.trackMomentumOut().Mag2());
1028  Float_t ElecEtotOverPin = (ElecPin > 0.0) ? ((ElecEe + ElecEgamma) / ElecPin) : -0.1;
1029  Float_t ElecEecal = theEle.ecalEnergy();
1030  Float_t ElecDeltaEta = theEle.deltaEtaSeedClusterTrackAtCalo();
1031  Float_t ElecDeltaPhi = theEle.deltaPhiSeedClusterTrackAtCalo();
1032  Float_t ElecMvaInSigmaEtaEta = (theEle).mvaInput().sigmaEtaEta;
1033  Float_t ElecMvaInHadEnergy = (theEle).mvaInput().hadEnergy;
1034  Float_t ElecMvaInDeltaEta = (theEle).mvaInput().deltaEta;
1035 
1036  //Variables related to the GsfTrack
1037  Float_t ElecChi2NormGSF = -99.;
1038  Float_t ElecGSFNumHits = -99.;
1039  Float_t ElecGSFTrackResol = -99.;
1040  Float_t ElecGSFTracklnPt = -99.;
1041  if (theEle.gsfTrack().isNonnull()) {
1042  ElecChi2NormGSF = (theEle).gsfTrack()->normalizedChi2();
1043  ElecGSFNumHits = (theEle).gsfTrack()->numberOfValidHits();
1044  if (theEle.gsfTrack()->pt() > 0.) {
1045  ElecGSFTrackResol = theEle.gsfTrack()->ptError() / theEle.gsfTrack()->pt();
1046  ElecGSFTracklnPt = log(theEle.gsfTrack()->pt()) * M_LN10;
1047  }
1048  }
1049 
1050  //Variables related to the CtfTrack
1051  Float_t ElecChi2NormKF = -99.;
1052  Float_t ElecKFNumHits = -99.;
1053  if (theEle.closestCtfTrackRef().isNonnull()) {
1054  ElecChi2NormKF = (theEle).closestCtfTrackRef()->normalizedChi2();
1055  ElecKFNumHits = (theEle).closestCtfTrackRef()->numberOfValidHits();
1056  }
1057 
1058  return MVAValue(TauPt,
1059  TauEtaAtEcalEntrance,
1060  TauPhi,
1061  TauLeadChargedPFCandPt,
1062  TauLeadChargedPFCandEtaAtEcalEntrance,
1063  TauEmFraction,
1064  TauLeadPFChargedHadrHoP,
1065  TauLeadPFChargedHadrEoP,
1066  TauVisMassIn,
1067  TaudCrackEta,
1068  TaudCrackPhi,
1069  TauHasGsf,
1070  TauSignalPFGammaCandsIn,
1071  TauSignalPFGammaCandsOut,
1072  GammasdEtaInSigCone,
1073  GammasdPhiInSigCone,
1074  GammasPtInSigCone,
1075  GammasdEtaOutSigCone,
1076  GammasdPhiOutSigCone,
1077  GammasPtOutSigCone,
1078  ElecEta,
1079  ElecPhi,
1080  ElecEtotOverPin,
1081  ElecChi2NormGSF,
1082  ElecChi2NormKF,
1083  ElecGSFNumHits,
1084  ElecKFNumHits,
1085  ElecGSFTrackResol,
1086  ElecGSFTracklnPt,
1087  ElecPin,
1088  ElecPout,
1089  ElecEecal,
1090  ElecDeltaEta,
1091  ElecDeltaPhi,
1092  ElecMvaInSigmaEtaEta,
1093  ElecMvaInHadEnergy,
1094  ElecMvaInDeltaEta);
1095 }
1096 
1098  // === tau variables ===
1099  float TauEtaAtEcalEntrance = theTau.etaAtEcalEntrance();
1100 
1101  float TauLeadChargedPFCandEtaAtEcalEntrance = theTau.etaAtEcalEntranceLeadChargedCand();
1102  float TauLeadChargedPFCandPt = theTau.ptLeadChargedCand();
1103 
1104  Float_t TauPt = theTau.pt();
1105  //Float_t TauEmFraction = std::max(theTau.ecalEnergy()/(theTau.ecalEnergy()+theTau.hcalEnergy()), (Float_t)0.);
1106  Float_t TauEmFraction = std::max(theTau.emFraction_MVA(), (Float_t)0.);
1107  Float_t TauLeadPFChargedHadrHoP = 0.;
1108  Float_t TauLeadPFChargedHadrEoP = 0.;
1109  if (theTau.leadChargedHadrCand()->p() > 0.) {
1110  TauLeadPFChargedHadrHoP = theTau.hcalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
1111  TauLeadPFChargedHadrEoP = theTau.ecalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
1112  }
1113 
1114  std::vector<Float_t> GammasdEtaInSigCone;
1115  std::vector<Float_t> GammasdPhiInSigCone;
1116  std::vector<Float_t> GammasPtInSigCone;
1117  std::vector<Float_t> GammasdEtaOutSigCone;
1118  std::vector<Float_t> GammasdPhiOutSigCone;
1119  std::vector<Float_t> GammasPtOutSigCone;
1120  reco::Candidate::LorentzVector pfGammaSum(0, 0, 0, 0);
1121  reco::Candidate::LorentzVector pfChargedSum(0, 0, 0, 0);
1122 
1123  const reco::CandidatePtrVector signalGammaCands = theTau.signalGammaCands();
1124  for (const auto& gamma : signalGammaCands) {
1125  float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4());
1126  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTau.pt())));
1127 
1128  // pfGammas inside the tau signal cone
1129  if (dR < signalrad) {
1130  if (theTau.leadChargedHadrCand().isNonnull()) {
1131  GammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
1132  GammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
1133  } else {
1134  GammasdEtaInSigCone.push_back(gamma->eta() - theTau.eta());
1135  GammasdPhiInSigCone.push_back(gamma->phi() - theTau.phi());
1136  }
1137  GammasPtInSigCone.push_back(gamma->pt());
1138  pfGammaSum += gamma->p4();
1139  }
1140  // pfGammas outside the tau signal cone
1141  else {
1142  if (theTau.leadChargedHadrCand().isNonnull()) {
1143  GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
1144  GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
1145  } else {
1146  GammasdEtaOutSigCone.push_back(gamma->eta() - theTau.eta());
1147  GammasdPhiOutSigCone.push_back(gamma->phi() - theTau.phi());
1148  }
1149  GammasPtOutSigCone.push_back(gamma->pt());
1150  }
1151  }
1152 
1153  const reco::CandidatePtrVector signalChargedCands = theTau.signalChargedHadrCands();
1154  for (const auto& charged : signalChargedCands) {
1155  float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4());
1156  float signalrad = std::max(0.05, std::min(0.10, 3.0 / std::max(1.0, theTau.pt())));
1157 
1158  // charged particles inside the tau signal cone
1159  if (dR < signalrad) {
1160  pfChargedSum += charged->p4();
1161  }
1162  }
1163 
1164  Int_t TauSignalPFGammaCandsIn = GammasPtInSigCone.size();
1165  Int_t TauSignalPFGammaCandsOut = GammasPtOutSigCone.size();
1166  Float_t TauVisMassIn = (pfGammaSum + pfChargedSum).mass();
1167  Float_t TauPhi = -99.;
1169  float sumPhiTimesEnergy = 0.;
1170  float sumEnergy = 0.;
1171  const reco::CandidatePtrVector signalCands = theTau.signalCands();
1172  for (const auto& signalCandPtr : signalCands) {
1173  reco::Candidate const* signalCand = signalCandPtr.get();
1174  float phi = theTau.phi();
1175  math::XYZPoint aPos;
1176  if (atECalEntrance(signalCand, aPos) == true)
1177  phi = aPos.Phi();
1178  sumPhiTimesEnergy += phi * signalCand->energy();
1179  sumEnergy += signalCand->energy();
1180  }
1181  if (sumEnergy > 0.) {
1182  TauPhi = sumPhiTimesEnergy / sumEnergy;
1183  }
1184  } else {
1185  TauPhi = theTau.phiAtEcalEntrance();
1186  }
1187 
1188  Float_t TaudCrackPhi = dCrackPhi(TauPhi, TauEtaAtEcalEntrance);
1189  Float_t TaudCrackEta = dCrackEta(TauEtaAtEcalEntrance);
1190 
1191  Float_t TauHasGsf = 0;
1192  pat::PackedCandidate const* packedLeadTauCand =
1193  dynamic_cast<pat::PackedCandidate const*>(theTau.leadChargedHadrCand().get());
1194  //const reco::Track & pseudoTrack = packedLeadTauCand->pseudoTrack();
1195  if (abs(packedLeadTauCand->pdgId()) == 11)
1196  TauHasGsf = 1;
1197 
1198  // === electron variables ===
1199  Float_t dummyElecEta = 9.9;
1200 
1201  return MVAValue(TauPt,
1202  TauEtaAtEcalEntrance,
1203  TauPhi,
1204  TauLeadChargedPFCandPt,
1205  TauLeadChargedPFCandEtaAtEcalEntrance,
1206  TauEmFraction,
1207  TauLeadPFChargedHadrHoP,
1208  TauLeadPFChargedHadrEoP,
1209  TauVisMassIn,
1210  TaudCrackEta,
1211  TaudCrackPhi,
1212  TauHasGsf,
1213  TauSignalPFGammaCandsIn,
1214  TauSignalPFGammaCandsOut,
1215  GammasdEtaInSigCone,
1216  GammasdPhiInSigCone,
1217  GammasPtInSigCone,
1218  GammasdEtaOutSigCone,
1219  GammasdPhiOutSigCone,
1220  GammasPtOutSigCone,
1221  dummyElecEta,
1222  0.,
1223  0.,
1224  0.,
1225  0.,
1226  0.,
1227  0.,
1228  0.,
1229  0.,
1230  0.,
1231  0.,
1232  0.,
1233  0.,
1234  0.,
1235  0.,
1236  0.,
1237  0.);
1238 }
1239 
1240 double AntiElectronIDMVA6::minimum(double a, double b) {
1241  if (std::abs(b) < std::abs(a))
1242  return b;
1243  else
1244  return a;
1245 }
1246 
1247 namespace {
1248 
1249  // IN: define locations of the 18 phi-cracks
1250  std::array<double, 18> fill_cPhi() {
1251  constexpr double pi = M_PI; // 3.14159265358979323846;
1252  std::array<double, 18> cPhi;
1253  // IN: define locations of the 18 phi-cracks
1254  cPhi[0] = 2.97025;
1255  for (unsigned iCrack = 1; iCrack <= 17; ++iCrack) {
1256  cPhi[iCrack] = cPhi[0] - 2. * iCrack * pi / 18;
1257  }
1258  return cPhi;
1259  }
1260 
1261  const std::array<double, 18> cPhi = fill_cPhi();
1262 
1263 } // namespace
1264 
1265 double AntiElectronIDMVA6::dCrackPhi(double phi, double eta) {
1266  //--- compute the (unsigned) distance to the closest phi-crack in the ECAL barrel
1267 
1268  constexpr double pi = M_PI; // 3.14159265358979323846;
1269 
1270  // IN: shift of this location if eta < 0
1271  constexpr double delta_cPhi = 0.00638;
1272 
1273  double retVal = 99.;
1274 
1275  if (eta >= -1.47464 && eta <= 1.47464) {
1276  // the location is shifted
1277  if (eta < 0.)
1278  phi += delta_cPhi;
1279 
1280  // CV: need to bring-back phi into interval [-pi,+pi]
1281  if (phi > pi)
1282  phi -= 2. * pi;
1283  if (phi < -pi)
1284  phi += 2. * pi;
1285 
1286  if (phi >= -pi && phi <= pi) {
1287  // the problem of the extrema:
1288  if (phi < cPhi[17] || phi >= cPhi[0]) {
1289  if (phi < 0.)
1290  phi += 2. * pi;
1291  retVal = minimum(phi - cPhi[0], phi - cPhi[17] - 2. * pi);
1292  } else {
1293  // between these extrema...
1294  bool OK = false;
1295  unsigned iCrack = 16;
1296  while (!OK) {
1297  if (phi < cPhi[iCrack]) {
1298  retVal = minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
1299  OK = true;
1300  } else {
1301  iCrack -= 1;
1302  }
1303  }
1304  }
1305  } else {
1306  retVal = 0.; // IN: if there is a problem, we assume that we are in a crack
1307  }
1308  } else {
1309  return -99.;
1310  }
1311 
1312  return std::abs(retVal);
1313 }
1314 
1316  //--- compute the (unsigned) distance to the closest eta-crack in the ECAL barrel
1317 
1318  // IN: define locations of the eta-cracks
1319  double cracks[5] = {0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00};
1320 
1321  double retVal = 99.;
1322 
1323  for (int iCrack = 0; iCrack < 5; ++iCrack) {
1324  double d = minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
1325  if (std::abs(d) < std::abs(retVal)) {
1326  retVal = d;
1327  }
1328  }
1329 
1330  return std::abs(retVal);
1331 }
1332 
1334  bool result = false;
1336  RawParticle(math::XYZTLorentzVector(part->px(), part->py(), part->pz(), part->energy()),
1337  math::XYZTLorentzVector(part->vertex().x(), part->vertex().y(), part->vertex().z(), 0.),
1338  part->charge()),
1339  0.,
1340  0.,
1341  bField_);
1342  theParticle.propagateToEcalEntrance(false);
1343  if (theParticle.getSuccess() != 0) {
1344  pos = math::XYZPoint(theParticle.particle().vertex());
1345  result = true;
1346  } else {
1347  result = false;
1348  }
1349  return result;
1350 }
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
double minimum(double a, double b)
std::string mvaName_woGwGSF_BL_
virtual double pz() const =0
z coordinate of momentum vector
std::string mvaName_NoEleMatch_woGwoGSF_BL_
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool atECalEntrance(const reco::Candidate *part, math::XYZPoint &pos)
double eta() const final
momentum pseudorapidity
int pdgId() const override
PDG identifier.
std::string mvaName_NoEleMatch_woGwoGSF_EC_
float hcalEnergyLeadChargedHadrCand() const
return hcal energy from LeadChargedHadrCand
Definition: Tau.h:308
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
edm::FileInPath inputFileName_
AntiElectronIDMVA6(const edm::ParameterSet &)
const GBRForest * mva_wGwGSF_EC_
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
#define nullptr
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool exists(std::string const &parameterName) const
checks if a parameter exists
Float_t * Var_NoEleMatch_wGwoGSF_Barrel_
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
double dCrackPhi(double phi, double eta)
double pt() const final
transverse momentum
float emFraction() const
Definition: PFTau.cc:339
const std::vector< reco::CandidatePtr > & signalGammaCands() const
Gamma candidates in signal region.
Definition: PFTau.cc:83
const GBRForest * mva_NoEleMatch_woGwoGSF_EC_
reco::CandidatePtrVector signalCands() const
std::string mvaName_NoEleMatch_wGwoGSF_EC_
RawParticle const & particle() const
The particle being propagated.
void beginEvent(const edm::Event &, const edm::EventSetup &)
const GBRForest * mva_NoEleMatch_wGwoGSF_BL_
reco::CandidatePtrVector signalGammaCands() const
bool isAvailable() const
Definition: Ref.h:537
Float_t * Var_NoEleMatch_woGwoGSF_Endcap_
const Double_t pi
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::vector< TFile * > inputFilesToDelete_
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
const GBRForest * mva_woGwGSF_EC_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
float deltaPhiSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:229
const CandidatePtr & leadChargedHadrCand() const
Definition: PFTau.cc:62
T sqrt(T t)
Definition: SSEVec.h:19
math::XYZVectorF trackMomentumOut() const
Definition: GsfElectron.h:270
double pt() const
track transverse momentum
Definition: TrackBase.h:602
T z() const
Definition: PV3DBase.h:61
float ecalEnergyLeadChargedHadrCand() const
Definition: Tau.h:306
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
Definition: PFTau.cc:182
T min(T a, T b)
Definition: MathUtil.h:58
float phiAtEcalEntrance() const
return phiAtEcalEntrance
Definition: Tau.h:310
const reco::CandidatePtr leadChargedHadrCand() const
LocationCode location() const
Where was the file found?
Definition: FileInPath.cc:161
Analysis-level tau class.
Definition: Tau.h:53
std::string mvaName_wGwGSF_EC_
d
Definition: ztail.py:151
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool propagateToEcalEntrance(bool first=true)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
#define M_PI
float ptLeadChargedCand() const
return pt from LeadChargedCand
Definition: Tau.h:316
const XYZTLorentzVector & vertex() const
the vertex fourvector
Definition: RawParticle.h:320
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:126
double MVAValue(Float_t TauPt, Float_t TauEtaAtEcalEntrance, Float_t TauPhi, Float_t TauLeadChargedPFCandPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauEmFraction, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMassIn, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauHasGsf, Int_t TauSignalPFGammaCandsIn, Int_t TauSignalPFGammaCandsOut, const std::vector< Float_t > &GammasdEtaInSigCone, const std::vector< Float_t > &GammasdPhiInSigCone, const std::vector< Float_t > &GammasPtInSigCone, const std::vector< Float_t > &GammasdEtaOutSigCone, const std::vector< Float_t > &GammasdPhiOutSigCone, const std::vector< Float_t > &GammasPtOutSigCone, Float_t ElecEta, Float_t ElecPhi, Float_t ElecEtotOverPin, Float_t ElecChi2NormGSF, Float_t ElecChi2NormKF, Float_t ElecGSFNumHits, Float_t ElecKFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecPin, Float_t ElecPout, Float_t ElecEecal, Float_t ElecDeltaEta, Float_t ElecDeltaPhi, Float_t ElecMvaInSigmaEtaEta, Float_t ElecMvaInHadEnergy, Float_t ElecMvaInDeltaEta)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
part
Definition: HCALResponse.h:20
Float_t * Var_NoEleMatch_wGwoGSF_Endcap_
double b
Definition: hdecay.h:118
Analysis-level electron class.
Definition: Electron.h:51
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
const GBRForest * mva_wGwGSF_BL_
const GBRForest * mva_woGwGSF_BL_
float ecalEnergy() const
Definition: GsfElectron.h:812
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:75
float emFraction_MVA() const
return emFraction_MVA
Definition: Tau.h:318
virtual int charge() const =0
electric charge
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
const GBRForest * mva_NoEleMatch_wGwoGSF_EC_
double a
Definition: hdecay.h:119
T get() const
Definition: EventSetup.h:73
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
T get() const
get a component
Definition: Candidate.h:222
std::string mvaName_wGwGSF_BL_
std::string mvaName_NoEleMatch_wGwoGSF_BL_
std::string fullPath() const
Definition: FileInPath.cc:163
virtual const Point & vertex() const =0
vertex position
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
reco::CandidatePtrVector signalChargedHadrCands() const
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
Definition: PFTau.cc:164
virtual double px() const =0
x coordinate of momentum vector
float etaAtEcalEntrance() const
return etaAtEcalEntrance
Definition: Tau.h:312
float etaAtEcalEntranceLeadChargedCand() const
return etaAtEcalEntrance from LeadChargedCand
Definition: Tau.h:314
double dCrackEta(double eta)
const GBRForest * mva_NoEleMatch_woGwoGSF_BL_
double GetClassifier(const float *vector) const
Definition: GBRForest.h:34
double phi() const final
momentum azimuthal angle
T const * product() const
Definition: ESHandle.h:86
std::string mvaName_woGwGSF_EC_
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
#define constexpr
Float_t * Var_NoEleMatch_woGwoGSF_Barrel_