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