CMS 3D CMS Logo

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