ATLAS Offline Software
fbtTestToyMC.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //----------------------------------------------------------------------
6 //
7 // This program provides a toy MC model of a set of pseudoexperiments. It
8 // is intended to explore the statistical properties of the fake lepton
9 // background estimate for a given set of experiemental conditions (number
10 // of events, number of leptons required, typical values of the real and
11 // fake efficiencies, etc.)
12 //
13 //----------------------------------------------------------------------
14 
17 
20 
24 
25 #include "xAODEgamma/Electron.h"
26 #include "AthContainers/Accessor.h"
27 
28 #include "TFile.h"
29 #include "TTree.h"
30 #include "TH1F.h"
31 #include "TH2F.h"
32 #include "TRandom3.h"
33 #include "TSystem.h"
34 #include <getopt.h>
35 #include <unistd.h>
36 #include <map>
37 #include <chrono>
38 #include <fstream>
39 #include <memory>
40 
41 ANA_MSG_HEADER(Test)
42 ANA_MSG_SOURCE(Test, "fbtTestToyMC")
43 using namespace Test;
44 
46  unsigned nevents;
47  unsigned ncases;
48  unsigned minnbaseline;
49  unsigned maxnbaseline;
50  float realeff_mean;
51  float fakeeff_mean;
52  float eff_spread;
54  std::string selection;
55  std::string process;
56  bool test_save;
57  bool test_merge;
58  std::string saveFileNameBase;
59  std::string mergeFileNameBase;
60  std::string outputdirname;
61  bool verbose;
62  bool test_histo;
65 };
66 
67 using namespace FakeBkgTools;
68 using namespace std;
69 
70 
71 
73 TFile *rootEffFile;
74 
75 StatusCode initialize ATLAS_NOT_THREAD_SAFE(CP::BaseFakeBkgTool& tool, const std::vector<std::string>& input, const std::string& selection, const std::string& process, bool verbose);
76 StatusCode writeXML(const string& name, int type);
77 StatusCode writeROOT(const string& name, int type, float realeff_mean, float fakeeff_mean, float eff_spread, float eff_delta_with_pt);
78 StatusCode setupEfficiencies ATLAS_NOT_THREAD_SAFE();
79 StatusCode lookupEfficiencies ATLAS_NOT_THREAD_SAFE(xAOD::IParticle& lepton, ParticleData& lepton_data);
80 
82 StatusCode setupSystBranches(const char* baseName,
84  float &weight,
85  float &weight_err,
86  std::map<CP::SystematicVariation, float> &syst_map,
87  std::map<CP::SystematicVariation, float> &syst_err_map,
88  TTree* ntuple);
89 
90 StatusCode setupSystBranchesAsym(const char* baseName,
92  float &weight,
93  float &weight_poserr,
94  float &weight_negerr,
95  std::map<CP::SystematicVariation, float> &syst_map,
96  std::map<CP::SystematicVariation, float> &syst_poserr_map,
97  std::map<CP::SystematicVariation, float> &syst_negerr_map,
98  TTree* ntuple);
99 
100 std::unique_ptr<TFile> openRootFile(fbtTestToyMC_config &config);
101 
102 StatusCode doMerge ATLAS_NOT_THREAD_SAFE( const std::vector<std::string> & input, const std::string & name, fbtTestToyMC_config &config, TH1F* h_lep_pt, float &lep_pt, TH1F* h_lep_eta, float &lep_eta, TH2F* h_lep_pt_eta, float &fakes, float &poserr, float &negerr, int icase);
103 
105 
106 double comboProb(const vector<FakeBkgTools::ParticleData> & leptons_data, const std::bitset<64> & tights, const std::bitset<64> &reals) ;
107 
108 StatusCode usage();
109 
111 double err_std;
115 
117 
119 
120 //additional variables that don't correspond to Tree branches
121 
122 Double_t n_fake_lhood;
123 
126 
127 std::ofstream *f_stdneg_lhood_pos;
128 std::ofstream *f_stdpos_lhood_0;
129 
130 const int nSave = 4; // number of subjobs to split into when testing saveProgress
131 
133  ANA_CHECK_SET_TYPE (int);
134 
136 
137  // defaults
138  config.nevents = 100;
139  config.ncases = 100;
140  config.realeff_mean = 0.90;
141  config.fakeeff_mean = 0.20;
142  config.eff_spread = 0.10;
143  config.eff_delta_with_pt = 0.;
144  config.minnbaseline = 1;
145  config.maxnbaseline = 4;
146  config.test_save = false;
147  config.saveFileNameBase = "saveProgress";
148  config.mergeFileNameBase = "saveProgress";
149  config.test_merge = false;
150  config.test_histo = false;
151  config.test_systematics = false;
152  config.poisson_fluctuations = false;
153  config.verbose = false;
154  config.selection = ">=1T";
155  config.process = ">=1F[T]";
156 
157  if (config.verbose) cout << "maxnbaseline = " << config.maxnbaseline << endl;
158 
159  ANA_CHECK( parseArguments(argc, argv, config) );
160 
161  ANA_CHECK( Loop(config) );
162 }
163 
165 
166  //Open an output file
167  if (config.verbose) cout << "maxnbaseline = " << config.maxnbaseline << endl;
168 
169  std::unique_ptr<TFile> f_out = openRootFile(config);
170 
171  int nevents_thiscase;
172 
173  // create output ntuple
174  TTree *ntuple = new TTree("FakeBkg", "Variables from toy MC");
175  ntuple->Branch("nevents", &nevents_thiscase, "nevents/I");
176  Int_t nevents_sel;
177  ntuple->Branch("nevents_sel", &nevents_sel, "nevents_sel/I");
178  Float_t fake_lep_frac;
179  ntuple->Branch("fake_lep_frac", &fake_lep_frac, "fake_lep_frac/F");
180  Float_t true_fakes;
181  ntuple->Branch("true_fakes", &true_fakes,"true_fakes/F");
182  Float_t asm_fakes;
183  ntuple->Branch("asm_fakes", &asm_fakes,"asm_fakes/F");
184  Float_t asm_err;
185  ntuple->Branch("asm_err", &asm_err,"asm_err/F");
186  Float_t fkf_fakes;
187  ntuple->Branch("fkf_fakes", &fkf_fakes,"fkf_fakes/F");
188  Float_t fkf_err;
189  ntuple->Branch("fkf_err", &fkf_err,"fkf_err/F");
190  Float_t lhoodMM_fakes;
191  ntuple->Branch("lhoodMM_fakes", &lhoodMM_fakes,"lhoodMM_fakes/F");
192  Float_t lhoodMM_poserr;
193  ntuple->Branch("lhoodMM_poserr", &lhoodMM_poserr,"lhoodMM_poserr/F");
194  Float_t lhoodMM_negerr;
195  ntuple->Branch("lhoodMM_negerr", &lhoodMM_negerr,"lhoodMM_negerr/F");
196  Float_t lhoodFF_fakes;
197  ntuple->Branch("lhoodFF_fakes", &lhoodFF_fakes,"lhoodFF_fakes/F");
198  Float_t lhoodFF_poserr;
199  ntuple->Branch("lhoodFF_poserr", &lhoodFF_poserr,"lhoodFF_poserr/F");
200  Float_t lhoodFF_negerr;
201  ntuple->Branch("lhoodFF_negerr", &lhoodFF_negerr,"lhoodFF_negerr/F");
202 
203 
204  map<CP::SystematicVariation,float> lhoodMM_weight_map, lhoodMM_poserr_map, lhoodMM_negerr_map;
205  map<CP::SystematicVariation,float> lhoodFF_weight_map, lhoodFF_poserr_map, lhoodFF_negerr_map;
206  map<CP::SystematicVariation,float> asm_weight_map, asm_err_map;
207  map<CP::SystematicVariation,float> fkf_weight_map, fkf_err_map;
208 
209  TRandom3 rand(242868252);
210 
211  Double_t realeff_spread = config.eff_spread;
212  Double_t fakeeff_spread = config.eff_spread;
213 
214  std::vector<bool> isTight;
215  std::vector<std::string> input = { config.outputdirname+"efficiencies_full" };
216 
217  if(false) // switch to test either XML or ROOT input
218  {
219  // not implemented yet!
220  // input.back().append(".xml");
221  // writeXML(input.back(), 0);
222  }
223  else
224  {
225  input.back().append(".root");
226  ANA_CHECK( writeROOT(input.back(), 0, config.realeff_mean, config.fakeeff_mean, config.eff_spread, config.eff_delta_with_pt) );
227  rootEffFileName = input.back();
228  ANA_CHECK( setupEfficiencies() );
229  }
230 
231 
232  for (unsigned icase(0); icase < config.ncases; icase++) {
233  nevents_sel = 0;
234 
235  TH1F* h_lep_pt_lhoodMM = 0;
236  TH1F* h_lep_eta_lhoodMM = 0;
237  TH2F* h_lep_pt_eta_lhoodMM = 0;
238  TH1F* h_lep_pt_lhoodFF = 0;
239  TH1F* h_lep_eta_lhoodFF = 0;
240  TH2F* h_lep_pt_eta_lhoodFF = 0;
241  TH1F* h_lep_pt_asm = 0;
242  TH1F* h_lep_eta_asm = 0;
243  TH2F* h_lep_pt_eta_asm = 0;
244  TH1F* h_lep_pt_fkf = 0;
245  TH1F* h_lep_eta_fkf = 0;
246  TH2F* h_lep_pt_eta_fkf = 0;
247 
248  if (config.test_histo) {
249  std::string hname = "lep_pt_lhoodMM_"+to_string(icase);
250  h_lep_pt_lhoodMM = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
251  hname = "lep_eta_lhoodMM_"+to_string(icase);
252  h_lep_eta_lhoodMM = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
253  hname = "lep_pt_eta_lhoodMM_"+to_string(icase);
254  h_lep_pt_eta_lhoodMM = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
255  hname = "lep_pt_lhoodFF_"+to_string(icase);
256  h_lep_pt_lhoodFF = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
257  hname = "lep_eta_lhoodFF_"+to_string(icase);
258  h_lep_eta_lhoodFF = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
259  hname = "lep_pt_eta_lhoodFF_"+to_string(icase);
260  h_lep_pt_eta_lhoodFF = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
261  hname = "lep_pt_asm_"+to_string(icase);
262  h_lep_pt_asm = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
263  hname = "lep_eta_asm_"+to_string(icase);
264  h_lep_eta_asm = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
265  hname = "lep_pt_eta_asm_"+to_string(icase);
266  h_lep_pt_eta_asm = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
267  hname = "lep_pt_fkf_"+to_string(icase);
268  h_lep_pt_fkf = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
269  hname = "lep_eta_fkf_"+to_string(icase);
270  h_lep_eta_fkf = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
271  hname = "lep_pt_eta_fkf_"+to_string(icase);
272  h_lep_pt_eta_fkf = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
273  }
274 
275  float lep_pt, lep_eta;
276 
277  if (!config.test_merge) {
278 
279  cout << "Starting case " << icase << endl;
280  CP::LhoodMM_tools lhmTool("LhoodMM_tools");
281  // arrays of tool instances to test saveProgress
282  std::vector<CP::LhoodMM_tools*> lhmTool_sav;
283  CP::LhoodMM_tools lhmTool_FF("LhoodFF_tools");
284  std::vector<CP::LhoodMM_tools*> lhmTool_FF_sav;
285  CP::AsymptMatrixTool asmTool("AsymptMatrixTool");
286  std::vector<CP::AsymptMatrixTool*> asmTool_sav;
287  CP::ApplyFakeFactor fkfTool("fkfTool");
288  std::vector<CP::ApplyFakeFactor*> fkfTool_sav;
289 
290  float asmYield(0);
291  float asmErr(0);
292  float fkfYield (0);
293  float fkfErr(0);
294  if (config.test_histo) {
295  ANA_CHECK( lhmTool.register1DHistogram(h_lep_pt_lhoodMM, &lep_pt) );
296  ANA_CHECK( lhmTool.register1DHistogram(h_lep_eta_lhoodMM, &lep_eta) );
297  ANA_CHECK( lhmTool.register2DHistogram(h_lep_pt_eta_lhoodMM, &lep_pt, &lep_eta) );
298  ANA_CHECK( lhmTool_FF.register1DHistogram(h_lep_pt_lhoodFF, &lep_pt) );
299  ANA_CHECK( lhmTool_FF.register1DHistogram(h_lep_eta_lhoodFF, &lep_eta) );
300  ANA_CHECK( lhmTool_FF.register2DHistogram(h_lep_pt_eta_lhoodFF, &lep_pt, &lep_eta) );
301  ANA_CHECK( fkfTool.register1DHistogram(h_lep_pt_fkf, &lep_pt) );
302  ANA_CHECK( fkfTool.register1DHistogram(h_lep_eta_fkf, &lep_eta) );
303  ANA_CHECK( fkfTool.register2DHistogram(h_lep_pt_eta_fkf, &lep_pt, &lep_eta) );
304  ANA_CHECK( asmTool.register1DHistogram(h_lep_pt_asm, &lep_pt) );
305  ANA_CHECK( asmTool.register1DHistogram(h_lep_eta_asm, &lep_eta) );
306  ANA_CHECK( asmTool.register2DHistogram(h_lep_pt_eta_asm, &lep_pt, &lep_eta) );
307  }
308 
309  ANA_CHECK( initialize(asmTool, input, config.selection, config.process, config.verbose) );
310  ANA_CHECK( initialize(lhmTool, input, config.selection, config.process, config.verbose) );
311  ANA_CHECK( initialize(lhmTool_FF, input, config.selection, config.process, config.verbose) );
312  ANA_CHECK( lhmTool_FF.setProperty("DoFakeFactorFit", true) );
313 
314  ANA_CHECK( initialize(fkfTool, input, config.selection, config.process, config.verbose) );
315 
316  if (config.test_save) {
317  for (int iSave = 0; iSave <= nSave; iSave++) {
318  std:: string toolName = "LhoodMM_tools_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
319  CP::LhoodMM_tools *lhmTool_is = new CP::LhoodMM_tools(toolName.c_str());
320  lhmTool_sav.push_back(lhmTool_is);
321  ANA_CHECK( initialize(*lhmTool_sav[iSave], input, config.selection, config.process, config.verbose) );
322  if (config.test_histo) {
323  ANA_CHECK( lhmTool_is->register1DHistogram(h_lep_pt_lhoodMM, &lep_pt) );
324  ANA_CHECK( lhmTool_is->register1DHistogram(h_lep_eta_lhoodMM, &lep_eta) );
325  ANA_CHECK( lhmTool_is->register2DHistogram(h_lep_pt_eta_lhoodMM, &lep_pt, &lep_eta) );
326  }
327  toolName = "LhoodMM_tools_FF_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
328  CP::LhoodMM_tools *lhmTool_FF_is = new CP::LhoodMM_tools(toolName.c_str());
329  lhmTool_FF_sav.push_back(lhmTool_FF_is);
330  ANA_CHECK( initialize(*lhmTool_FF_sav[iSave], input, config.selection, config.process, config.verbose) );
331  ANA_CHECK( lhmTool_FF_sav[iSave]->setProperty("DoFakeFactorFit", true) );
332  if (config.test_histo) {
333  ANA_CHECK( lhmTool_FF_is->register1DHistogram(h_lep_pt_lhoodFF, &lep_pt) );
334  ANA_CHECK( lhmTool_FF_is->register1DHistogram(h_lep_eta_lhoodFF, &lep_eta) );
335  ANA_CHECK( lhmTool_FF_is->register2DHistogram(h_lep_pt_eta_lhoodFF, &lep_pt, &lep_eta) );
336  }
337 
338  toolName = "AsymptMatrixTool_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
339  CP::AsymptMatrixTool *asmTool_is = new CP::AsymptMatrixTool(toolName.c_str()); if (config.test_histo) {
340  ANA_CHECK( asmTool_is->register1DHistogram(h_lep_pt_asm, &lep_pt) );
341  ANA_CHECK( asmTool_is->register1DHistogram(h_lep_eta_asm, &lep_eta) );
342  ANA_CHECK( asmTool_is->register2DHistogram(h_lep_pt_eta_asm, &lep_pt, &lep_eta) );
343  }
344  asmTool_sav.push_back(asmTool_is);
345  ANA_CHECK( initialize(*asmTool_sav[iSave], input, config.selection, config.process, config.verbose) );
346 
347  toolName = "ApplyFakeFactor_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
348  CP::ApplyFakeFactor *fkfTool_is = new CP::ApplyFakeFactor(toolName.c_str());
349  fkfTool_sav.push_back(fkfTool_is);
350  ANA_CHECK( initialize(*fkfTool_sav[iSave], input, config.selection, config.process, config.verbose) );
351  if (config.test_histo) {
352  ANA_CHECK( fkfTool_is->register1DHistogram(h_lep_pt_fkf, &lep_pt) );
353  ANA_CHECK( fkfTool_is->register1DHistogram(h_lep_eta_fkf, &lep_eta) );
354  ANA_CHECK( fkfTool_is->register2DHistogram(h_lep_pt_eta_fkf, &lep_pt, &lep_eta) );
355  }
356  }
357  }
358 
359 
360  Double_t realeff_mean_thiscase = rand.Gaus(config.realeff_mean, realeff_spread);
361  if (realeff_mean_thiscase > 0.99) realeff_mean_thiscase = 0.99;
362  Double_t fakeeff_mean_thiscase = rand.Gaus(config.fakeeff_mean, fakeeff_spread);
363  if (fakeeff_mean_thiscase < 0.01) fakeeff_mean_thiscase = 0.01;
364  if (fakeeff_mean_thiscase > realeff_mean_thiscase) fakeeff_mean_thiscase = realeff_mean_thiscase-0.01;
365 
366  fake_lep_frac = rand.Uniform(); // fraction of fake leptons in the loose sample
367 
368  totWeight_std = 0.;
369  err_std = 0;
370  n_fake_lhood = 0.;
373 
374  std::vector<LhoodMMEvent> mmevts;
375 
376  true_fakes = 0;
377 
378  std::vector<double> realeff, fakeeff;
379 
380  vector<FinalState*> fs;
381  FinalState* this_fs(0);
382  for (unsigned ilep(0); ilep <= config.maxnbaseline; ilep++) {
383  string error;
384  this_fs = new FinalState(0, ilep, config.selection, config.process, error);
385  fs.push_back(this_fs);
386  }
387 
388  if (config.poisson_fluctuations) {
389  nevents_thiscase = rand.Poisson(config.nevents);
390  } else {
391  nevents_thiscase = config.nevents;
392  }
393 
394  static const SG::Accessor<char> TightAcc("Tight");
395 
396  // need two passes to simulate subtraction of real lepton contribution
397  // in fake factor method with a statistically-independent sample
398  for (int pass(0); pass<2; pass++) {
399  int savIndex(0);
400 
401 
402  int nEventsMultFactor = 1;
403  if (pass > 0) nEventsMultFactor = 10; // simulates higher-stats "MC" for removal of real contribution to fake factor result
404  for (Long64_t ievt(0); ievt<nevents_thiscase*nEventsMultFactor; ievt++) {
405 
406  float nlep_frac = 1./(config.maxnbaseline-config.minnbaseline+1);
407  Int_t nlep_select = config.minnbaseline+rand.Uniform()/nlep_frac;
408 
409  float extraweight(1.0);
410 
411  realeff.clear();
412  fakeeff.clear();
413 
415  vector<FakeBkgTools::ParticleData> leptons_data;
416 
417  vector<bool> lep_real;
418 
419  // set up an ordered vector of lepton pts
420  vector<float> lep_pts;
421  for (int ilep(0); ilep < nlep_select; ilep++) {
422  lep_pts.push_back(100*rand.Uniform());
423  }
424  // sort in descending order
425  sort(lep_pts.begin(), lep_pts.end(), std::greater<float>());
426 
427  for (int ilep(0); ilep < nlep_select; ilep++) {
428  xAOD::Electron* lepton = new xAOD::Electron; // for toy MC the lepton flavor doesn't matter
429  // assign the lepton as real or fake
430  bool isReal(false);
431  if (rand.Uniform() > fake_lep_frac) {
432  isReal = true;
433  } else {
434  isReal = false;
435  }
436 
437  lep_real.push_back(isReal);
438  lepton->makePrivateStore();
439  lepton->setCharge(rand.Uniform() > 0.5 ? 1 : -1 );
440 
441  lep_pt = lep_pts[ilep];
442  lep_eta = -5. + 10*rand.Uniform();
443  lepton->setP4( 1000*lep_pt, lep_eta, 0, 0.511);
444 
445  FakeBkgTools::ParticleData lepton_data;
446  ANA_CHECK( lookupEfficiencies(*lepton, lepton_data) );
447  // decide if lepton is tight or not
448  if (isReal) {
449  if (rand.Uniform() < lepton_data.real_efficiency.nominal) {
450  TightAcc(*lepton) = true;
451  } else {
452  TightAcc(*lepton) = false;
453  }
454  } else {
455  if (rand.Uniform() < lepton_data.fake_efficiency.nominal) {
456  TightAcc(*lepton) = true;
457  } else {
458  TightAcc(*lepton) = false;
459  }
460  }
461  leptons.push_back(static_cast<xAOD::IParticle*>(lepton));
462 
463  leptons_data.push_back(lepton_data);
464  }
465 
466  if (pass == 0) {
467  ANA_CHECK( asmTool.addEvent(leptons, extraweight) );
468  ANA_CHECK( fkfTool.addEvent(leptons, extraweight) );
469  ANA_CHECK( lhmTool.addEvent(leptons, extraweight) );
470  ANA_CHECK( lhmTool_FF.addEvent(leptons, extraweight) );
471  if (config.test_save) {
472  ANA_CHECK( lhmTool_sav[savIndex]->addEvent(leptons, extraweight) );
473  ANA_CHECK( lhmTool_FF_sav[savIndex]->addEvent(leptons, extraweight) );
474  ANA_CHECK( asmTool_sav[savIndex]->addEvent(leptons, extraweight) );
475  ANA_CHECK( fkfTool_sav[savIndex]->addEvent(leptons, extraweight) );
476  }
477 
478  }
479 
480  bool all_real(true);
481  if (pass == 1) {
482  for (int ilep(0); ilep < nlep_select; ilep++) {
483  if (!lep_real[ilep]) {
484  all_real = false;
485  }
486  }
487  }
488 
489  // fkfTool.addEvent(leptons, extraweight);
490  if (pass == 1 && all_real) {
491  ANA_CHECK( fkfTool.addEvent(leptons, -extraweight/nEventsMultFactor) );
492  // probably not the fully correct way to do it for the LhoodMM,
493  // but might be close enough
494  ANA_CHECK( lhmTool_FF.addEvent(leptons, -extraweight/nEventsMultFactor) );
495 
496  if (config.test_save) {
497  ANA_CHECK( fkfTool_sav[savIndex]->addEvent(leptons, -extraweight/nEventsMultFactor) );
498  ANA_CHECK( lhmTool_FF_sav[savIndex]->addEvent(leptons, -extraweight/nEventsMultFactor) );
499  }
500  }
501 
502  // determine the expected number of fake lepton events
503  // start by looping over all possible number of tight leptons
504  vector<int> lep_indices;
505  std::bitset<64> tights, reals, charges;
506  for (int ilep(0); ilep < nlep_select; ilep++) {
507  lep_indices.push_back(ilep);
508  if (lep_real[ilep]) reals.set(ilep);
509  }
510 
511  if (pass == 0) {
512  for (long comb(0); comb < (1<<nlep_select); ++comb) {
513  tights = std::bitset<64>(comb);
514  if (fs[nlep_select]->accept_selection(tights, charges)) {
515  if (fs[nlep_select]->accept_process(nlep_select, reals, tights)) {
516  true_fakes += extraweight*comboProb(leptons_data, tights, reals);
517  }
518  }
519  }
520  // now see how many events actually passed the required selection
521  tights.reset();
522  for (int ilep = 0; ilep < nlep_select; ilep++) {
523  if (TightAcc(*leptons[ilep])) tights.set(ilep);
524  }
525  if (fs[nlep_select]->accept_selection(tights,charges) ) {
526  nevents_sel += extraweight;
527  }
528 
529  float wgt(1.);
530  ANA_CHECK( asmTool.getEventWeight(wgt, config.selection, config.process) );
531  asmYield += wgt;
532  asmErr += wgt*wgt;
533 
534  ANA_CHECK( fkfTool.getEventWeight(wgt, config.selection, config.process) );
535  fkfYield += wgt;
536  fkfErr += wgt*wgt;
537  } else {
538  // this is where the subtraction of the real contribution is simulated
539  if (all_real) {
540  float wgt(1.0);
541  ANA_CHECK( fkfTool.getEventWeight(wgt, config.selection, config.process) );
542  fkfYield -= wgt/nEventsMultFactor;
543  fkfErr += wgt*wgt/(nEventsMultFactor);
544  }
545  }
546 
547  if (config.test_save) {
548  if (pass == 0) {
549  if (ievt > 0 && (((nSave*ievt)%nevents_thiscase ==0) || ievt == nevents_thiscase -1) ) {
550  string saveFileName = config.saveFileNameBase;
551  saveFileName+= "_lhm_"+to_string(icase)+"_"+to_string(savIndex)+".root";
552  std::unique_ptr<TFile> saveFile(TFile::Open(saveFileName.c_str(), "RECREATE"));
553  ANA_CHECK( lhmTool_sav[savIndex]->saveProgress(saveFile->mkdir("fakes")) );
554  saveFile->Close();
555 
556  saveFileName = config.saveFileNameBase+"_asm_"+to_string(icase)+"_"+to_string(savIndex)+".root";
557  saveFile = std::make_unique<TFile>(saveFileName.c_str(), "RECREATE");
558  ANA_CHECK( asmTool_sav[savIndex]->saveProgress(saveFile.get()) );
559  saveFile->Close();
560 
561  savIndex++;
562  }
563  } else {
564  if (ievt > 0 && (((nSave*ievt)%(nevents_thiscase*nEventsMultFactor) ==0) || ievt == nevents_thiscase*nEventsMultFactor -1) ) {
565  string saveFileName = config.saveFileNameBase;
566 
567  saveFileName = config.saveFileNameBase+"_lhf_"+to_string(icase)+"_"+to_string(savIndex)+".root";
568  std::unique_ptr<TFile> saveFile(TFile::Open(saveFileName.c_str(), "RECREATE"));
569  ANA_CHECK( lhmTool_FF_sav[savIndex]->saveProgress(saveFile->mkdir("fakes")) );
570  saveFile->Close();
571 
572  saveFileName = config.saveFileNameBase+"_fkf_"+to_string(icase)+"_"+to_string(savIndex)+".root";
573  saveFile = std::make_unique<TFile>(saveFileName.c_str(), "RECREATE");
574  ANA_CHECK( fkfTool_sav[savIndex]->saveProgress(saveFile.get()) );
575  saveFile->Close();
576  savIndex++;
577 
578  float nfakes_tmp(0), err_tmp(0);
579  ANA_CHECK( fkfTool.getTotalYield(nfakes_tmp, err_tmp, err_tmp) );;
580  }
581  }
582  }
583 
584  for (xAOD::IParticleContainer::iterator it = leptons.begin(); it != leptons.end(); ++it) {
585  if (*it != nullptr) delete *it;
586  }
587  leptons.clear();
588  }
589  }
590  asm_err = sqrt(asmErr);
591  asm_fakes = asmYield;
592  ANA_CHECK( asmTool.getTotalYield(asmYield, asmErr, asmErr) );
593 
594 
595  ANA_CHECK( lhmTool.getTotalYield(lhoodMM_fakes, lhoodMM_poserr, lhoodMM_negerr) );
596 
597  ANA_CHECK( lhmTool_FF.getTotalYield(lhoodFF_fakes, lhoodFF_poserr, lhoodFF_negerr) );
598 
599  ANA_CHECK( fkfTool.getTotalYield(fkfYield, fkfErr, fkfErr) );
600  fkf_err = fkfErr;
601  fkf_fakes = fkfYield;
602 
603  if (config.test_systematics) {
604  auto sysvars = asmTool.affectingSystematics();
605  std::string systBrName, systBrNameF;
606 
607  for(auto& sysvar : sysvars){
608  if (config.verbose) asmTool.getSystDescriptor().printUncertaintyDescription(sysvar);
609 
610  float asm_syst_weight, asm_syst_err;
611  float fkf_syst_weight, fkf_syst_err;
612  float lhoodMM_syst_weight, lhoodMM_syst_poserr, lhoodMM_syst_negerr;
613  float lhoodFF_syst_weight, lhoodFF_syst_poserr, lhoodFF_syst_negerr;
614 
615  if (icase == 0) {
616  ANA_CHECK( setupSystBranches("asm", sysvar, asm_syst_weight, asm_syst_err, asm_weight_map, asm_err_map, ntuple) );
617  ANA_CHECK( setupSystBranches("fkf", sysvar, fkf_syst_weight, fkf_syst_err, fkf_weight_map, fkf_err_map, ntuple) );;
618  ANA_CHECK( setupSystBranchesAsym("lhoodMM", sysvar, lhoodMM_syst_weight, lhoodMM_syst_poserr, lhoodMM_syst_negerr, lhoodMM_weight_map, lhoodMM_poserr_map, lhoodMM_negerr_map, ntuple) );
619  ANA_CHECK( setupSystBranchesAsym("lhoodFF", sysvar, lhoodFF_syst_weight, lhoodFF_syst_poserr, lhoodFF_syst_negerr, lhoodFF_weight_map, lhoodFF_poserr_map, lhoodFF_negerr_map, ntuple) );
620  }
621  ANA_CHECK( asmTool.applySystematicVariation({sysvar}) );
622  ANA_CHECK( asmTool.getTotalYield(asm_weight_map.find(sysvar)->second,
623  asm_err_map.find(sysvar)->second,
624  asm_err_map.find(sysvar)->second));
625 
626  ANA_CHECK( fkfTool.applySystematicVariation({sysvar}) );;
627  ANA_CHECK( fkfTool.getTotalYield(fkf_weight_map.find(sysvar)->second,
628  fkf_err_map.find(sysvar)->second,
629  fkf_err_map.find(sysvar)->second) );
630  ANA_CHECK( lhmTool.applySystematicVariation({sysvar}) );;
631  ANA_CHECK( lhmTool.getTotalYield(lhoodMM_weight_map.find(sysvar)->second,
632  lhoodMM_poserr_map.find(sysvar)->second,
633  lhoodMM_negerr_map.find(sysvar)->second) );
634  ANA_CHECK( lhmTool_FF.applySystematicVariation({sysvar}) );;
635  ANA_CHECK( lhmTool_FF.getTotalYield(lhoodFF_weight_map.find(sysvar)->second,
636  lhoodFF_poserr_map.find(sysvar)->second,
637  lhoodFF_negerr_map.find(sysvar)->second) );
638  }
639  }
640 
641 
642  cout << "OUTPUT true_fakes = " << true_fakes << endl;
643  cout << "OUTPUT nfakes for lhoodMM = " << lhoodMM_fakes << " +" << lhoodMM_poserr << " -" << lhoodMM_negerr << endl;
644  cout << "OUTPUT nfakes for lhoodFF = " << lhoodFF_fakes << " +" << lhoodFF_poserr << " -" << lhoodFF_negerr << endl;
645  cout << "OUTPUT nfakes for asm = " << asm_fakes << " +- " << asm_err << endl;
646  cout << "OUTPUT nfakes for fkf = " << fkf_fakes << " +- " << fkf_err << endl;
647  cout << "OUTPUT true_fakes = " << true_fakes << endl;
648  } else {
649 
650  ANA_CHECK( doMerge(input, "lhm", config, h_lep_pt_lhoodMM, lep_pt, h_lep_eta_lhoodMM, lep_eta, h_lep_pt_eta_lhoodMM, lhoodMM_fakes, lhoodMM_poserr, lhoodMM_negerr, icase) );
651  ANA_CHECK( doMerge(input, "lhf", config, h_lep_pt_lhoodFF, lep_pt, h_lep_eta_lhoodFF, lep_eta, h_lep_pt_eta_lhoodFF, lhoodFF_fakes, lhoodFF_poserr, lhoodFF_negerr, icase) );
652  ANA_CHECK( doMerge(input, "asm", config, h_lep_pt_asm, lep_pt, h_lep_eta_asm, lep_eta, h_lep_pt_eta_asm, asm_fakes, asm_err, asm_err, icase) );
653  ANA_CHECK( doMerge(input, "fkf", config, h_lep_pt_fkf, lep_pt, h_lep_eta_fkf, lep_eta, h_lep_pt_eta_fkf, fkf_fakes, fkf_err, fkf_err, icase) );
654  }
655 
656  ntuple->Fill();
657 
658  f_out->cd();
659  if (config.test_histo) {
660  h_lep_pt_lhoodMM->Write();
661  h_lep_eta_lhoodMM->Write();
662  h_lep_pt_eta_lhoodMM->Write();
663  h_lep_pt_lhoodFF->Write();
664  h_lep_eta_lhoodFF->Write();
665  h_lep_pt_eta_lhoodFF->Write();
666  h_lep_pt_asm->Write();
667  h_lep_eta_asm->Write();
668  h_lep_pt_eta_asm->Write();
669  h_lep_pt_fkf->Write();
670  h_lep_eta_fkf->Write();
671  h_lep_pt_eta_fkf->Write();
672 
673  delete h_lep_pt_lhoodMM;
674  delete h_lep_eta_lhoodMM;
675  delete h_lep_pt_eta_lhoodMM;
676  delete h_lep_pt_lhoodFF;
677  delete h_lep_eta_lhoodFF;
678  delete h_lep_pt_eta_lhoodFF;
679  delete h_lep_pt_asm;
680  delete h_lep_eta_asm;
681  delete h_lep_pt_eta_asm;
682  delete h_lep_pt_fkf;
683  delete h_lep_eta_fkf;
684  delete h_lep_pt_eta_fkf;
685 
686 
687  }
688  }
689 
690  f_out->Write();
691  f_out->Close();
692 
693  return StatusCode::SUCCESS;
694 }
695 
696 StatusCode writeROOT(const string& name, int type, float realeff_mean, float fakeeff_mean, float eff_spread, float eff_delta_with_pt){
697  TRandom3 rnd(235789);
698 
699  int nbin = 100;
700 
701  std::unique_ptr<TFile> file(TFile::Open(name.c_str(), "RECREATE"));
702 
703  if(type == 0)
704  {
705  TH1D hElFake("FakeEfficiency_el_pt","FakeEfficiency_el_pt", nbin, 0., 1.*nbin);
706  TH1D hMuFake("FakeEfficiency_mu_pt","FakeEfficiency_mu_pt", nbin, 0., 1.*nbin);
707  TH1D hElReal("RealEfficiency_el_pt","RealEfficiency_el_pt", nbin, 0., 1.*nbin);
708  TH1D hMuReal("RealEfficiency_mu_pt","RealEfficiency_mu_pt", nbin, 0., 1.*nbin);
709 
710  TH1D hElFake_bigSyst("FakeEfficiency_el_pt__bigSyst","FakeEfficiency_el_pt__bigSyst", nbin, 0., 1.*nbin);
711  TH1D hElFake_smallSyst("FakeEfficiency_el_pt__smallSyst","FakeEfficiency_el_pt__smallSyst", nbin, 0., 1.*nbin);
712  TH1D hMuFake_bigSyst("FakeEfficiency_mu_pt__bigSyst","FakeEfficiency_mu_pt__bigSyst", nbin, 0., 1.*nbin);
713  TH1D hMuFake_smallSyst("FakeEfficiency_mu_pt__smallSyst","FakeEfficiency_mu_pt__smallSyst", nbin, 0., 1.*nbin);
714  TH1D hElReal_bigSyst("RealEfficiency_el_pt__bigSyst","RealEfficiency_el_pt__bigSyst", nbin, 0., 1.*nbin);
715  TH1D hMuReal_bigSyst("RealEfficiency_mu_pt__bigSyst","RealEfficiency_mu_pt__bigSyst", nbin, 0., 1.*nbin);
716 
717  for (int ibin = 1; ibin <= nbin; ibin++) {
718  Double_t realeff = TMath::Min(rnd.Gaus(realeff_mean, eff_spread)+eff_delta_with_pt*(ibin-nbin/2), 0.99);
719  Double_t fakeeff = TMath::Max(rnd.Gaus(fakeeff_mean, eff_spread)-eff_delta_with_pt*(ibin-nbin/2), 0.01);
720 
721  float minrfdiff = 0.10;
722  if (realeff - fakeeff < minrfdiff) {
723  if (realeff > minrfdiff) {
724  fakeeff = realeff - minrfdiff;
725  } else {
726  realeff = realeff + 0.10;
727  }
728  }
729 
730  // sanity checks on the efficiencies
731  if (realeff < 0 || realeff > 1.) cout << "ERROR: Bad real efficiency value: " << realeff << endl;
732  if (fakeeff < 0 || fakeeff > 1.) cout << "ERROR: Bad fake efficiency value: " << fakeeff << endl;
733  if ((realeff - fakeeff) < minrfdiff) cout << "ERROR: Too small difference between real and fake efficiencies: " << realeff << " " << fakeeff << endl;
734 
735  hElFake.SetBinContent(ibin, fakeeff);
736  hElFake.SetBinError(ibin, eff_spread);
737  //hElFake.SetBinError(ibin, 0.);
738  hMuFake.SetBinContent(ibin, fakeeff);
739  hMuFake.SetBinError(ibin, eff_spread);
740  //hMuFake.SetBinError(ibin, 0.);
741  hElReal.SetBinContent(ibin, realeff);
742  hElReal.SetBinError(ibin, eff_spread);
743  //hElReal.SetBinError(ibin, 0.);
744  hMuReal.SetBinContent(ibin, realeff);
745  hMuReal.SetBinError(ibin, eff_spread);
746  //hMuReal.SetBinError(ibin, 0.);
747 
748  hElFake_bigSyst.SetBinContent(ibin, 0.20*hElFake.GetBinContent(ibin));
749  hElFake_smallSyst.SetBinContent(ibin, 0.02*hElFake.GetBinContent(ibin));
750  hMuFake_bigSyst.SetBinContent(ibin, 0.20*hMuFake.GetBinContent(ibin));
751  hMuFake_smallSyst.SetBinContent(ibin, 0.02*hMuFake.GetBinContent(ibin));
752  hElReal_bigSyst.SetBinContent(ibin, 0.20*hElReal.GetBinContent(ibin));
753  hMuReal_bigSyst.SetBinContent(ibin, 0.20*hMuReal.GetBinContent(ibin));
754 
755  }
756 
757  file->cd();
758  hElFake.Write();
759  hElReal.Write();
760  hMuFake.Write();
761  hMuReal.Write();
762  hElFake_bigSyst.Write();
763  hElReal_bigSyst.Write();
764  hElFake_smallSyst.Write();
765  hMuFake_bigSyst.Write();
766  hMuFake_smallSyst.Write();
767  hMuReal_bigSyst.Write();
768  }
769  file->Close();
770  return StatusCode::SUCCESS;
771 }
772 
774  static struct option long_options[] =
775  {
776  {"ncases", required_argument, 0, 'c'},
777  {"nevents", required_argument, 0, 'e'},
778  {"minnb", required_argument, 0, 'm'},
779  {"maxnb", required_argument, 0, 'n'},
780  {"rmean", required_argument, 0, 'r'},
781  {"fmean", required_argument, 0, 'f'},
782  {"effsigma", required_argument, 0, 's'},
783  {"effdeltawithpt", required_argument, 0, 'd'},
784  {"sel", required_argument, 0, 'l'},
785  {"proc", required_argument, 0, 'p'},
786  {"test_save", no_argument, 0, 'S'},
787  {"test_merge", required_argument, 0, 'M'},
788  {"test_histo", required_argument, 0, 'H'},
789  {"test_systematics", no_argument, 0, 'E'},
790  {"verbose", no_argument, 0, 'v'},
791  {"poisson", no_argument, 0, 'P'},
792  {"help", no_argument, 0, 'h'},
793  {0,0,0,0}
794  };
795 
796  int c;
797  // int optind;
798  int longindex = 0;
799 
800  while ((c = getopt_long(argc, argv, "c:e:m:n:r:f:s:d:l:p:S:M:HEPvh", long_options, &longindex)) != -1) {
801  switch(c) {
802  case 'c':
803  config.ncases = atoi(optarg);
804  break;
805  case 'e':
806  config.nevents = atoi(optarg);
807  break;
808  case 'r':
809  config.realeff_mean = atof(optarg);
810  break;
811  case 'f':
812  config.fakeeff_mean = atof(optarg);
813  break;
814  case 's':
815  config.eff_spread = atof(optarg);
816  break;
817  case 'd':
818  config.eff_delta_with_pt = atof(optarg);
819  break;
820  case 'l':
821  config.selection = optarg;
822  break;
823  case 'p':
824  config.process = optarg;
825  break;
826  case 'm':
827  config.minnbaseline = atoi(optarg);
828  break;
829  case 'n':
830  config.maxnbaseline = atoi(optarg);
831  break;
832  case 'S':
833  config.test_save = true;
834  config.saveFileNameBase = optarg;
835  break;
836  case 'M':
837  config.test_merge = true;
838  config.mergeFileNameBase = optarg;
839  break;
840  case 'H':
841  config.test_histo = true;
842  break;
843  case 'E':
844  config.test_systematics = true;
845  break;
846  case 'v':
847  config.verbose = true;
848  break;
849  case 'P':
850  config.poisson_fluctuations = true;
851  break;
852  case 'h':
853  ANA_CHECK( usage() );
854  exit(0);
855  case '?':
856  ANA_CHECK( usage() );
857  abort();
858  default:
859  abort();
860  }
861  }
862 
863  // remove any \ from selection and process strings
864  size_t pos;
865 
866  pos = config.selection.find("\"");
867  while (pos != string::npos) {
868  config.selection.replace(pos, 1, "");
869  pos = config.selection.find("\"");
870  }
871  pos = config.process.find("\"");
872  while (pos != string::npos) {
873  config.process.replace(pos, 1, "");
874  pos = config.process.find("\"");
875  }
876  return StatusCode::SUCCESS;
877 }
878 
879 std::unique_ptr<TFile> openRootFile(fbtTestToyMC_config &config) {
880  string outputdirname;
881  string rootfilename;
882  outputdirname = "FakeBkgTools_toy_MC_nevents_";
883  outputdirname += to_string(config.nevents);
884  outputdirname += "_ncases_";
885  outputdirname += to_string(config.ncases);
886  outputdirname += "_minnbaseline_";
887  outputdirname += to_string(config.minnbaseline);
888  outputdirname += "_maxnbaseline_";
889  outputdirname += to_string(config.maxnbaseline);
890  outputdirname += "_realeff_";
891  outputdirname += to_string(config.realeff_mean);
892  outputdirname += "_fakeeff_";
893  outputdirname += to_string(config.fakeeff_mean);
894  outputdirname += "_effspread_";
895  outputdirname += to_string(config.eff_spread);
896  outputdirname += "_selection_";
897  outputdirname += config.selection;
898  outputdirname += "_process_";
899  outputdirname += config.process;
900  if (config.poisson_fluctuations) {
901  outputdirname += "_poisson_";
902  }
903 
904  //now replace things like >, < from selection and process strings to get a
905  //legal directory name
906  size_t pos;
907  pos = outputdirname.find(">=");
908  while (pos != string::npos) {
909  outputdirname.replace(pos, 2, "ge");
910  pos = outputdirname.find(">=");
911  }
912  pos = outputdirname.find("<=");
913  while (pos != string::npos) {
914  outputdirname.replace(pos, 2, "le");
915  pos = outputdirname.find("<=");
916  }
917  pos = outputdirname.find(">");
918  while (pos != string::npos) {
919  outputdirname.replace(pos, 1, "gt");
920  pos = outputdirname.find(">");
921  }
922  pos = outputdirname.find("<");
923  while (pos != string::npos) {
924  outputdirname.replace(pos, 1, "lt");
925  pos = outputdirname.find("<");
926  }
927  pos = outputdirname.find("=");
928  while (pos != string::npos) {
929  outputdirname.replace(pos, 1, "eq");
930  pos = outputdirname.find("=");
931  }
932  pos = outputdirname.find(",");
933  while (pos != string::npos) {
934  outputdirname.replace(pos, 1, "");
935  pos = outputdirname.find(",");
936  }
937  pos = outputdirname.find("[");
938  while (pos != string::npos) {
939  outputdirname.replace(pos, 1, "");
940  pos = outputdirname.find("[");
941  }
942  pos = outputdirname.find("]");
943  while (pos != string::npos) {
944  outputdirname.replace(pos, 1, "");
945  pos = outputdirname.find("]");
946  }
947  pos = outputdirname.find("\"");
948  while (pos != string::npos) {
949  outputdirname.replace(pos, 1, "");
950  pos = outputdirname.find("\"");
951  }
952  pos = outputdirname.find("\\");
953  while (pos != string::npos) {
954  outputdirname.replace(pos, 1, "");
955  pos = outputdirname.find("\\");
956  }
957 
958  gSystem->mkdir(outputdirname.c_str());
959  rootfilename = outputdirname+"/output.root";
960 
961  config.outputdirname = outputdirname;
962 
963  std::unique_ptr<TFile> f_out(TFile::Open(rootfilename.c_str(),"RECREATE"));
964 
965  return f_out;
966 }
967 
968 StatusCode initialize ATLAS_NOT_THREAD_SAFE(CP::BaseFakeBkgTool& tool, const std::vector<std::string>& input, const std::string& selection, const std::string& process, bool verbose)
969 {
970  ANA_CHECK( tool.setProperty("InputFiles", input) );
971  ANA_CHECK( tool.setProperty("EnergyUnit", "GeV") );
972  ANA_CHECK( tool.setProperty("Selection", selection) );
973  ANA_CHECK( tool.setProperty("Process", process) );
974  if(verbose) {
975  ANA_CHECK( tool.setProperty("OutputLevel", MSG::VERBOSE) );
976  }
977  else{
978  ANA_CHECK( tool.setProperty("OutputLevel", MSG::INFO) );
979  }
980  ANA_CHECK( tool.setProperty("ConvertWhenMissing", true) );
981  ANA_CHECK( tool.initialize() );
982  return StatusCode::SUCCESS;
983 }
984 
985 StatusCode setupEfficiencies ATLAS_NOT_THREAD_SAFE() {
986  rootEffFile = new TFile(rootEffFileName.c_str());
987  if (rootEffFile == 0) {
988  cout << "Um, no ROOT file!" << endl;
989  return StatusCode::FAILURE;
990  }
991 
992  h_realeff_e = (TH1F*)rootEffFile->Get("RealEfficiency_el_pt");
993  h_fakeeff_e = (TH1F*)rootEffFile->Get("FakeEfficiency_el_pt");
994  h_realeff_mu = (TH1F*)rootEffFile->Get("RealEfficiency_mu_pt");
995  h_fakeeff_mu = (TH1F*)rootEffFile->Get("FakeEfficiency_mu_pt");
996 
997  h_realeff_e->SetDirectory(0);
998  h_fakeeff_e->SetDirectory(0);
999  h_realeff_mu->SetDirectory(0);
1000  h_fakeeff_mu->SetDirectory(0);
1001 
1002  if (h_realeff_e == 0) cout << "No real e" << endl;
1003  if (h_fakeeff_e == 0) cout << "No fake e" << endl;
1004  if (h_realeff_mu == 0) cout << "No real mu" << endl;
1005  if (h_fakeeff_mu == 0) cout << "No fake mu" << endl;
1006 
1007  rootEffFile->Close();
1008  delete rootEffFile;
1009  return StatusCode::SUCCESS;
1010 }
1011 
1013 
1014  if (h_realeff_e == 0) cout << "No real e" << endl;
1015  if (h_fakeeff_e == 0) cout << "No fake e" << endl;
1016  if (h_realeff_mu == 0) cout << "No real mu" << endl;
1017  if (h_fakeeff_mu == 0) cout << "No fake mu" << endl;
1018  if (lepton.type() == xAOD::Type::Electron) {
1019  lepton_data.real_efficiency.nominal = h_realeff_e->GetBinContent(h_realeff_e->FindBin(lepton.pt()/1000.));
1020  lepton_data.fake_efficiency.nominal = h_fakeeff_e->GetBinContent(h_fakeeff_e->FindBin(lepton.pt()/1000.));
1021  } else {
1022  lepton_data.real_efficiency.nominal = h_realeff_mu->GetBinContent(h_realeff_mu->FindBin(lepton.pt()/1000.));
1023  lepton_data.fake_efficiency.nominal = h_fakeeff_mu->GetBinContent(h_fakeeff_mu->FindBin(lepton.pt()/1000.));
1024  }
1025  return StatusCode::SUCCESS;
1026 }
1027 
1028 double comboProb(const vector<FakeBkgTools::ParticleData> & leptons_data, const std::bitset<64> & tights, const std::bitset<64> &reals) {
1029 
1030  double prob(1.);
1031  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1032  if (tights[ilep]) {
1033  if (reals[ilep]) {
1034  prob *= leptons_data[ilep].real_efficiency.nominal;
1035  } else {
1036  prob *= leptons_data[ilep].fake_efficiency.nominal;
1037  }
1038  } else {
1039  if (reals[ilep]) {
1040  prob *= (1.-leptons_data[ilep].real_efficiency.nominal);
1041  } else {
1042  prob *= (1.-leptons_data[ilep].fake_efficiency.nominal);
1043  }
1044  }
1045  }
1046 
1047  return prob;
1048 }
1049 
1050 double comboProb_FF(const vector<FakeBkgTools::ParticleData> & leptons_data, const std::bitset<64> &tights, const std::bitset<64> & reals) {
1051 
1052  // like comboProb, but with real efficiencies set to 1.
1053  double prob(1.);
1054  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1055  if (tights[ilep]) {
1056  if (reals[ilep]) {
1057  } else {
1058  prob *= leptons_data[ilep].fake_efficiency.nominal;
1059  }
1060  } else {
1061  if (reals[ilep]) {
1062  prob *= 0;
1063  } else {
1064  prob *= (1.-leptons_data[ilep].fake_efficiency.nominal);
1065  }
1066  }
1067  }
1068  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1069  if (reals[ilep]) {
1070  float F = leptons_data[ilep].fake_efficiency.nominal/(1-leptons_data[ilep].fake_efficiency.nominal);
1071  prob += F;
1072  }
1073  }
1074  return prob;
1075 }
1076 
1077 StatusCode setupSystBranches(const char* baseName,
1078  CP::SystematicVariation sysvar,
1079  float &weight,
1080  float &weight_err,
1081  std::map<CP::SystematicVariation, float> &syst_map,
1082  std::map<CP::SystematicVariation, float> &syst_err_map,
1083  TTree* ntuple) {
1084  syst_map.emplace(std::make_pair(sysvar, weight));
1085  std::string systBrName = baseName;
1086  systBrName = systBrName+"_fakes_"+sysvar.name();
1087  std::string systBrNameF = systBrName+"/F";
1088  ntuple->Branch(systBrName.c_str(), &(syst_map.find(sysvar)->second), systBrNameF.c_str());
1089  syst_err_map.emplace(std::make_pair(sysvar, weight_err));
1090  systBrName = baseName;
1091  systBrName = systBrName+"_err_"+sysvar.name();
1092  systBrNameF = systBrName+"/F";
1093  ntuple->Branch(systBrName.c_str(), &(syst_err_map.find(sysvar)->second), systBrNameF.c_str());
1094 
1095  return StatusCode::SUCCESS;
1096 }
1097 
1098 StatusCode setupSystBranchesAsym(const char* baseName,
1099  CP::SystematicVariation sysvar,
1100  float &weight,
1101  float &weight_poserr,
1102  float &weight_negerr,
1103  std::map<CP::SystematicVariation, float> &syst_map,
1104  std::map<CP::SystematicVariation, float> &syst_poserr_map,
1105  std::map<CP::SystematicVariation, float> &syst_negerr_map,
1106  TTree* ntuple) {
1107  syst_map.emplace(std::make_pair(sysvar, weight));
1108  std::string systBrName = baseName;
1109  systBrName = systBrName+"_fakes_"+sysvar.name();
1110  std::string systBrNameF = systBrName+"/F";
1111  ntuple->Branch(systBrName.c_str(), &(syst_map.find(sysvar)->second), systBrNameF.c_str());
1112  syst_poserr_map.emplace(std::make_pair(sysvar, weight_poserr));
1113  systBrName = baseName;
1114  systBrName = systBrName+"_poserr_"+sysvar.name();
1115  systBrNameF = systBrName+"/F";
1116  ntuple->Branch(systBrName.c_str(), &(syst_poserr_map.find(sysvar)->second), systBrNameF.c_str());
1117  syst_negerr_map.emplace(std::make_pair(sysvar, weight_negerr));
1118  systBrName = baseName;
1119  systBrName = systBrName+"_negerr_"+sysvar.name();
1120  systBrNameF = systBrName+"/F";
1121  ntuple->Branch(systBrName.c_str(), &(syst_negerr_map.find(sysvar)->second), systBrNameF.c_str());
1122 
1123  return StatusCode::SUCCESS;
1124 }
1125 
1126 StatusCode doMerge ATLAS_NOT_THREAD_SAFE( const std::vector<std::string> & input, const std::string & name, fbtTestToyMC_config &config, TH1F* h_lep_pt, float &lep_pt, TH1F* h_lep_eta, float &lep_eta, TH2F* h_lep_pt_eta, float &fakes, float &poserr, float &negerr, int icase) {
1127 
1128  std::string haddcmd = "hadd -f "+config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+".root "+config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+"_*.root";
1129  system(haddcmd.c_str());
1130 
1131  std::unique_ptr<CP::BaseFakeBkgTool> tool;
1132 
1133  if (name == "lhm" || name == "lhf") {
1134  std::string toolName = "Lhood";
1135  if (name == "lhm") {
1136  toolName += "MM";
1137  } else {
1138  toolName += "FF";
1139  }
1140  toolName += to_string(icase)+"_tools_merge";
1141  tool = std::make_unique<CP::LhoodMM_tools>(toolName);
1142  if (name == "lhf") {
1143  ANA_CHECK( tool->setProperty("DoFakeFactorFit", true) );
1144  }
1145  ANA_CHECK( tool->setProperty("ProgressFileDirectory", "fakes") );
1146  } else if (name == "asm") {
1147  tool = std::make_unique<CP::AsymptMatrixTool>("asm_tool_merge");
1148  } else if (name == "fkf") {
1149  tool = std::make_unique<CP::ApplyFakeFactor>("fkf_tool_merge");
1150  }
1151 
1152  std::string mergeFileName = config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+".root";
1153  std::cout << mergeFileName << std::endl;
1154  ANA_CHECK( tool->setProperty("ProgressFileName", mergeFileName) );
1155  ANA_CHECK( initialize(*tool, input, config.selection, config.process, config.verbose) );
1156  if (config.test_histo) {
1157  ANA_CHECK( tool->register1DHistogram(h_lep_pt, &lep_pt) );
1158  ANA_CHECK( tool->register1DHistogram(h_lep_eta, &lep_eta) );
1159  ANA_CHECK( tool->register2DHistogram(h_lep_pt_eta, &lep_pt, &lep_eta) );
1160  }
1161 
1162  ANA_CHECK( tool->getTotalYield(fakes, poserr, negerr) );
1163  // cout << "merged lhm nfakes = " << lhoodMM_fakes << " + " << lhoodMM_poserr << " " << lhoodMM_negerr << endl;
1164  return StatusCode::SUCCESS;
1165 }
1166 
1168  std::cout << std::endl << "fbtTestToyMC provides a toy MC model of a set of pseudoexperiments. It is intended to explore the statistical properties of the fake lepton background estimate for a given set of experiemental conditions (number of events, number of leptons required, typical values of the real and fake efficiencies, etc.)" << std::endl << std::endl;
1169  std::cout << "Options: " << std::endl;
1170  std::cout << " --ncases, -c: number of pseudoexperiments to run (default: 100)" << std::endl;
1171  std::cout << " --nevents, -e: number of events in each pseudoexperiment (default: 100)" << std::endl;
1172  std::cout << " --poisson, -P: use Poisson-distributed number of events in each pseudoexperiment, rather than a fixed number (default: false)" << std::endl;
1173  std::cout << " --minnb, -m: minimum number of baseline leptons per event (default: 1)" << std::endl;
1174  std::cout << " --maxnb, -m: maximum number of baseline leptons per event (default: 4)" << std::endl;
1175  std::cout << " --rmean, -r: average real lepton efficiency (default: 0.9)" << std::endl;
1176  std::cout << " --fmean, -f: average fake lepton efficiency (default: 0.2)" << std::endl;
1177  std::cout << " --effsigma, -s: standard deviation for lepton-to-lepton variation in real and fake efficiencies (default: 0.10)" << std::endl;
1178  std::cout << " --effdeltawithpt, -d: rate at which the real (fake) efficiency increases (decreases) with simulated pt. Note that the simulated pt range is 0 to 100" << std::endl;
1179  std::cout << " --sel, -l: selection string to be used by the tools (default \" >= 1T\") " << std::endl;
1180  std::cout << " --proc, -p: process string to be used by the tools (default \" >= 1F[T]\") " << std::endl;
1181  std::cout << " --test_save, -S: save output from subjobs in each pseudoexperiement. If set, requires an argument to specify the base name of the root files where the output will be saved. (default: false) " << std::endl;
1182  std::cout << " --test_merge, -M: merge output from subjobs in each pseudoexperiement. If set, requires an argument to specify the base name of the root files to be merged. This should match the base name used in a previous run with the --test_save option (default: false) " << std::endl;
1183  std::cout << " --test_histo, -H: test the filling of 1- and 2-dimensional histograms (default: false) " << std::endl;
1184  std::cout << " --test_systematics, -E: test the handling of systematic unceratinties (default: false) " << std::endl;
1185  std::cout << " --verbose, -v: enable verbose output (default: false) " << std::endl;
1186  std::cout << " --help, -h: print this help message" << std::endl;
1187  return StatusCode::SUCCESS;;
1188 }
h_realeff_mu
TH1F * h_realeff_mu
Definition: fbtTestToyMC.cxx:72
fbtTestToyMC_config::realeff_mean
float realeff_mean
Definition: fbtTestToyMC.cxx:50
fbtTestToyMC_config::eff_spread
float eff_spread
Definition: fbtTestToyMC.cxx:52
comboProb_FF
double comboProb_FF(const vector< FakeBkgTools::ParticleData > &leptons_data, const std::bitset< 64 > &tights, const std::bitset< 64 > &reals)
Definition: fbtTestToyMC.cxx:1050
comboProb
double comboProb(const vector< FakeBkgTools::ParticleData > &leptons_data, const std::bitset< 64 > &tights, const std::bitset< 64 > &reals)
Definition: fbtTestToyMC.cxx:1028
CP::BaseFakeBkgTool
Definition: BaseFakeBkgTool.h:41
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
nSave
const int nSave
Definition: fbtTestToyMC.cxx:130
f_stdpos_lhood_0
std::ofstream * f_stdpos_lhood_0
Definition: fbtTestToyMC.cxx:128
fbtTestToyMC_config::test_save
bool test_save
Definition: fbtTestToyMC.cxx:56
f_stdneg_lhood_pos
std::ofstream * f_stdneg_lhood_pos
Definition: fbtTestToyMC.cxx:127
SG::Accessor< char >
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:279
fbtTestToyMC_config::test_merge
bool test_merge
Definition: fbtTestToyMC.cxx:57
fbtTestToyMC_config::ncases
unsigned ncases
Definition: fbtTestToyMC.cxx:47
CP::LhoodMM_tools::getTotalYield
virtual StatusCode getTotalYield(float &yield, float &statErrUp, float &statErrDown) override final
returns the accumulated fake lepton background yield (or compute it, in the case of the likelihood ma...
Definition: LhoodMM_tools.cxx:306
h_fakeeff_mu
TH1F * h_fakeeff_mu
Definition: fbtTestToyMC.cxx:72
n_fake_lhood_tot_negerr
Double_t n_fake_lhood_tot_negerr
Definition: fbtTestToyMC.cxx:125
CP::BaseFakeBkgTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
Definition: BaseFakeBkgTool.cxx:465
usage
StatusCode usage()
Definition: fbtTestToyMC.cxx:1167
initialize
void initialize()
Definition: run_EoverP.cxx:894
LhoodMMEvent.h
fbtTestToyMC_config::nevents
unsigned nevents
Definition: fbtTestToyMC.cxx:46
CP::SystematicVariation::name
const std::string & name() const
description: the full systematics name, for use in strings, etc.
Definition: SystematicVariation.cxx:303
h_realeff_e
TH1F * h_realeff_e
Definition: fbtTestToyMC.cxx:72
skel.it
it
Definition: skel.GENtoEVGEN.py:396
xAOD::IParticle::type
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
FakeBkgTools::ParticleData
Definition: FakeBkgInternals.h:85
CP::ApplyFakeFactor
Definition: ApplyFakeFactor.h:22
fbtTestToyMC_config::mergeFileNameBase
std::string mergeFileNameBase
Definition: fbtTestToyMC.cxx:59
CP::SystematicVariation
Definition: SystematicVariation.h:47
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
covarianceTool.prob
prob
Definition: covarianceTool.py:678
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
CP::BaseLinearFakeBkgTool::getEventWeight
virtual StatusCode getEventWeight(float &weight, const std::string &selection, const std::string &process) override final
returns an event weight addEvent() must have been called before hand.
Definition: BaseLinearFakeBkgTool.cxx:39
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
handi.long_options
list long_options
Definition: handi.py:43
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
fbtTestToyMC_config::verbose
bool verbose
Definition: fbtTestToyMC.cxx:61
weight_lepfakes_2tight_1loose
double weight_lepfakes_2tight_1loose
Definition: fbtTestToyMC.cxx:114
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
setupSystBranchesAsym
StatusCode setupSystBranchesAsym(const char *baseName, CP::SystematicVariation sysvar, float &weight, float &weight_poserr, float &weight_negerr, std::map< CP::SystematicVariation, float > &syst_map, std::map< CP::SystematicVariation, float > &syst_poserr_map, std::map< CP::SystematicVariation, float > &syst_negerr_map, TTree *ntuple)
Definition: fbtTestToyMC.cxx:1098
ANA_MSG_HEADER
#define ANA_MSG_HEADER(NAME)
for standalone code this creates a new message category
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:113
fbtTestToyMC_config::selection
std::string selection
Definition: fbtTestToyMC.cxx:54
fbtTestToyMC_config::test_systematics
bool test_systematics
Definition: fbtTestToyMC.cxx:63
xAOD::Electron_v1::setCharge
void setCharge(float charge)
set the charge of the object
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition: CppUnit_SGtestdriver.cxx:141
fbtTestToyMC_config::poisson_fluctuations
bool poisson_fluctuations
Definition: fbtTestToyMC.cxx:64
CP::BaseLinearFakeBkgTool::register2DHistogram
virtual StatusCode register2DHistogram(TH2 *h2, const float *xval, const float *yval) override
associates a 2D histogram to the tool, to obtain a binned estimate of the fake lepton background the ...
Definition: BaseLinearFakeBkgTool.cxx:128
totWeight_std
double totWeight_std
Definition: fbtTestToyMC.cxx:110
xAOD::Egamma_v1::setP4
void setP4(float pt, float eta, float phi, float m)
set the 4-vec
Definition: Egamma_v1.cxx:104
rootEffFile
TFile * rootEffFile
Definition: fbtTestToyMC.cxx:73
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
fbtTestToyMC_config::minnbaseline
unsigned minnbaseline
Definition: fbtTestToyMC.cxx:48
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
FakeBkgTools
Definition: BaseFakeBkgTool.h:23
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
fbtTestToyMC_config::process
std::string process
Definition: fbtTestToyMC.cxx:55
err_std
double err_std
Definition: fbtTestToyMC.cxx:111
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
MessageCheck.h
macros for messaging and checking status codes
file
TFile * file
Definition: tile_monitor.h:29
fitFailed
bool fitFailed
Definition: fbtTestToyMC.cxx:116
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
fbtTestToyMC_config::maxnbaseline
unsigned maxnbaseline
Definition: fbtTestToyMC.cxx:49
h_fakeeff_e
TH1F * h_fakeeff_e
Definition: fbtTestToyMC.cxx:72
selection
std::string selection
Definition: fbtTestBasics.cxx:75
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
openRootFile
std::unique_ptr< TFile > openRootFile(fbtTestToyMC_config &config)
Definition: fbtTestToyMC.cxx:879
calibdata.exit
exit
Definition: calibdata.py:236
DataVector::clear
void clear()
Erase all the elements in the collection.
fbtTestToyMC_config::outputdirname
std::string outputdirname
Definition: fbtTestToyMC.cxx:60
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
setupSystBranches
StatusCode setupSystBranches(const char *baseName, CP::SystematicVariation sysvar, float &weight, float &weight_err, std::map< CP::SystematicVariation, float > &syst_map, std::map< CP::SystematicVariation, float > &syst_err_map, TTree *ntuple)
Definition: fbtTestToyMC.cxx:1077
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
fbtTestToyMC_config::fakeeff_mean
float fakeeff_mean
Definition: fbtTestToyMC.cxx:51
ANA_MSG_SOURCE
#define ANA_MSG_SOURCE(NAME, TITLE)
the source code part of ANA_MSG_SOURCE
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:133
n_fake_lhood
Double_t n_fake_lhood
Definition: fbtTestToyMC.cxx:122
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
rootEffFileName
string rootEffFileName
Definition: fbtTestToyMC.cxx:118
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
Accessor.h
Helper class to provide type-safe access to aux data.
weight_lepfakes_2tight
double weight_lepfakes_2tight
Definition: fbtTestToyMC.cxx:112
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
FakeBkgInternals.h
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
FakeBkgTools::ParticleData::real_efficiency
Efficiency real_efficiency
Definition: FakeBkgInternals.h:86
n_fake_lhood_tot_poserr
Double_t n_fake_lhood_tot_poserr
Definition: fbtTestToyMC.cxx:124
xAOD::Electron_v1
Definition: Electron_v1.h:34
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
downloadSingle.saveFileName
string saveFileName
Definition: downloadSingle.py:40
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
FakeBkgTools::Efficiency::nominal
float nominal
Definition: FakeBkgInternals.h:42
FakeBkgTools::FinalState
Definition: FakeBkgInternals.h:98
CP::BaseLinearFakeBkgTool::register1DHistogram
virtual StatusCode register1DHistogram(TH1 *h1, const float *val) override
associates a 1D histogram to the tool, to obtain a binned estimate of the fake lepton background the ...
Definition: BaseLinearFakeBkgTool.cxx:121
writeROOT
StatusCode writeROOT(const string &name, int type, float realeff_mean, float fakeeff_mean, float eff_spread, float eff_delta_with_pt)
Definition: fbtTestToyMC.cxx:696
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
fbtTestToyMC_config::eff_delta_with_pt
float eff_delta_with_pt
Definition: fbtTestToyMC.cxx:53
CP::BaseLinearFakeBkgTool::getTotalYield
virtual StatusCode getTotalYield(float &yield, float &statErrorUp, float &statErrorDown) override final
returns the accumulated fake lepton background yield (or compute it, in the case of the likelihood ma...
Definition: BaseLinearFakeBkgTool.cxx:70
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
CP::BaseFakeBkgTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
Definition: BaseFakeBkgTool.cxx:438
F
#define F(x, y, z)
Definition: MD5.cxx:112
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:74
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
CP::LhoodMM_tools
Definition: LhoodMM_tools.h:28
fbtTestToyMC_config
Definition: fbtTestToyMC.cxx:45
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
Electron.h
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
StandaloneToolHandle.h
CP::BaseFakeBkgTool::addEvent
virtual StatusCode addEvent(const xAOD::IParticleContainer &particles, float extraWeight=1.f) override final
supply list of leptons / global variables, internal counters incremented Does not return anything; ev...
Definition: BaseFakeBkgTool.cxx:238
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
CP::LhoodMM_tools::register2DHistogram
virtual StatusCode register2DHistogram(TH2 *h2, const float *xval, const float *yval) override
associates a 2D histogram to the tool, to obtain a binned estimate of the fake lepton background the ...
Definition: LhoodMM_tools.cxx:191
fbtTestToyMC_config::test_histo
bool test_histo
Definition: fbtTestToyMC.cxx:62
FakeBkgTools::ParticleData::fake_efficiency
Efficiency fake_efficiency
Definition: FakeBkgInternals.h:86
fbtTestToyMC_config::saveFileNameBase
std::string saveFileNameBase
Definition: fbtTestToyMC.cxx:58
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70
CP::IFakeBkgSystDescriptor::printUncertaintyDescription
virtual void printUncertaintyDescription(const CP::SystematicVariation &systematic) const =0
prints a human-readable description of the source of systematic uncertainty specified as argument
LhoodMM_tools.h
python.compressB64.c
def c
Definition: compressB64.py:93
CP::AsymptMatrixTool
Definition: AsymptMatrixTool.h:18
ApplyFakeFactor.h
writeXML
StatusCode writeXML(const string &name, int type)
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AsymptMatrixTool.h
CP::BaseFakeBkgTool::getSystDescriptor
virtual const IFakeBkgSystDescriptor & getSystDescriptor() const override
retrieves an interface to various helper methods to identify what the different SystematicVariations ...
Definition: BaseFakeBkgTool.h:74
ATLAS_NOT_THREAD_SAFE
StatusCode initialize ATLAS_NOT_THREAD_SAFE(CP::BaseFakeBkgTool &tool, const std::vector< std::string > &input, const std::string &selection, const std::string &process, bool verbose)
Definition: fbtTestToyMC.cxx:968
weight_lepfakes_3tight
double weight_lepfakes_3tight
Definition: fbtTestToyMC.cxx:113
CP::LhoodMM_tools::register1DHistogram
virtual StatusCode register1DHistogram(TH1 *h1, const float *val) override
associates a 1D histogram to the tool, to obtain a binned estimate of the fake lepton background the ...
Definition: LhoodMM_tools.cxx:163