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