CMS 3D CMS Logo

EGammaMvaEleEstimator.cc
Go to the documentation of this file.
1 #include <TFile.h>
3 #include <cmath>
4 #include <vector>
5 
6 #ifndef STANDALONE
23 #include <cstdio>
24 #include <zlib.h>
25 #endif
26 
27 //--------------------------------------------------------------------------------------------------
29 fMethodname("BDTG method"),
30 fisInitialized(kFALSE),
31 fMVAType(kTrig),
32 fUseBinnedVersion(kTRUE),
33 fNMVABins(0)
34 {
35  // Constructor.
36 }
37 
38 //--------------------------------------------------------------------------------------------------
40 {
41  for (unsigned int i=0;i<fTMVAReader.size(); ++i) {
42  if (fTMVAReader[i]) delete fTMVAReader[i];
43  }
44 }
45 
46 //--------------------------------------------------------------------------------------------------
48  std::string weightsfile,
50 {
51 
52  std::vector<std::string> tempWeightFileVector;
53  tempWeightFileVector.push_back(weightsfile);
54  initialize(methodName,type,kFALSE,tempWeightFileVector);
55 }
56 
57 
58 //--------------------------------------------------------------------------------------------------
61  Bool_t useBinnedVersion,
62  std::vector<std::string> weightsfiles
63  ) {
64 
65  //clean up first
66  for (unsigned int i=0;i<fTMVAReader.size(); ++i) {
67  if (fTMVAReader[i]) delete fTMVAReader[i];
68  }
69  fTMVAReader.clear();
70  fTMVAMethod.clear();
71 
72  //initialize
73  fisInitialized = kTRUE;
74  fMVAType = type;
75  fMethodname = methodName;
76  fUseBinnedVersion = useBinnedVersion;
77 
78  //Define expected number of bins
79  UInt_t ExpectedNBins = 0;
80  if (!fUseBinnedVersion) {
81  ExpectedNBins = 1;
82  } else if (type == kTrig) {
83  ExpectedNBins = 6;
84  }else if (type == kTrigNoIP) {
85  ExpectedNBins = 6;
86  } else if (type == kNonTrig) {
87  ExpectedNBins = 6;
88  } else if (type == kIsoRings) {
89  ExpectedNBins = 4;
90  } else if (type == kTrigIDIsoCombined) {
91  ExpectedNBins = 6;
92  } else if (type == kTrigIDIsoCombinedPUCorrected) {
93  ExpectedNBins = 6;
94  }
95 
96  fNMVABins = ExpectedNBins;
97 
98  //Check number of weight files given
99  if (fNMVABins != weightsfiles.size() ) {
100  std::cout << "Error: Expected Number of bins = " << fNMVABins << " does not equal to weightsfiles.size() = "
101  << weightsfiles.size() << std::endl;
102 
103  #ifndef STANDALONE
104  assert(fNMVABins == weightsfiles.size());
105  #endif
106  }
107 
108  //Loop over all bins
109  for (unsigned int i=0;i<fNMVABins; ++i) {
110 
111  TMVA::Reader *tmpTMVAReader = new TMVA::Reader( "!Color:!Silent:Error" );
112  tmpTMVAReader->SetVerbose(kTRUE);
113 
114  if (type == kTrig) {
115  // Pure tracking variables
116  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
117  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
118  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
119  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
120 
121  // Geometrical matchings
122  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
123  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
124  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
125 
126  // Pure ECAL -> shower shapes
127  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
128  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
129  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
130  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
131  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
132  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
133 
134  // Energy matching
135  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
136  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
137  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
138  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
139  if(i == 2 || i == 5)
140  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
141 
142  if(!fUseBinnedVersion)
143  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
144 
145  // IP
146  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
147  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
148 
149  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
150  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
151  }
152 
153  if (type == kTrigNoIP) {
154 
155 
156  // Pure tracking variables
157  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
158  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
159  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
160  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
161 
162  // Geometrical matchings
163  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
164  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
165  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
166 
167  // Pure ECAL -> shower shapes
168  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
169  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
170  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
171  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
172  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
173  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
174 
175  // Energy matching
176  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
177  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
178  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
179  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
180  tmpTMVAReader->AddVariable("rho", &fMVAVar_rho);
181 
182  if(i == 2 || i == 5)
183  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
184 
185  if(!fUseBinnedVersion)
186  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
187 
188  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
189  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
190 
191  }
192 
193  if (type == kNonTrig) {
194 
195  // Pure tracking variables
196  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
197  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
198  tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
199  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
200 
201  // Geometrical matchings
202  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
203  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
204  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
205 
206  // Pure ECAL -> shower shapes
207  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
208  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
209  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
210  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
211  tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
212  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
213 
214  // Energy matching
215  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
216  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
217  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
218  tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
219  if(i == 2 || i == 5)
220  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
221 
222  if(!fUseBinnedVersion)
223  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
224 
225  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
226  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
227 
228  }
229 
230  if (type == kIsoRings) {
231  tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
232  tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
233  tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
234  tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
235  tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
236  tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
237  tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
238  tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
239  tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
240  tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
241  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
242  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
243  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
244  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
245  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
246  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
247  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
248  }
249 
250 
251  if (type == kTrigIDIsoCombinedPUCorrected) {
252 
253  // Pure tracking variables
254  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
255  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
256  tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
257  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
258 
259  // Geometrical matchings
260  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
261  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
262  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
263 
264  // Pure ECAL -> shower shapes
265  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
266  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
267  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
268  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
269  tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
270  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
271 
272  // Energy matching
273  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
274  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
275  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
276  tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
277  if(i == 2 || i == 5) {
278  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
279  }
280  if(!fUseBinnedVersion) {
281  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
282  }
283 
284  // IP
285  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
286  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
287 
288  //isolation variables
289  tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
290  tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
291  tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
292  tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
293  tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
294  tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
295  tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
296  tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
297  tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
298  tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
299  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
300  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
301  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
302  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
303  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
304 
305  //spectators
306  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
307  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
308 
309  }
310 
311  if (type == kTrigIDIsoCombined) {
312 
313  // Pure tracking variables
314  tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
315  tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
316  tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
317  tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
318 
319  // Geometrical matchings
320  tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
321  tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
322  tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
323 
324  // Pure ECAL -> shower shapes
325  tmpTMVAReader->AddVariable("see", &fMVAVar_see);
326  tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
327  tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
328  tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
329  tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
330  tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
331 
332  // Energy matching
333  tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
334  tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
335  tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
336  tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
337  if(i == 2 || i == 5) {
338  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
339  }
340  if(!fUseBinnedVersion) {
341  tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
342  }
343 
344  // IP
345  tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
346  tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
347 
348  //isolation variables
349  tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
350  tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
351  tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
352  tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
353  tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
354  tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
355  tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
356  tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
357  tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
358  tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
359  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
360  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
361  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
362  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
363  tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
364  tmpTMVAReader->AddVariable( "rho", &fMVAVar_rho );
365 
366  //spectators
367  tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
368  tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
369 
370  }
371 
372 #ifndef STANDALONE
373  if ((fMethodname == "BDT") && (weightsfiles[i].rfind(".xml.gz") == weightsfiles[i].length()-strlen(".xml.gz"))) {
374  gzFile file = gzopen(weightsfiles[i].c_str(), "rb");
375  if (file == nullptr) { std::cout << "Error opening gzip file associated to " << weightsfiles[i] << std::endl; throw cms::Exception("Configuration","Error reading zipped XML file"); }
376  std::vector<char> data;
377  data.reserve(1024*1024*10);
378  unsigned int bufflen = 32*1024;
379  char *buff = reinterpret_cast<char *>(malloc(bufflen));
380  if (buff == nullptr) { std::cout << "Error creating buffer for " << weightsfiles[i] << std::endl; gzclose(file); throw cms::Exception("Configuration","Error reading zipped XML file"); }
381  int read;
382  while ((read = gzread(file, buff, bufflen)) != 0) {
383  if (read == -1) { std::cout << "Error reading gzip file associated to " << weightsfiles[i] << ": " << gzerror(file,&read) << std::endl; gzclose(file); free(buff); throw cms::Exception("Configuration","Error reading zipped XML file"); }
384  data.insert(data.end(), buff, buff+read);
385  }
386  if (gzclose(file) != Z_OK) { std::cout << "Error closing gzip file associated to " << weightsfiles[i] << std::endl; }
387  free(buff);
388  data.push_back('\0'); // IMPORTANT
389  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(TMVA::Types::kBDT, &data[0])));
390  } else {
391  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(fMethodname , weightsfiles[i])));
392  }
393 #else
394  fTMVAMethod.push_back(dynamic_cast<TMVA::MethodBase*>(tmpTMVAReader->BookMVA(fMethodname , weightsfiles[i])));
395 #endif
396  std::cout << "MVABin " << i << " : MethodName = " << fMethodname
397  << " , type == " << type << " , "
398  << "Load weights file : " << weightsfiles[i]
399  << std::endl;
400  fTMVAReader.push_back(tmpTMVAReader);
401  }
402  std::cout << "Electron ID MVA Completed\n";
403 
404 }
405 
406 
407 //--------------------------------------------------------------------------------------------------
408 UInt_t EGammaMvaEleEstimator::GetMVABin( double eta, double pt) const {
409 
410  //Default is to return the first bin
411  unsigned int bin = 0;
412 
414  if (pt < 10 && fabs(eta) < 1.479) bin = 0;
415  if (pt < 10 && fabs(eta) >= 1.479) bin = 1;
416  if (pt >= 10 && fabs(eta) < 1.479) bin = 2;
417  if (pt >= 10 && fabs(eta) >= 1.479) bin = 3;
418  }
419 
421  bin = 0;
422  if (pt < 10 && fabs(eta) < 0.8) bin = 0;
423  if (pt < 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 1;
424  if (pt < 10 && fabs(eta) >= 1.479) bin = 2;
425  if (pt >= 10 && fabs(eta) < 0.8) bin = 3;
426  if (pt >= 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 4;
427  if (pt >= 10 && fabs(eta) >= 1.479) bin = 5;
428  }
429 
430 
435  ) {
436  bin = 0;
437  if (pt < 20 && fabs(eta) < 0.8) bin = 0;
438  if (pt < 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 1;
439  if (pt < 20 && fabs(eta) >= 1.479) bin = 2;
440  if (pt >= 20 && fabs(eta) < 0.8) bin = 3;
441  if (pt >= 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 4;
442  if (pt >= 20 && fabs(eta) >= 1.479) bin = 5;
443  }
444 
445 
446 
447  return bin;
448 }
449 
450 
451 //--------------------------------------------------------------------------------------------------
452 // for kTrig algorithm
453 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
454  Double_t kfchi2,
455  Int_t kfhits,
456  Double_t gsfchi2,
457  Double_t deta,
458  Double_t dphi,
459  Double_t detacalo,
460  //Double_t dphicalo,
461  Double_t see,
462  Double_t spp,
463  Double_t etawidth,
464  Double_t phiwidth,
465  Double_t OneMinusE1x5E5x5,
466  Double_t R9,
467  //Int_t nbrems,
468  Double_t HoE,
469  Double_t EoP,
470  Double_t IoEmIoP,
471  Double_t eleEoPout,
472  Double_t PreShowerOverRaw,
473  //Double_t EoPout,
474  Double_t d0,
475  Double_t ip3d,
476  Double_t eta,
477  Double_t pt,
478  Bool_t printDebug) {
479 
480  if (!fisInitialized) {
481  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
482  return -9999;
483  }
484 
486  std::cout << "Error: This method should be called for kTrig MVA only" <<std::endl;
487  return -9999;
488  }
489 
490  fMVAVar_fbrem = fbrem;
491  fMVAVar_kfchi2 = kfchi2;
492  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
493  fMVAVar_gsfchi2 = gsfchi2;
494 
495  fMVAVar_deta = deta;
496  fMVAVar_dphi = dphi;
497  fMVAVar_detacalo = detacalo;
498 
499 
500  fMVAVar_see = see;
501  fMVAVar_spp = spp;
502  fMVAVar_etawidth = etawidth;
503  fMVAVar_phiwidth = phiwidth;
504  fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
505  fMVAVar_R9 = R9;
506 
507 
508  fMVAVar_HoE = HoE;
509  fMVAVar_EoP = EoP;
510  fMVAVar_IoEmIoP = IoEmIoP;
511  fMVAVar_eleEoPout = eleEoPout;
512  fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
513 
514  fMVAVar_d0 = d0;
515  fMVAVar_ip3d = ip3d;
516  fMVAVar_eta = eta;
517  fMVAVar_pt = pt;
518 
519 
520  bindVariables();
521  Double_t mva = -9999;
522  if (fUseBinnedVersion) {
524  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
525  } else {
526  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
527  }
528 
529  if(printDebug) {
530  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
531  std::cout << " fbrem " << fMVAVar_fbrem
532  << " kfchi2 " << fMVAVar_kfchi2
533  << " mykfhits " << fMVAVar_kfhits
534  << " gsfchi2 " << fMVAVar_gsfchi2
535  << " deta " << fMVAVar_deta
536  << " dphi " << fMVAVar_dphi
537  << " detacalo " << fMVAVar_detacalo
538  << " see " << fMVAVar_see
539  << " spp " << fMVAVar_spp
540  << " etawidth " << fMVAVar_etawidth
541  << " phiwidth " << fMVAVar_phiwidth
542  << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
543  << " R9 " << fMVAVar_R9
544  << " HoE " << fMVAVar_HoE
545  << " EoP " << fMVAVar_EoP
546  << " IoEmIoP " << fMVAVar_IoEmIoP
547  << " eleEoPout " << fMVAVar_eleEoPout
548  << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
549  << " d0 " << fMVAVar_d0
550  << " ip3d " << fMVAVar_ip3d
551  << " eta " << fMVAVar_eta
552  << " pt " << fMVAVar_pt <<std::endl;
553  std::cout << " ### MVA " << mva << std::endl;
554  }
555 
556 
557  return mva;
558 }
559 
560 //--------------------------------------------------------------------------------------------------------
561 // for kTrigNoIP algorithm
562 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
563  Double_t kfchi2,
564  Int_t kfhits,
565  Double_t gsfchi2,
566  Double_t deta,
567  Double_t dphi,
568  Double_t detacalo,
569  Double_t see,
570  Double_t spp,
571  Double_t etawidth,
572  Double_t phiwidth,
573  Double_t e1x5e5x5,
574  Double_t R9,
575  Double_t HoE,
576  Double_t EoP,
577  Double_t IoEmIoP,
578  Double_t eleEoPout,
579  Double_t rho,
580  Double_t PreShowerOverRaw,
581  Double_t eta,
582  Double_t pt,
583  Bool_t printDebug) {
584 
585  if (!fisInitialized) {
586  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
587  return -9999;
588  }
589 
591  std::cout << "Error: This method should be called for kTrigNoIP MVA only" <<std::endl;
592  return -9999;
593  }
594 
595  fMVAVar_fbrem = fbrem;
596  fMVAVar_kfchi2 = kfchi2;
597  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
598  fMVAVar_gsfchi2 = gsfchi2;
599 
600  fMVAVar_deta = deta;
601  fMVAVar_dphi = dphi;
602  fMVAVar_detacalo = detacalo;
603 
604  fMVAVar_see = see;
605  fMVAVar_spp = spp;
606  fMVAVar_etawidth = etawidth;
607  fMVAVar_phiwidth = phiwidth;
608  fMVAVar_OneMinusE1x5E5x5 = e1x5e5x5;
609  fMVAVar_R9 = R9;
610 
611  fMVAVar_HoE = HoE;
612  fMVAVar_EoP = EoP;
613  fMVAVar_IoEmIoP = IoEmIoP;
614  fMVAVar_eleEoPout = eleEoPout;
615  fMVAVar_rho = rho;
616  fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
617 
618 
619  fMVAVar_eta = eta;
620  fMVAVar_pt = pt;
621 
622 
623  bindVariables();
624  Double_t mva = -9999;
625  if (fUseBinnedVersion) {
627  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
628  } else {
629  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
630  }
631 
632  if(printDebug) {
633  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
634  std::cout << " fbrem " << fMVAVar_fbrem
635  << " kfchi2 " << fMVAVar_kfchi2
636  << " mykfhits " << fMVAVar_kfhits
637  << " gsfchi2 " << fMVAVar_gsfchi2
638  << " deta " << fMVAVar_deta
639  << " dphi " << fMVAVar_dphi
640  << " detacalo " << fMVAVar_detacalo
641  << " see " << fMVAVar_see
642  << " spp " << fMVAVar_spp
643  << " etawidth " << fMVAVar_etawidth
644  << " phiwidth " << fMVAVar_phiwidth
645  << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
646  << " R9 " << fMVAVar_R9
647  << " HoE " << fMVAVar_HoE
648  << " EoP " << fMVAVar_EoP
649  << " IoEmIoP " << fMVAVar_IoEmIoP
650  << " eleEoPout " << fMVAVar_eleEoPout
651  << " rho " << fMVAVar_rho
652  << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
653  << " eta " << fMVAVar_eta
654  << " pt " << fMVAVar_pt <<std::endl;
655  std::cout << " ### MVA " << mva << std::endl;
656  }
657 
658 
659  return mva;
660 }
661 
662 //--------------------------------------------------------------------------------------------------
663 // for kNonTrig algorithm
664 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
665  Double_t kfchi2,
666  Int_t kfhits,
667  Double_t gsfchi2,
668  Double_t deta,
669  Double_t dphi,
670  Double_t detacalo,
671  //Double_t dphicalo,
672  Double_t see,
673  Double_t spp,
674  Double_t etawidth,
675  Double_t phiwidth,
676  Double_t OneMinusE1x5E5x5,
677  Double_t R9,
678  //Int_t nbrems,
679  Double_t HoE,
680  Double_t EoP,
681  Double_t IoEmIoP,
682  Double_t eleEoPout,
683  Double_t PreShowerOverRaw,
684  //Double_t EoPout,
685  Double_t eta,
686  Double_t pt,
687  Bool_t printDebug) {
688 
689  if (!fisInitialized) {
690  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
691  return -9999;
692  }
693 
695  std::cout << "Error: This method should be called for kNonTrig MVA only" <<std::endl;
696  return -9999;
697  }
698 
699  fMVAVar_fbrem = fbrem;
700  fMVAVar_kfchi2 = kfchi2;
701  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
702  fMVAVar_gsfchi2 = gsfchi2;
703 
704  fMVAVar_deta = deta;
705  fMVAVar_dphi = dphi;
706  fMVAVar_detacalo = detacalo;
707 
708 
709  fMVAVar_see = see;
710  fMVAVar_spp = spp;
711  fMVAVar_etawidth = etawidth;
712  fMVAVar_phiwidth = phiwidth;
713  fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
714  fMVAVar_R9 = R9;
715 
716 
717  fMVAVar_HoE = HoE;
718  fMVAVar_EoP = EoP;
719  fMVAVar_IoEmIoP = IoEmIoP;
720  fMVAVar_eleEoPout = eleEoPout;
721  fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
722 
723  fMVAVar_eta = eta;
724  fMVAVar_pt = pt;
725 
726 
727  bindVariables();
728  Double_t mva = -9999;
729  if (fUseBinnedVersion) {
731  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
732  } else {
733  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
734  }
735 
736 
737 
738  if(printDebug) {
739  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
740  std::cout << " fbrem " << fMVAVar_fbrem
741  << " kfchi2 " << fMVAVar_kfchi2
742  << " mykfhits " << fMVAVar_kfhits
743  << " gsfchi2 " << fMVAVar_gsfchi2
744  << " deta " << fMVAVar_deta
745  << " dphi " << fMVAVar_dphi
746  << " detacalo " << fMVAVar_detacalo
747  << " see " << fMVAVar_see
748  << " spp " << fMVAVar_spp
749  << " etawidth " << fMVAVar_etawidth
750  << " phiwidth " << fMVAVar_phiwidth
751  << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
752  << " R9 " << fMVAVar_R9
753  << " HoE " << fMVAVar_HoE
754  << " EoP " << fMVAVar_EoP
755  << " IoEmIoP " << fMVAVar_IoEmIoP
756  << " eleEoPout " << fMVAVar_eleEoPout
757  << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
758  << " eta " << fMVAVar_eta
759  << " pt " << fMVAVar_pt <<std::endl;
760  std::cout << " ### MVA " << mva << std::endl;
761  }
762 
763 
764  return mva;
765 }
766 
767 
768 
769 //--------------------------------------------------------------------------------------------------
771  Double_t kfchi2,
772  Int_t kfhits,
773  Double_t gsfchi2,
774  Double_t deta,
775  Double_t dphi,
776  Double_t detacalo,
777  Double_t see,
778  Double_t spp,
779  Double_t etawidth,
780  Double_t phiwidth,
781  Double_t OneMinusE1x5E5x5,
782  Double_t R9,
783  Double_t HoE,
784  Double_t EoP,
785  Double_t IoEmIoP,
786  Double_t eleEoPout,
787  Double_t PreShowerOverRaw,
788  Double_t d0,
789  Double_t ip3d,
790  Double_t ChargedIso_DR0p0To0p1,
791  Double_t ChargedIso_DR0p1To0p2,
792  Double_t ChargedIso_DR0p2To0p3,
793  Double_t ChargedIso_DR0p3To0p4,
794  Double_t ChargedIso_DR0p4To0p5,
795  Double_t GammaIso_DR0p0To0p1,
796  Double_t GammaIso_DR0p1To0p2,
797  Double_t GammaIso_DR0p2To0p3,
798  Double_t GammaIso_DR0p3To0p4,
799  Double_t GammaIso_DR0p4To0p5,
800  Double_t NeutralHadronIso_DR0p0To0p1,
801  Double_t NeutralHadronIso_DR0p1To0p2,
802  Double_t NeutralHadronIso_DR0p2To0p3,
803  Double_t NeutralHadronIso_DR0p3To0p4,
804  Double_t NeutralHadronIso_DR0p4To0p5,
805  Double_t Rho,
806  Double_t eta,
807  Double_t pt,
808  Bool_t printDebug) {
809 
810  if (!fisInitialized) {
811  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
812  return -9999;
813  }
814 
815  fMVAVar_fbrem = ( fbrem < -1.0 ) ? -1.0 : fbrem;
816  fMVAVar_kfchi2 = ( kfchi2 > 10 ) ? 10 : kfchi2;
817  fMVAVar_kfhits = float(kfhits); // BTD does not support int variables
818  fMVAVar_gsfchi2 = ( gsfchi2 > 200 ) ? 200 : gsfchi2;
819  fMVAVar_deta = ( fabs(deta) > 0.06 ) ? 0.06 : fabs(deta);
820  fMVAVar_dphi = dphi;
821  fMVAVar_detacalo = detacalo;
822 
823  fMVAVar_see = see;
824  fMVAVar_spp = spp;
825  fMVAVar_etawidth = etawidth;
826  fMVAVar_phiwidth = phiwidth;
827  fMVAVar_OneMinusE1x5E5x5= std::max(std::min(double(OneMinusE1x5E5x5),2.0),-1.0);
828  fMVAVar_R9 = (R9 > 5) ? 5: R9;
829 
830  fMVAVar_HoE = HoE;
831  fMVAVar_EoP = (EoP > 20) ? 20 : EoP;
832  fMVAVar_IoEmIoP = IoEmIoP;
833  fMVAVar_eleEoPout = (eleEoPout > 20) ? 20 : eleEoPout;
834  fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
835 
836  fMVAVar_d0 = d0;
837  fMVAVar_ip3d = ip3d;
838 
839  fMVAVar_ChargedIso_DR0p0To0p1 = ChargedIso_DR0p0To0p1;
840  fMVAVar_ChargedIso_DR0p1To0p2 = ChargedIso_DR0p1To0p2;
841  fMVAVar_ChargedIso_DR0p2To0p3 = ChargedIso_DR0p2To0p3;
842  fMVAVar_ChargedIso_DR0p3To0p4 = ChargedIso_DR0p3To0p4;
843  fMVAVar_ChargedIso_DR0p4To0p5 = ChargedIso_DR0p4To0p5;
844  fMVAVar_GammaIso_DR0p0To0p1 = GammaIso_DR0p0To0p1;
845  fMVAVar_GammaIso_DR0p1To0p2 = GammaIso_DR0p1To0p2;
846  fMVAVar_GammaIso_DR0p2To0p3 = GammaIso_DR0p2To0p3;
847  fMVAVar_GammaIso_DR0p3To0p4 = GammaIso_DR0p3To0p4;
848  fMVAVar_GammaIso_DR0p4To0p5 = GammaIso_DR0p4To0p5;
849  fMVAVar_NeutralHadronIso_DR0p0To0p1 = NeutralHadronIso_DR0p0To0p1;
850  fMVAVar_NeutralHadronIso_DR0p1To0p2 = NeutralHadronIso_DR0p1To0p2;
851  fMVAVar_NeutralHadronIso_DR0p2To0p3 = NeutralHadronIso_DR0p2To0p3;
852  fMVAVar_NeutralHadronIso_DR0p3To0p4 = NeutralHadronIso_DR0p3To0p4;
853  fMVAVar_NeutralHadronIso_DR0p4To0p5 = NeutralHadronIso_DR0p4To0p5;
854 
855  fMVAVar_rho = Rho;
856  fMVAVar_eta = eta;
857  fMVAVar_pt = pt;
858 
859  Double_t mva = -9999;
860  if (fUseBinnedVersion) {
862  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
863  } else {
864  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
865  }
866 
867  if(printDebug) {
868  std::cout << " *** Inside the class fMethodname " << fMethodname << std::endl;
869  std::cout << " fbrem " << fMVAVar_fbrem
870  << " kfchi2 " << fMVAVar_kfchi2
871  << " mykfhits " << fMVAVar_kfhits
872  << " gsfchi2 " << fMVAVar_gsfchi2
873  << " deta " << fMVAVar_deta
874  << " dphi " << fMVAVar_dphi
875  << " detacalo " << fMVAVar_detacalo
876  << " see " << fMVAVar_see
877  << " spp " << fMVAVar_spp
878  << " etawidth " << fMVAVar_etawidth
879  << " phiwidth " << fMVAVar_phiwidth
880  << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
881  << " R9 " << fMVAVar_R9
882  << " HoE " << fMVAVar_HoE
883  << " EoP " << fMVAVar_EoP
884  << " IoEmIoP " << fMVAVar_IoEmIoP
885  << " eleEoPout " << fMVAVar_eleEoPout
886  << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
887  << " d0 " << fMVAVar_d0
888  << " ip3d " << fMVAVar_ip3d
889  << " ChargedIso_DR0p0To0p1 " << ChargedIso_DR0p0To0p1
890  << " ChargedIso_DR0p1To0p2 " << ChargedIso_DR0p1To0p2
891  << " ChargedIso_DR0p2To0p3 " << ChargedIso_DR0p2To0p3
892  << " ChargedIso_DR0p3To0p4 " << ChargedIso_DR0p3To0p4
893  << " ChargedIso_DR0p4To0p5 " << ChargedIso_DR0p4To0p5
894  << " GammaIso_DR0p0To0p1 " << GammaIso_DR0p0To0p1
895  << " GammaIso_DR0p1To0p2 " << GammaIso_DR0p1To0p2
896  << " GammaIso_DR0p2To0p3 " << GammaIso_DR0p2To0p3
897  << " GammaIso_DR0p3To0p4 " << GammaIso_DR0p3To0p4
898  << " GammaIso_DR0p4To0p5 " << GammaIso_DR0p4To0p5
899  << " NeutralHadronIso_DR0p0To0p1 " << NeutralHadronIso_DR0p0To0p1
900  << " NeutralHadronIso_DR0p1To0p2 " << NeutralHadronIso_DR0p1To0p2
901  << " NeutralHadronIso_DR0p2To0p3 " << NeutralHadronIso_DR0p2To0p3
902  << " NeutralHadronIso_DR0p3To0p4 " << NeutralHadronIso_DR0p3To0p4
903  << " NeutralHadronIso_DR0p4To0p5 " << NeutralHadronIso_DR0p4To0p5
904  << " Rho " << Rho
905  << " eta " << fMVAVar_eta
906  << " pt " << fMVAVar_pt <<std::endl;
907  std::cout << " ### MVA " << mva << std::endl;
908  }
909 
910  return mva;
911 }
912 
913 
914 
915 
916 
917 #ifndef STANDALONE
919  Double_t Eta,
920  Double_t Rho,
922  Double_t ChargedIso_DR0p0To0p1,
923  Double_t ChargedIso_DR0p1To0p2,
924  Double_t ChargedIso_DR0p2To0p3,
925  Double_t ChargedIso_DR0p3To0p4,
926  Double_t ChargedIso_DR0p4To0p5,
927  Double_t GammaIso_DR0p0To0p1,
928  Double_t GammaIso_DR0p1To0p2,
929  Double_t GammaIso_DR0p2To0p3,
930  Double_t GammaIso_DR0p3To0p4,
931  Double_t GammaIso_DR0p4To0p5,
932  Double_t NeutralHadronIso_DR0p0To0p1,
933  Double_t NeutralHadronIso_DR0p1To0p2,
934  Double_t NeutralHadronIso_DR0p2To0p3,
935  Double_t NeutralHadronIso_DR0p3To0p4,
936  Double_t NeutralHadronIso_DR0p4To0p5,
937  Bool_t printDebug) {
938 
939  if (!fisInitialized) {
940  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
941  return -9999;
942  }
943 
944  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((ChargedIso_DR0p0To0p1)/Pt, 2.5);
945  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((ChargedIso_DR0p1To0p2)/Pt, 2.5);
946  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((ChargedIso_DR0p2To0p3)/Pt, 2.5);
947  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((ChargedIso_DR0p3To0p4)/Pt, 2.5);
948  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((ChargedIso_DR0p4To0p5)/Pt, 2.5);
959 
960  // evaluate
961  int bin = GetMVABin(Eta,Pt);
962  Double_t mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
963 
964  if(printDebug) {
965  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << std::endl;
966  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
971  << fMVAVar_ChargedIso_DR0p4To0p5 <<std::endl;
972  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
977  << fMVAVar_GammaIso_DR0p4To0p5 <<std::endl;
978  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
984  <<std::endl;
985  std::cout << " ### MVA " << mva <<std::endl;
986  }
987 
988  return mva;
989 
990 }
991 
992 
993 //--------------------------------------------------------------------------------------------------
994 
995 // for kTrig and kNonTrig algorithm
997  const reco::Vertex& vertex,
998  const TransientTrackBuilder& transientTrackBuilder,
999  EcalClusterLazyTools myEcalCluster,
1000  bool printDebug) {
1001 
1002  if (!fisInitialized) {
1003  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1004  return -9999;
1005  }
1006 
1008  std::cout << "Error: This method should be called for kTrig or kNonTrig MVA only" <<std::endl;
1009  return -9999;
1010  }
1011 
1012  bool validKF= false;
1013  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1014  validKF = (myTrackRef.isAvailable());
1015  validKF &= (myTrackRef.isNonnull());
1016 
1017  // Pure tracking variables
1018  fMVAVar_fbrem = ele.fbrem();
1019  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
1020  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
1021  fMVAVar_kfhitsall = (validKF) ? myTrackRef->numberOfValidHits() : -1. ; // save also this in your ntuple as possible alternative
1022  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1023 
1024 
1025  // Geometrical matchings
1029 
1030 
1031  // Pure ECAL -> shower shapes
1032  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1033  std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
1034  if (edm::isFinite(vCov[2])) fMVAVar_spp = sqrt (vCov[2]); //EleSigmaIPhiIPhi
1035  else fMVAVar_spp = 0.;
1036 
1037  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1038  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1039  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
1040  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
1041 
1042  // Energy matching
1043  fMVAVar_HoE = ele.hadronicOverEm();
1045  fMVAVar_IoEmIoP = (1.0/ele.ecalEnergy()) - (1.0 / ele.p()); // in the future to be changed with ele.gsfTrack()->p()
1047  fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1048 
1049 
1050  // Spectators
1051  fMVAVar_eta = ele.superCluster()->eta();
1052  fMVAVar_pt = ele.pt();
1053 
1054 
1055 
1056  // for triggering electrons get the impact parameteres
1057  if(fMVAType == kTrig) {
1058  //d0
1059  if (ele.gsfTrack().isNonnull()) {
1060  fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
1061  } else if (ele.closestCtfTrackRef().isNonnull()) {
1062  fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
1063  } else {
1064  fMVAVar_d0 = -9999.0;
1065  }
1066 
1067  //default values for IP3D
1068  fMVAVar_ip3d = -999.0;
1069  fMVAVar_ip3dSig = 0.0;
1070  if (ele.gsfTrack().isNonnull()) {
1071  const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
1072 
1073  const reco::TransientTrack &tt = transientTrackBuilder.build(ele.gsfTrack());
1074  const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,vertex);
1075  if (ip3dpv.first) {
1076  double ip3d = gsfsign*ip3dpv.second.value();
1077  double ip3derr = ip3dpv.second.error();
1078  fMVAVar_ip3d = ip3d;
1079  fMVAVar_ip3dSig = ip3d/ip3derr;
1080  }
1081  }
1082  }
1083 
1084 
1085  // evaluate
1086  bindVariables();
1087  Double_t mva = -9999;
1088  if (fUseBinnedVersion) {
1090  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1091  } else {
1092  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1093  }
1094 
1095 
1096 
1097  if(printDebug) {
1098  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1099  std::cout << " fbrem " << fMVAVar_fbrem
1100  << " kfchi2 " << fMVAVar_kfchi2
1101  << " mykfhits " << fMVAVar_kfhits
1102  << " gsfchi2 " << fMVAVar_gsfchi2
1103  << " deta " << fMVAVar_deta
1104  << " dphi " << fMVAVar_dphi
1105  << " detacalo " << fMVAVar_detacalo
1106  << " see " << fMVAVar_see
1107  << " spp " << fMVAVar_spp
1108  << " etawidth " << fMVAVar_etawidth
1109  << " phiwidth " << fMVAVar_phiwidth
1110  << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
1111  << " R9 " << fMVAVar_R9
1112  << " HoE " << fMVAVar_HoE
1113  << " EoP " << fMVAVar_EoP
1114  << " IoEmIoP " << fMVAVar_IoEmIoP
1115  << " eleEoPout " << fMVAVar_eleEoPout
1116  << " d0 " << fMVAVar_d0
1117  << " ip3d " << fMVAVar_ip3d
1118  << " eta " << fMVAVar_eta
1119  << " pt " << fMVAVar_pt <<std::endl;
1120  std::cout << " ### MVA " << mva <<std::endl;
1121  }
1122 
1123 
1124 
1125  return mva;
1126 }
1127 
1128 
1129 // for kTrigNoIP algorithm
1131  const reco::Vertex& vertex,
1132  double rho,
1133  //const TransientTrackBuilder& transientTrackBuilder,
1134  EcalClusterLazyTools myEcalCluster,
1135  bool printDebug) {
1136 
1137  if (!fisInitialized) {
1138  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1139  return -9999;
1140  }
1141 
1143  std::cout << "Error: This method should be called for kTrigNoIP MVA only" <<std::endl;
1144  return -9999;
1145  }
1146 
1147  bool validKF= false;
1148  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1149  validKF = (myTrackRef.isAvailable());
1150  validKF &= (myTrackRef.isNonnull());
1151 
1152  // Pure tracking variables
1153  fMVAVar_fbrem = ele.fbrem();
1154  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
1155  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
1156  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1157 
1158 
1159  // Geometrical matchings
1163 
1164 
1165  // Pure ECAL -> shower shapes
1166  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1167  std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
1168  if (edm::isFinite(vCov[2])) fMVAVar_spp = sqrt (vCov[2]); //EleSigmaIPhiIPhi
1169  else fMVAVar_spp = 0.;
1170 
1171 
1172  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1173  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1174  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
1175  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
1176 
1177 
1178  // Energy matching
1179  fMVAVar_HoE = ele.hadronicOverEm();
1181  fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1183  fMVAVar_rho = rho;
1184  fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1185 
1186 
1187  // Spectators
1188  fMVAVar_eta = ele.superCluster()->eta();
1189  fMVAVar_pt = ele.pt();
1190 
1191 
1192 
1193 
1194 
1195  // evaluate
1196  bindVariables();
1197  Double_t mva = -9999;
1198  if (fUseBinnedVersion) {
1200  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1201  } else {
1202  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1203  }
1204 
1205 
1206 
1207  if(printDebug) {
1208  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1209  std::cout << " fbrem " << fMVAVar_fbrem
1210  << " kfchi2 " << fMVAVar_kfchi2
1211  << " mykfhits " << fMVAVar_kfhits
1212  << " gsfchi2 " << fMVAVar_gsfchi2
1213  << " deta " << fMVAVar_deta
1214  << " dphi " << fMVAVar_dphi
1215  << " detacalo " << fMVAVar_detacalo
1216  // << " dphicalo " << fMVAVar_dphicalo
1217  << " see " << fMVAVar_see
1218  << " spp " << fMVAVar_spp
1219  << " etawidth " << fMVAVar_etawidth
1220  << " phiwidth " << fMVAVar_phiwidth
1221  << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
1222  << " R9 " << fMVAVar_R9
1223  // << " mynbrems " << fMVAVar_nbrems
1224  << " HoE " << fMVAVar_HoE
1225  << " EoP " << fMVAVar_EoP
1226  << " IoEmIoP " << fMVAVar_IoEmIoP
1227  << " eleEoPout " << fMVAVar_eleEoPout
1228  << " rho " << fMVAVar_rho
1229  // << " EoPout " << fMVAVar_EoPout
1230  << " eta " << fMVAVar_eta
1231  << " pt " << fMVAVar_pt <<std::endl;
1232  std::cout << " ### MVA " << mva <<std::endl;
1233  }
1234 
1235 
1236 
1237  return mva;
1238 }
1239 
1240 // for kTrig, kNonTrig and kTrigNoIP algorithm
1242  const reco::Vertex& vertex,
1243  double rho,
1244  bool useFull5x5,
1245  bool printDebug) {
1246 
1247  if (!fisInitialized) {
1248  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1249  return -9999;
1250  }
1251 
1252  bool validKF= false;
1253  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1254  validKF = (myTrackRef.isAvailable());
1255  validKF &= (myTrackRef.isNonnull());
1256 
1257  // Pure tracking variables
1258  fMVAVar_fbrem = ele.fbrem();
1259  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
1260  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
1261  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1262 
1263 
1264  // Geometrical matchings
1268 
1269  // Pure ECAL -> shower shapes
1270  fMVAVar_see = useFull5x5 ? ele.full5x5_sigmaIetaIeta() : ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1271  fMVAVar_spp = useFull5x5 ? ele.full5x5_sigmaIphiIphi() : ele.sigmaIphiIphi(); //EleSigmaIEtaIEta
1272 
1273  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1274  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1275  fMVAVar_OneMinusE1x5E5x5 = useFull5x5 ? ( (ele.full5x5_e5x5()) !=0. ? 1.-(ele.full5x5_e1x5()/ele.full5x5_e5x5()) : -1. )
1276  : ( (ele.e5x5() ) !=0. ? 1.-(ele.e1x5() /ele.e5x5() ) : -1. ) ;
1277  fMVAVar_R9 = useFull5x5 ? ele.full5x5_r9() : ele.r9();
1278 
1279  // Energy matching
1280  fMVAVar_HoE = ele.hadronicOverEm(); // this is identical for both
1282 
1283  // unify this in the future?
1284  if( fMVAType == kTrig || fMVAType == kNonTrig){
1285  fMVAVar_IoEmIoP = (1.0/ele.ecalEnergy()) - (1.0 / ele.p()); // in the future to be changed with ele.gsfTrack()->p()
1286  }else{
1287  fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1288  }
1290  fMVAVar_rho = rho;
1291  fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1292 
1293  // for triggering electrons get the impact parameteres
1294  if(fMVAType == kTrig) {
1295  //d0
1296  if (ele.gsfTrack().isNonnull()) {
1297  fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
1298  } else if (ele.closestCtfTrackRef().isNonnull()) {
1299  fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
1300  } else {
1301  fMVAVar_d0 = -9999.0;
1302  }
1303 
1304  //default values for IP3D
1305  fMVAVar_ip3d = -999.0;
1306  fMVAVar_ip3dSig = 0.0;
1307  if (ele.gsfTrack().isNonnull()) {
1308  const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
1309 
1310  //std::cout << "Warning : if usePV = false when pat-electrons were produced, dB() was calculated with respect to beamspot while original mva uses primary vertex" << std::endl;
1311  double ip3d = gsfsign*ele.dB();
1312  double ip3derr = ele.edB();
1313  fMVAVar_ip3d = ip3d;
1314  fMVAVar_ip3dSig = ip3d/ip3derr;
1315  }
1316  }
1317 
1318  // Spectators
1319  fMVAVar_eta = ele.superCluster()->eta();
1320  fMVAVar_pt = ele.pt();
1321 
1322  // evaluate
1323  bindVariables();
1324  Double_t mva = -9999;
1325  if (fUseBinnedVersion) {
1327  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1328  } else {
1329  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1330  }
1331 
1332  if(printDebug) {
1333  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1334  std::cout << " fbrem " << fMVAVar_fbrem
1335  << " kfchi2 " << fMVAVar_kfchi2
1336  << " mykfhits " << fMVAVar_kfhits
1337  << " gsfchi2 " << fMVAVar_gsfchi2
1338  << " deta " << fMVAVar_deta
1339  << " dphi " << fMVAVar_dphi
1340  << " detacalo " << fMVAVar_detacalo
1341  // << " dphicalo " << fMVAVar_dphicalo
1342  << " see " << fMVAVar_see
1343  << " spp " << fMVAVar_spp
1344  << " etawidth " << fMVAVar_etawidth
1345  << " phiwidth " << fMVAVar_phiwidth
1346  << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
1347  << " R9 " << fMVAVar_R9
1348  // << " mynbrems " << fMVAVar_nbrems
1349  << " HoE " << fMVAVar_HoE
1350  << " EoP " << fMVAVar_EoP
1351  << " IoEmIoP " << fMVAVar_IoEmIoP
1352  << " eleEoPout " << fMVAVar_eleEoPout
1353  << " rho " << fMVAVar_rho
1354  // << " EoPout " << fMVAVar_EoPout
1355  << " d0 " << fMVAVar_d0
1356  << " ip3d " << fMVAVar_ip3d
1357  << " eta " << fMVAVar_eta
1358  << " pt " << fMVAVar_pt <<std::endl;
1359  std::cout << " ### MVA " << mva <<std::endl;
1360  }
1361 
1362  return mva;
1363 }
1364 
1365 
1366 // for kTrigNoIP algorithm only.
1368  double rho,
1369  bool printDebug) {
1370 
1371  if (!fisInitialized) {
1372  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1373  return -9999;
1374  }
1375 
1377  std::cout << "Error: This method should be called for kTrigNoIP mva only" <<std::endl;
1378  return -9999;
1379  }
1380 
1381 
1382  bool validKF= false;
1383  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1384  validKF = (myTrackRef.isAvailable());
1385  validKF &= (myTrackRef.isNonnull());
1386 
1387  // Pure tracking variables
1388  fMVAVar_fbrem = ele.fbrem();
1389  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
1390  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
1391  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1392 
1393 
1394  // Geometrical matchings
1398 
1399 
1400  // Pure ECAL -> shower shapes
1401  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1402 
1403  fMVAVar_spp = ele.sigmaIphiIphi();
1404 
1405  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1406  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1407  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
1408  fMVAVar_R9 = ele.r9();
1409 
1410  // Energy matching
1411  fMVAVar_HoE = ele.hadronicOverEm();
1413  fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p()); // in the future to be changed with ele.gsfTrack()->p()
1415  fMVAVar_rho = rho;
1416  fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1417 
1418 
1419  // Spectators
1420  fMVAVar_eta = ele.superCluster()->eta();
1421  fMVAVar_pt = ele.pt();
1422 
1423 
1424 
1425 
1426 
1427  // evaluate
1428  bindVariables();
1429  Double_t mva = -9999;
1430  if (fUseBinnedVersion) {
1432  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1433  } else {
1434  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1435  }
1436 
1437 
1438 
1439  if(printDebug) {
1440  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1441  std::cout << " fbrem " << fMVAVar_fbrem
1442  << " kfchi2 " << fMVAVar_kfchi2
1443  << " mykfhits " << fMVAVar_kfhits
1444  << " gsfchi2 " << fMVAVar_gsfchi2
1445  << " deta " << fMVAVar_deta
1446  << " dphi " << fMVAVar_dphi
1447  << " detacalo " << fMVAVar_detacalo
1448  // << " dphicalo " << fMVAVar_dphicalo
1449  << " see " << fMVAVar_see
1450  << " spp " << fMVAVar_spp
1451  << " etawidth " << fMVAVar_etawidth
1452  << " phiwidth " << fMVAVar_phiwidth
1453  << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
1454  << " R9 " << fMVAVar_R9
1455  // << " mynbrems " << fMVAVar_nbrems
1456  << " HoE " << fMVAVar_HoE
1457  << " EoP " << fMVAVar_EoP
1458  << " IoEmIoP " << fMVAVar_IoEmIoP
1459  << " eleEoPout " << fMVAVar_eleEoPout
1460  << " rho " << fMVAVar_rho
1461  // << " EoPout " << fMVAVar_EoPout
1462  << " eta " << fMVAVar_eta
1463  << " pt " << fMVAVar_pt <<std::endl;
1464  std::cout << " ### MVA " << mva <<std::endl;
1465  }
1466 
1467 
1468 
1469  return mva;
1470 }
1471 
1472 
1473 
1474 
1475 
1476 
1477 
1478 
1479 
1481  const reco::Vertex& vertex,
1483  double Rho,
1485  const reco::GsfElectronCollection &IdentifiedElectrons,
1486  const reco::MuonCollection &IdentifiedMuons,
1487  bool printDebug) {
1488 
1489  if (!fisInitialized) {
1490  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1491  return -9999;
1492  }
1493 
1494  // Spectators
1495  fMVAVar_eta = ele.superCluster()->eta();
1496  fMVAVar_pt = ele.pt();
1497 
1498  //**********************************************************
1499  //Isolation variables
1500  //**********************************************************
1501  Double_t tmpChargedIso_DR0p0To0p1 = 0;
1502  Double_t tmpChargedIso_DR0p1To0p2 = 0;
1503  Double_t tmpChargedIso_DR0p2To0p3 = 0;
1504  Double_t tmpChargedIso_DR0p3To0p4 = 0;
1505  Double_t tmpChargedIso_DR0p4To0p5 = 0;
1506  Double_t tmpGammaIso_DR0p0To0p1 = 0;
1507  Double_t tmpGammaIso_DR0p1To0p2 = 0;
1508  Double_t tmpGammaIso_DR0p2To0p3 = 0;
1509  Double_t tmpGammaIso_DR0p3To0p4 = 0;
1510  Double_t tmpGammaIso_DR0p4To0p5 = 0;
1511  Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
1512  Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
1513  Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
1514  Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
1515  Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
1516 
1517  double electronTrackZ = 0;
1518  if (ele.gsfTrack().isNonnull()) {
1519  electronTrackZ = ele.gsfTrack()->dz(vertex.position());
1520  } else if (ele.closestCtfTrackRef().isNonnull()) {
1521  electronTrackZ = ele.closestCtfTrackRef()->dz(vertex.position());
1522  }
1523 
1524  for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin();
1525  iP != PFCandidates.end(); ++iP) {
1526 
1527  //exclude the electron itself
1528  if(iP->gsfTrackRef().isNonnull() && ele.gsfTrack().isNonnull() &&
1529  refToPtr(iP->gsfTrackRef()) == refToPtr(ele.gsfTrack())) continue;
1530  if(iP->trackRef().isNonnull() && ele.closestCtfTrackRef().isNonnull() &&
1531  refToPtr(iP->trackRef()) == refToPtr(ele.closestCtfTrackRef())) continue;
1532 
1533  //************************************************************
1534  // New Isolation Calculations
1535  //************************************************************
1536  double dr = sqrt(pow(iP->eta() - ele.eta(),2) + pow(acos(cos(iP->phi() - ele.phi())),2));
1537  //Double_t deta = (iP->eta() - ele.eta());
1538 
1539  if (dr < 1.0) {
1540  Bool_t IsLeptonFootprint = kFALSE;
1541  //************************************************************
1542  // Lepton Footprint Removal
1543  //************************************************************
1544  for (reco::GsfElectronCollection::const_iterator iE = IdentifiedElectrons.begin();
1545  iE != IdentifiedElectrons.end(); ++iE) {
1546  //if pf candidate matches an electron passing ID cuts, then veto it
1547  if(iP->gsfTrackRef().isNonnull() && iE->gsfTrack().isNonnull() &&
1548  refToPtr(iP->gsfTrackRef()) == refToPtr(iE->gsfTrack())) IsLeptonFootprint = kTRUE;
1549  if(iP->trackRef().isNonnull() && iE->closestCtfTrackRef().isNonnull() &&
1550  refToPtr(iP->trackRef()) == refToPtr(iE->closestCtfTrackRef())) IsLeptonFootprint = kTRUE;
1551 
1552  //if pf candidate lies in veto regions of electron passing ID cuts, then veto it
1553  double tmpDR = sqrt(pow(iP->eta() - iE->eta(),2) + pow(acos(cos(iP->phi() - iE->phi())),2));
1554  if(iP->trackRef().isNonnull() && fabs(iE->superCluster()->eta()) >= 1.479
1555  && tmpDR < 0.015) IsLeptonFootprint = kTRUE;
1556  if(iP->particleId() == reco::PFCandidate::gamma && fabs(iE->superCluster()->eta()) >= 1.479
1557  && tmpDR < 0.08) IsLeptonFootprint = kTRUE;
1558  }
1559  for (reco::MuonCollection::const_iterator iM = IdentifiedMuons.begin();
1560  iM != IdentifiedMuons.end(); ++iM) {
1561  //if pf candidate matches an muon passing ID cuts, then veto it
1562  if(iP->trackRef().isNonnull() && iM->innerTrack().isNonnull() &&
1563  refToPtr(iP->trackRef()) == refToPtr(iM->innerTrack())) IsLeptonFootprint = kTRUE;
1564 
1565  //if pf candidate lies in veto regions of muon passing ID cuts, then veto it
1566  double tmpDR = sqrt(pow(iP->eta() - iM->eta(),2) + pow(acos(cos(iP->phi() - iM->phi())),2));
1567  if(iP->trackRef().isNonnull() && tmpDR < 0.01) IsLeptonFootprint = kTRUE;
1568  }
1569 
1570  if (!IsLeptonFootprint) {
1571  Bool_t passVeto = kTRUE;
1572  //Charged
1573  if(iP->trackRef().isNonnull()) {
1574  if (!(fabs(iP->trackRef()->dz(vertex.position()) - electronTrackZ) < 0.2)) passVeto = kFALSE;
1575  //************************************************************
1576  // Veto any PFmuon, or PFEle
1577  if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu) passVeto = kFALSE;
1578  //************************************************************
1579  //************************************************************
1580  // Footprint Veto
1581  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015) passVeto = kFALSE;
1582  //************************************************************
1583  if (passVeto) {
1584  if (dr < 0.1) tmpChargedIso_DR0p0To0p1 += iP->pt();
1585  if (dr >= 0.1 && dr < 0.2) tmpChargedIso_DR0p1To0p2 += iP->pt();
1586  if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += iP->pt();
1587  if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += iP->pt();
1588  if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += iP->pt();
1589  } //pass veto
1590  }
1591  //Gamma
1592  else if (iP->particleId() == reco::PFCandidate::gamma) {
1593  //************************************************************
1594  // Footprint Veto
1595  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08) passVeto = kFALSE;
1596  //************************************************************
1597  if (passVeto) {
1598  if (dr < 0.1) tmpGammaIso_DR0p0To0p1 += iP->pt();
1599  if (dr >= 0.1 && dr < 0.2) tmpGammaIso_DR0p1To0p2 += iP->pt();
1600  if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += iP->pt();
1601  if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += iP->pt();
1602  if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += iP->pt();
1603  }
1604  }
1605  //NeutralHadron
1606  else {
1607  if (dr < 0.1) tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
1608  if (dr >= 0.1 && dr < 0.2) tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
1609  if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
1610  if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
1611  if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
1612  }
1613  } //not lepton footprint
1614  } //in 1.0 dr cone
1615  } //loop over PF candidates
1616 
1617  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
1618  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
1619  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
1620  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
1621  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
1632 
1633  if (printDebug) {
1634  std::cout << "UseBinnedVersion=" << fUseBinnedVersion << " -> BIN: " << fMVAVar_eta << " " << fMVAVar_pt << " : " << GetMVABin(fMVAVar_eta,fMVAVar_pt) <<std::endl;
1635  }
1636 
1637  // evaluate
1638  bindVariables();
1639  Double_t mva = -9999;
1640 
1641 // mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
1642  if (fUseBinnedVersion) {
1644  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1645  } else {
1646  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1647  }
1648 
1649 
1650  if(printDebug) {
1651  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1652  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1657  << fMVAVar_ChargedIso_DR0p4To0p5 <<std::endl;
1658  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1659  << fMVAVar_GammaIso_DR0p0To0p1 << " "
1660  << fMVAVar_GammaIso_DR0p1To0p2 << " "
1661  << fMVAVar_GammaIso_DR0p2To0p3 << " "
1662  << fMVAVar_GammaIso_DR0p3To0p4 << " "
1663  << fMVAVar_GammaIso_DR0p4To0p5 <<std::endl;
1664  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1670  <<std::endl;
1671  std::cout << " ### MVA " << mva <<std::endl;
1672  }
1673 
1674 
1675  return mva;
1676 }
1677 
1678 
1679 //--------------------------------------------------------------------------------------------------
1680 
1682  const reco::Vertex& vertex,
1683  const TransientTrackBuilder& transientTrackBuilder,
1684  EcalClusterLazyTools myEcalCluster,
1686  double Rho,
1688  bool printDebug) {
1689 
1690  if (!fisInitialized) {
1691  std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
1692  return -9999;
1693  }
1694 
1695  bool validKF= false;
1696  reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
1697  validKF = (myTrackRef.isAvailable());
1698  validKF &= (myTrackRef.isNonnull());
1699 
1700  // Pure tracking variables
1701  fMVAVar_fbrem = (ele.fbrem() < -1. ) ? -1. : ele.fbrem();
1702  fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
1703  if (fMVAVar_kfchi2 > 10) fMVAVar_kfchi2 = 10;
1704  fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
1705  fMVAVar_kfhitsall = (validKF) ? myTrackRef->numberOfValidHits() : -1. ; // save also this in your ntuple as possible alternative
1706  fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
1707  if (fMVAVar_gsfchi2 > 200) fMVAVar_gsfchi2 = 200;
1708 
1709 
1710  // Geometrical matchings
1711  fMVAVar_deta = ( fabs(ele.deltaEtaSuperClusterTrackAtVtx()) > 0.06 ) ? 0.06 : fabs(ele.deltaEtaSuperClusterTrackAtVtx());
1714 
1715 
1716  // Pure ECAL -> shower shapes
1717  fMVAVar_see = ele.sigmaIetaIeta(); //EleSigmaIEtaIEta
1718  std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
1719  if (edm::isFinite(vCov[2])) fMVAVar_spp = sqrt (vCov[2]); //EleSigmaIPhiIPhi
1720  else fMVAVar_spp = 0.;
1721 
1722  fMVAVar_etawidth = ele.superCluster()->etaWidth();
1723  fMVAVar_phiwidth = ele.superCluster()->phiWidth();
1724  fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
1726  fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
1727  if (fMVAVar_R9 > 5) fMVAVar_R9 = 5;
1728 
1729  // Energy matching
1730  fMVAVar_HoE = ele.hadronicOverEm();
1731  fMVAVar_EoP = ( ele.eSuperClusterOverP() > 20 ) ? 20 : ele.eSuperClusterOverP();
1732  fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.trackMomentumAtVtx().R()); //this is the proper variable
1733  fMVAVar_eleEoPout = ( ele.eEleClusterOverPout() > 20 ) ? 20 : ele.eEleClusterOverPout();
1734  fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
1735 
1736  // Spectators
1737  fMVAVar_eta = ele.superCluster()->eta();
1738  fMVAVar_pt = ele.pt();
1739 
1740 
1741 
1742  // for triggering electrons get the impact parameteres
1743  if(fMVAType == kTrig) {
1744  //d0
1745  if (ele.gsfTrack().isNonnull()) {
1746  fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
1747  } else if (ele.closestCtfTrackRef().isNonnull()) {
1748  fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
1749  } else {
1750  fMVAVar_d0 = -9999.0;
1751  }
1752 
1753  //default values for IP3D
1754  fMVAVar_ip3d = -999.0;
1755  fMVAVar_ip3dSig = 0.0;
1756  if (ele.gsfTrack().isNonnull()) {
1757  const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
1758 
1759  const reco::TransientTrack &tt = transientTrackBuilder.build(ele.gsfTrack());
1760  const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,vertex);
1761  if (ip3dpv.first) {
1762  double ip3d = gsfsign*ip3dpv.second.value();
1763  double ip3derr = ip3dpv.second.error();
1764  fMVAVar_ip3d = ip3d;
1765  fMVAVar_ip3dSig = ip3d/ip3derr;
1766  }
1767  }
1768  }
1769 
1770  //**********************************************************
1771  //Isolation variables
1772  //**********************************************************
1773  Double_t tmpChargedIso_DR0p0To0p1 = 0;
1774  Double_t tmpChargedIso_DR0p1To0p2 = 0;
1775  Double_t tmpChargedIso_DR0p2To0p3 = 0;
1776  Double_t tmpChargedIso_DR0p3To0p4 = 0;
1777  Double_t tmpChargedIso_DR0p4To0p5 = 0;
1778  Double_t tmpGammaIso_DR0p0To0p1 = 0;
1779  Double_t tmpGammaIso_DR0p1To0p2 = 0;
1780  Double_t tmpGammaIso_DR0p2To0p3 = 0;
1781  Double_t tmpGammaIso_DR0p3To0p4 = 0;
1782  Double_t tmpGammaIso_DR0p4To0p5 = 0;
1783  Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
1784  Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
1785  Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
1786  Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
1787  Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
1788 
1789  for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin();
1790  iP != PFCandidates.end(); ++iP) {
1791 
1792  double dr = sqrt(pow(iP->eta() - ele.eta(),2) + pow(acos(cos(iP->phi() - ele.phi())),2));
1793 
1794  Bool_t passVeto = kTRUE;
1795  //Charged
1796  if(iP->trackRef().isNonnull()) {
1797 
1798  //make sure charged pf candidates pass the PFNoPU condition (assumed)
1799 
1800  //************************************************************
1801  // Veto any PFmuon, or PFEle
1802  if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu) passVeto = kFALSE;
1803  //************************************************************
1804  //************************************************************
1805  // Footprint Veto
1806  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015) passVeto = kFALSE;
1807  //************************************************************
1808  if (passVeto) {
1809  if (dr < 0.1) tmpChargedIso_DR0p0To0p1 += iP->pt();
1810  if (dr >= 0.1 && dr < 0.2) tmpChargedIso_DR0p1To0p2 += iP->pt();
1811  if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += iP->pt();
1812  if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += iP->pt();
1813  if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += iP->pt();
1814  } //pass veto
1815  }
1816  //Gamma
1817  else if (iP->particleId() == reco::PFCandidate::gamma) {
1818  //************************************************************
1819  // Footprint Veto
1820  if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08) passVeto = kFALSE;
1821  //************************************************************
1822  if (passVeto) {
1823  if (dr < 0.1) tmpGammaIso_DR0p0To0p1 += iP->pt();
1824  if (dr >= 0.1 && dr < 0.2) tmpGammaIso_DR0p1To0p2 += iP->pt();
1825  if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += iP->pt();
1826  if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += iP->pt();
1827  if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += iP->pt();
1828  }
1829  }
1830  //NeutralHadron
1831  else {
1832  if (dr < 0.1) tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
1833  if (dr >= 0.1 && dr < 0.2) tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
1834  if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
1835  if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
1836  if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
1837  }
1838  } //loop over PF candidates
1839 
1841  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
1842  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
1843  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
1844  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
1845  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
1856  } else if (fMVAType == kTrigIDIsoCombined) {
1857  fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
1858  fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
1859  fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
1860  fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
1861  fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
1862  fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpGammaIso_DR0p0To0p1)/ele.pt(), 2.5), 0.0);
1863  fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpGammaIso_DR0p1To0p2)/ele.pt(), 2.5), 0.0);
1864  fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpGammaIso_DR0p2To0p3)/ele.pt(), 2.5), 0.0);
1865  fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpGammaIso_DR0p3To0p4)/ele.pt(), 2.5), 0.0);
1866  fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpGammaIso_DR0p4To0p5)/ele.pt(), 2.5), 0.0);
1867  fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1)/ele.pt(), 2.5), 0.0);
1868  fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2)/ele.pt(), 2.5), 0.0);
1869  fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3)/ele.pt(), 2.5), 0.0);
1870  fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4)/ele.pt(), 2.5), 0.0);
1871  fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5)/ele.pt(), 2.5), 0.0);
1872  fMVAVar_rho = Rho;
1873  } else {
1874  std::cout << "Warning: Type " << fMVAType << " is not supported.\n";
1875  }
1876 
1877  // evaluate
1878  Double_t mva = -9999;
1879  if (fUseBinnedVersion) {
1881  mva = fTMVAReader[bin]->EvaluateMVA(fTMVAMethod[bin]);
1882  } else {
1883  mva = fTMVAReader[0]->EvaluateMVA(fTMVAMethod[0]);
1884  }
1885 
1886 
1887 
1888  if(printDebug) {
1889  std::cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType <<std::endl;
1890  std::cout << " fbrem " << fMVAVar_fbrem
1891  << " kfchi2 " << fMVAVar_kfchi2
1892  << " mykfhits " << fMVAVar_kfhits
1893  << " gsfchi2 " << fMVAVar_gsfchi2
1894  << " deta " << fMVAVar_deta
1895  << " dphi " << fMVAVar_dphi
1896  << " detacalo " << fMVAVar_detacalo
1897  << " see " << fMVAVar_see
1898  << " spp " << fMVAVar_spp
1899  << " etawidth " << fMVAVar_etawidth
1900  << " phiwidth " << fMVAVar_phiwidth
1901  << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
1902  << " R9 " << fMVAVar_R9
1903  << " HoE " << fMVAVar_HoE
1904  << " EoP " << fMVAVar_EoP
1905  << " IoEmIoP " << fMVAVar_IoEmIoP
1906  << " eleEoPout " << fMVAVar_eleEoPout
1907  << " d0 " << fMVAVar_d0
1908  << " ip3d " << fMVAVar_ip3d
1909  << " eta " << fMVAVar_eta
1910  << " pt " << fMVAVar_pt <<std::endl;
1911  std::cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1916  << fMVAVar_ChargedIso_DR0p4To0p5 <<std::endl;
1917  std::cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1918  << fMVAVar_GammaIso_DR0p0To0p1 << " "
1919  << fMVAVar_GammaIso_DR0p1To0p2 << " "
1920  << fMVAVar_GammaIso_DR0p2To0p3 << " "
1921  << fMVAVar_GammaIso_DR0p3To0p4 << " "
1922  << fMVAVar_GammaIso_DR0p4To0p5 <<std::endl;
1923  std::cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
1929  <<std::endl;
1930  std::cout << "Rho : " << Rho <<std::endl;
1931  std::cout << " ### MVA " << mva <<std::endl;
1932  }
1933 
1934 
1935 
1936  return mva;
1937 }
1938 
1939 
1940 
1941 
1942 #endif
1943 
1945 
1946  // this binding is needed for variables that sometime diverge.
1947 
1948 
1949  if(fMVAVar_fbrem < -1.)
1950  fMVAVar_fbrem = -1.;
1951 
1952  fMVAVar_deta = fabs(fMVAVar_deta);
1953  if(fMVAVar_deta > 0.06)
1954  fMVAVar_deta = 0.06;
1955 
1956 
1957  fMVAVar_dphi = fabs(fMVAVar_dphi);
1958  if(fMVAVar_dphi > 0.6)
1959  fMVAVar_dphi = 0.6;
1960 
1961 
1962  if(fMVAVar_EoP > 20.)
1963  fMVAVar_EoP = 20.;
1964 
1965  if(fMVAVar_eleEoPout > 20.)
1966  fMVAVar_eleEoPout = 20.;
1967 
1968 
1970  if(fMVAVar_detacalo > 0.2)
1971  fMVAVar_detacalo = 0.2;
1972 
1973  if(fMVAVar_OneMinusE1x5E5x5 < -1.)
1975 
1976  if(fMVAVar_OneMinusE1x5E5x5 > 2.)
1978 
1979 
1980 
1981  if(fMVAVar_R9 > 5)
1982  fMVAVar_R9 = 5;
1983 
1984  if(fMVAVar_gsfchi2 > 200.)
1985  fMVAVar_gsfchi2 = 200;
1986 
1987 
1988  if(fMVAVar_kfchi2 > 10.)
1989  fMVAVar_kfchi2 = 10.;
1990 
1991 
1992  // Needed for a bug in CMSSW_420, fixed in more recent CMSSW versions
1993 #ifndef STANDALONE
1995 #else
1996  if(std::isnan(fMVAVar_spp))
1997 #endif
1998  fMVAVar_spp = 0.;
1999 
2000 
2001  return;
2002 }
2003 
2004 
2005 
2006 
2007 
2008 
2009 
2010 
float sigmaIphiIphi() const
Definition: GsfElectron.h:441
bool isAvailable() const
Definition: Ref.h:575
type
Definition: HCALResponse.h:21
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:205
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double eta() const final
momentum pseudorapidity
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
float full5x5_e5x5() const
Definition: GsfElectron.h:466
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
float full5x5_e1x5() const
Definition: GsfElectron.h:464
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:295
Double_t isoMvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, const reco::GsfElectronCollection &IdentifiedElectrons, const reco::MuonCollection &IdentifiedMuons, bool printDebug=kFALSE)
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
reco::TransientTrack build(const reco::Track *p) const
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
float full5x5_sigmaIphiIphi() const
Definition: GsfElectron.h:463
double pt() const final
transverse momentum
float fbrem() const
Definition: GsfElectron.h:772
T Min(T a, T b)
Definition: MathUtil.h:39
UInt_t GetMVABin(double eta, double pt) const
std::vector< TMVA::Reader * > fTMVAReader
constexpr bool isFinite(T x)
const Point & position() const
position
Definition: Vertex.h:109
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
float full5x5_sigmaIetaIeta() const
Definition: GsfElectron.h:462
Double_t IDIsoCombinedMvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, bool printDebug=kFALSE)
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
float sigmaIetaIeta() const
Definition: GsfElectron.h:440
float hadronicOverEm() const
Definition: GsfElectron.h:495
bool isnan(float x)
Definition: math.h:13
T sqrt(T t)
Definition: SSEVec.h:18
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
float eEleClusterOverPout() const
Definition: GsfElectron.h:252
T min(T a, T b)
Definition: MathUtil.h:58
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools myEcalCluster, bool printDebug=kFALSE)
bin
set the eta bin as selection string.
T Max(T a, T b)
Definition: MathUtil.h:44
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double p() const final
magnitude of momentum vector
float e1x5() const
Definition: GsfElectron.h:442
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...
float ecalEnergy() const
Definition: GsfElectron.h:859
float e5x5() const
Definition: GsfElectron.h:444
float full5x5_r9() const
Definition: GsfElectron.h:467
double dB(IPTYPE type) const
Impact parameter wrt primary vertex or beamspot.
float r9() const
Definition: GsfElectron.h:445
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:254
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
std::vector< TMVA::MethodBase * > fTMVAMethod
double phi() const final
momentum azimuthal angle
double edB(IPTYPE type) const
Uncertainty on the corresponding impact parameter.
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40