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