ATLAS Offline Software
Classes | Functions | Variables
fbtTestToyMC.cxx File Reference
#include "AsgMessaging/MessageCheck.h"
#include <AsgTools/StandaloneToolHandle.h>
#include "FakeBkgTools/FakeBkgInternals.h"
#include "FakeBkgTools/ApplyFakeFactor.h"
#include "FakeBkgTools/AsymptMatrixTool.h"
#include "FakeBkgTools/LhoodMM_tools.h"
#include "xAODEgamma/Electron.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TRandom3.h"
#include "TSystem.h"
#include <getopt.h>
#include <unistd.h>
#include <map>
#include <chrono>
#include <fstream>
#include <memory>

Go to the source code of this file.

Classes

struct  fbtTestToyMC_config
 

Functions

StatusCode initialize (CP::BaseFakeBkgTool &tool, const std::vector< std::string > &input, const std::string &selection, const std::string &process, bool verbose)
 
StatusCode writeXML (const string &name, int type)
 
StatusCode writeROOT (const string &name, int type, float realeff_mean, float fakeeff_mean, float eff_spread, float eff_delta_with_pt)
 
StatusCode setupEfficiencies ()
 
StatusCode lookupEfficiencies (xAOD::IParticle &lepton, ParticleData &lepton_data)
 
StatusCode parseArguments (int argc, char *argv[], fbtTestToyMC_config &config)
 
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)
 
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)
 
std::unique_ptr< TFile > openRootFile (fbtTestToyMC_config &config)
 
StatusCode doMerge (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)
 
StatusCode Loop (fbtTestToyMC_config config)
 
double comboProb (const vector< FakeBkgTools::ParticleData > &leptons_data, const std::bitset< 64 > &tights, const std::bitset< 64 > &reals)
 
StatusCode usage ()
 
int main (int argc, char *argv[])
 
double comboProb_FF (const vector< FakeBkgTools::ParticleData > &leptons_data, const std::bitset< 64 > &tights, const std::bitset< 64 > &reals)
 

Variables

TH1Fh_realeff_e
 
TH1Fh_fakeeff_e
 
TH1Fh_realeff_mu
 
TH1Fh_fakeeff_mu
 
TFile * rootEffFile
 
double totWeight_std
 
double err_std
 
double weight_lepfakes_2tight
 
double weight_lepfakes_3tight
 
double weight_lepfakes_2tight_1loose
 
bool fitFailed
 
string rootEffFileName
 
Double_t n_fake_lhood
 
Double_t n_fake_lhood_tot_poserr
 
Double_t n_fake_lhood_tot_negerr
 
std::ofstream * f_stdneg_lhood_pos
 
std::ofstream * f_stdpos_lhood_0
 
const int nSave = 4
 

Function Documentation

◆ comboProb()

double comboProb ( const vector< FakeBkgTools::ParticleData > &  leptons_data,
const std::bitset< 64 > &  tights,
const std::bitset< 64 > &  reals 
)

Definition at line 1023 of file fbtTestToyMC.cxx.

1023  {
1024 
1025  double prob(1.);
1026  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1027  if (tights[ilep]) {
1028  if (reals[ilep]) {
1029  prob *= leptons_data[ilep].real_efficiency.nominal;
1030  } else {
1031  prob *= leptons_data[ilep].fake_efficiency.nominal;
1032  }
1033  } else {
1034  if (reals[ilep]) {
1035  prob *= (1.-leptons_data[ilep].real_efficiency.nominal);
1036  } else {
1037  prob *= (1.-leptons_data[ilep].fake_efficiency.nominal);
1038  }
1039  }
1040  }
1041 
1042  return prob;
1043 }

◆ comboProb_FF()

double comboProb_FF ( const vector< FakeBkgTools::ParticleData > &  leptons_data,
const std::bitset< 64 > &  tights,
const std::bitset< 64 > &  reals 
)

Definition at line 1045 of file fbtTestToyMC.cxx.

1045  {
1046 
1047  // like comboProb, but with real efficiencies set to 1.
1048  double prob(1.);
1049  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1050  if (tights[ilep]) {
1051  if (reals[ilep]) {
1052  } else {
1053  prob *= leptons_data[ilep].fake_efficiency.nominal;
1054  }
1055  } else {
1056  if (reals[ilep]) {
1057  prob *= 0;
1058  } else {
1059  prob *= (1.-leptons_data[ilep].fake_efficiency.nominal);
1060  }
1061  }
1062  }
1063  for (unsigned ilep = 0; ilep < leptons_data.size(); ilep++) {
1064  if (reals[ilep]) {
1065  float F = leptons_data[ilep].fake_efficiency.nominal/(1-leptons_data[ilep].fake_efficiency.nominal);
1066  prob += F;
1067  }
1068  }
1069  return prob;
1070 }

◆ doMerge()

StatusCode doMerge ( 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 
)

Definition at line 1121 of file fbtTestToyMC.cxx.

1121  {
1122 
1123  std::string haddcmd = "hadd -f "+config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+".root "+config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+"_*.root";
1124  system(haddcmd.c_str());
1125 
1126  std::unique_ptr<CP::BaseFakeBkgTool> tool;
1127 
1128  if (name == "lhm" || name == "lhf") {
1129  std::string toolName = "Lhood";
1130  if (name == "lhm") {
1131  toolName += "MM";
1132  } else {
1133  toolName += "FF";
1134  }
1135  toolName += to_string(icase)+"_tools_merge";
1136  tool = std::make_unique<CP::LhoodMM_tools>(toolName);
1137  if (name == "lhf") {
1138  ANA_CHECK( tool->setProperty("DoFakeFactorFit", true) );
1139  }
1140  ANA_CHECK( tool->setProperty("ProgressFileDirectory", "fakes") );
1141  } else if (name == "asm") {
1142  tool = std::make_unique<CP::AsymptMatrixTool>("asm_tool_merge");
1143  } else if (name == "fkf") {
1144  tool = std::make_unique<CP::ApplyFakeFactor>("fkf_tool_merge");
1145  }
1146 
1147  std::string mergeFileName = config.mergeFileNameBase+"_"+name+"_"+to_string(icase)+".root";
1148  std::cout << mergeFileName << std::endl;
1149  ANA_CHECK( tool->setProperty("ProgressFileName", mergeFileName) );
1150  ANA_CHECK( initialize(*tool, input, config.selection, config.process, config.verbose) );
1151  if (config.test_histo) {
1152  ANA_CHECK( tool->register1DHistogram(h_lep_pt, &lep_pt) );
1153  ANA_CHECK( tool->register1DHistogram(h_lep_eta, &lep_eta) );
1154  ANA_CHECK( tool->register2DHistogram(h_lep_pt_eta, &lep_pt, &lep_eta) );
1155  }
1156 
1157  ANA_CHECK( tool->getTotalYield(fakes, poserr, negerr) );
1158  // cout << "merged lhm nfakes = " << lhoodMM_fakes << " + " << lhoodMM_poserr << " " << lhoodMM_negerr << endl;
1159  return StatusCode::SUCCESS;
1160 }

◆ initialize()

StatusCode initialize ( CP::BaseFakeBkgTool tool,
const std::vector< std::string > &  input,
const std::string &  selection,
const std::string &  process,
bool  verbose 
)

Definition at line 963 of file fbtTestToyMC.cxx.

964 {
965  ANA_CHECK( tool.setProperty("InputFiles", input) );
966  ANA_CHECK( tool.setProperty("EnergyUnit", "GeV") );
967  ANA_CHECK( tool.setProperty("Selection", selection) );
968  ANA_CHECK( tool.setProperty("Process", process) );
969  if(verbose) {
970  ANA_CHECK( tool.setProperty("OutputLevel", MSG::VERBOSE) );
971  }
972  else{
973  ANA_CHECK( tool.setProperty("OutputLevel", MSG::INFO) );
974  }
975  ANA_CHECK( tool.setProperty("ConvertWhenMissing", true) );
976  ANA_CHECK( tool.initialize() );
977  return StatusCode::SUCCESS;
978 }

◆ lookupEfficiencies()

StatusCode lookupEfficiencies ( xAOD::IParticle lepton,
FakeBkgTools::ParticleData lepton_data 
)

Definition at line 1007 of file fbtTestToyMC.cxx.

1007  {
1008 
1009  if (h_realeff_e == 0) cout << "No real e" << endl;
1010  if (h_fakeeff_e == 0) cout << "No fake e" << endl;
1011  if (h_realeff_mu == 0) cout << "No real mu" << endl;
1012  if (h_fakeeff_mu == 0) cout << "No fake mu" << endl;
1013  if (lepton.type() == xAOD::Type::Electron) {
1014  lepton_data.real_efficiency.nominal = h_realeff_e->GetBinContent(h_realeff_e->FindBin(lepton.pt()/1000.));
1015  lepton_data.fake_efficiency.nominal = h_fakeeff_e->GetBinContent(h_fakeeff_e->FindBin(lepton.pt()/1000.));
1016  } else {
1017  lepton_data.real_efficiency.nominal = h_realeff_mu->GetBinContent(h_realeff_mu->FindBin(lepton.pt()/1000.));
1018  lepton_data.fake_efficiency.nominal = h_fakeeff_mu->GetBinContent(h_fakeeff_mu->FindBin(lepton.pt()/1000.));
1019  }
1020  return StatusCode::SUCCESS;
1021 }

◆ Loop()

StatusCode Loop ( fbtTestToyMC_config  config)

Definition at line 161 of file fbtTestToyMC.cxx.

161  {
162 
163  //Open an output file
164  if (config.verbose) cout << "maxnbaseline = " << config.maxnbaseline << endl;
165 
166  std::unique_ptr<TFile> f_out = openRootFile(config);
167 
168  int nevents_thiscase;
169 
170  // create output ntuple
171  TTree *ntuple = new TTree("FakeBkg", "Variables from toy MC");
172  ntuple->Branch("nevents", &nevents_thiscase, "nevents/I");
173  Int_t nevents_sel;
174  ntuple->Branch("nevents_sel", &nevents_sel, "nevents_sel/I");
175  Float_t fake_lep_frac;
176  ntuple->Branch("fake_lep_frac", &fake_lep_frac, "fake_lep_frac/F");
177  Float_t true_fakes;
178  ntuple->Branch("true_fakes", &true_fakes,"true_fakes/F");
179  Float_t asm_fakes;
180  ntuple->Branch("asm_fakes", &asm_fakes,"asm_fakes/F");
181  Float_t asm_err;
182  ntuple->Branch("asm_err", &asm_err,"asm_err/F");
183  Float_t fkf_fakes;
184  ntuple->Branch("fkf_fakes", &fkf_fakes,"fkf_fakes/F");
185  Float_t fkf_err;
186  ntuple->Branch("fkf_err", &fkf_err,"fkf_err/F");
187  Float_t lhoodMM_fakes;
188  ntuple->Branch("lhoodMM_fakes", &lhoodMM_fakes,"lhoodMM_fakes/F");
189  Float_t lhoodMM_poserr;
190  ntuple->Branch("lhoodMM_poserr", &lhoodMM_poserr,"lhoodMM_poserr/F");
191  Float_t lhoodMM_negerr;
192  ntuple->Branch("lhoodMM_negerr", &lhoodMM_negerr,"lhoodMM_negerr/F");
193  Float_t lhoodFF_fakes;
194  ntuple->Branch("lhoodFF_fakes", &lhoodFF_fakes,"lhoodFF_fakes/F");
195  Float_t lhoodFF_poserr;
196  ntuple->Branch("lhoodFF_poserr", &lhoodFF_poserr,"lhoodFF_poserr/F");
197  Float_t lhoodFF_negerr;
198  ntuple->Branch("lhoodFF_negerr", &lhoodFF_negerr,"lhoodFF_negerr/F");
199 
200 
201  map<CP::SystematicVariation,float> lhoodMM_weight_map, lhoodMM_poserr_map, lhoodMM_negerr_map;
202  map<CP::SystematicVariation,float> lhoodFF_weight_map, lhoodFF_poserr_map, lhoodFF_negerr_map;
203  map<CP::SystematicVariation,float> asm_weight_map, asm_err_map;
204  map<CP::SystematicVariation,float> fkf_weight_map, fkf_err_map;
205 
206  TRandom3 rand(242868252);
207 
208  Double_t realeff_spread = config.eff_spread;
209  Double_t fakeeff_spread = config.eff_spread;
210 
211  std::vector<bool> isTight;
212  std::vector<std::string> input = { config.outputdirname+"efficiencies_full" };
213 
214  if(false) // switch to test either XML or ROOT input
215  {
216  // not implemented yet!
217  // input.back().append(".xml");
218  // writeXML(input.back(), 0);
219  }
220  else
221  {
222  input.back().append(".root");
223  ANA_CHECK( writeROOT(input.back(), 0, config.realeff_mean, config.fakeeff_mean, config.eff_spread, config.eff_delta_with_pt) );
224  rootEffFileName = input.back();
226  }
227 
228 
229  for (unsigned icase(0); icase < config.ncases; icase++) {
230  nevents_sel = 0;
231 
232  TH1F* h_lep_pt_lhoodMM = 0;
233  TH1F* h_lep_eta_lhoodMM = 0;
234  TH2F* h_lep_pt_eta_lhoodMM = 0;
235  TH1F* h_lep_pt_lhoodFF = 0;
236  TH1F* h_lep_eta_lhoodFF = 0;
237  TH2F* h_lep_pt_eta_lhoodFF = 0;
238  TH1F* h_lep_pt_asm = 0;
239  TH1F* h_lep_eta_asm = 0;
240  TH2F* h_lep_pt_eta_asm = 0;
241  TH1F* h_lep_pt_fkf = 0;
242  TH1F* h_lep_eta_fkf = 0;
243  TH2F* h_lep_pt_eta_fkf = 0;
244 
245  if (config.test_histo) {
246  std::string hname = "lep_pt_lhoodMM_"+to_string(icase);
247  h_lep_pt_lhoodMM = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
248  hname = "lep_eta_lhoodMM_"+to_string(icase);
249  h_lep_eta_lhoodMM = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
250  hname = "lep_pt_eta_lhoodMM_"+to_string(icase);
251  h_lep_pt_eta_lhoodMM = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
252  hname = "lep_pt_lhoodFF_"+to_string(icase);
253  h_lep_pt_lhoodFF = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
254  hname = "lep_eta_lhoodFF_"+to_string(icase);
255  h_lep_eta_lhoodFF = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
256  hname = "lep_pt_eta_lhoodFF_"+to_string(icase);
257  h_lep_pt_eta_lhoodFF = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
258  hname = "lep_pt_asm_"+to_string(icase);
259  h_lep_pt_asm = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
260  hname = "lep_eta_asm_"+to_string(icase);
261  h_lep_eta_asm = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
262  hname = "lep_pt_eta_asm_"+to_string(icase);
263  h_lep_pt_eta_asm = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
264  hname = "lep_pt_fkf_"+to_string(icase);
265  h_lep_pt_fkf = new TH1F(hname.c_str(), hname.c_str(), 10, 0, 100);
266  hname = "lep_eta_fkf_"+to_string(icase);
267  h_lep_eta_fkf = new TH1F(hname.c_str(), hname.c_str(), 10, -5, 5);
268  hname = "lep_pt_eta_fkf_"+to_string(icase);
269  h_lep_pt_eta_fkf = new TH2F(hname.c_str(), hname.c_str(), 10, 0, 100, 10, -5, 5);
270  }
271 
272  float lep_pt, lep_eta;
273 
274  if (!config.test_merge) {
275 
276  cout << "Starting case " << icase << endl;
277  CP::LhoodMM_tools lhmTool("LhoodMM_tools");
278  // arrays of tool instances to test saveProgress
279  std::vector<CP::LhoodMM_tools*> lhmTool_sav;
280  CP::LhoodMM_tools lhmTool_FF("LhoodFF_tools");
281  std::vector<CP::LhoodMM_tools*> lhmTool_FF_sav;
282  CP::AsymptMatrixTool asmTool("AsymptMatrixTool");
283  std::vector<CP::AsymptMatrixTool*> asmTool_sav;
284  CP::ApplyFakeFactor fkfTool("fkfTool");
285  std::vector<CP::ApplyFakeFactor*> fkfTool_sav;
286 
287  float asmYield(0);
288  float asmErr(0);
289  float fkfYield (0);
290  float fkfErr(0);
291  if (config.test_histo) {
292  ANA_CHECK( lhmTool.register1DHistogram(h_lep_pt_lhoodMM, &lep_pt) );
293  ANA_CHECK( lhmTool.register1DHistogram(h_lep_eta_lhoodMM, &lep_eta) );
294  ANA_CHECK( lhmTool.register2DHistogram(h_lep_pt_eta_lhoodMM, &lep_pt, &lep_eta) );
295  ANA_CHECK( lhmTool_FF.register1DHistogram(h_lep_pt_lhoodFF, &lep_pt) );
296  ANA_CHECK( lhmTool_FF.register1DHistogram(h_lep_eta_lhoodFF, &lep_eta) );
297  ANA_CHECK( lhmTool_FF.register2DHistogram(h_lep_pt_eta_lhoodFF, &lep_pt, &lep_eta) );
298  ANA_CHECK( fkfTool.register1DHistogram(h_lep_pt_fkf, &lep_pt) );
299  ANA_CHECK( fkfTool.register1DHistogram(h_lep_eta_fkf, &lep_eta) );
300  ANA_CHECK( fkfTool.register2DHistogram(h_lep_pt_eta_fkf, &lep_pt, &lep_eta) );
301  ANA_CHECK( asmTool.register1DHistogram(h_lep_pt_asm, &lep_pt) );
302  ANA_CHECK( asmTool.register1DHistogram(h_lep_eta_asm, &lep_eta) );
303  ANA_CHECK( asmTool.register2DHistogram(h_lep_pt_eta_asm, &lep_pt, &lep_eta) );
304  }
305 
306  ANA_CHECK( initialize(asmTool, input, config.selection, config.process, config.verbose) );
307  ANA_CHECK( initialize(lhmTool, input, config.selection, config.process, config.verbose) );
308  ANA_CHECK( initialize(lhmTool_FF, input, config.selection, config.process, config.verbose) );
309  ANA_CHECK( lhmTool_FF.setProperty("DoFakeFactorFit", true) );
310 
311  ANA_CHECK( initialize(fkfTool, input, config.selection, config.process, config.verbose) );
312 
313  if (config.test_save) {
314  for (int iSave = 0; iSave <= nSave; iSave++) {
315  std:: string toolName = "LhoodMM_tools_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
316  CP::LhoodMM_tools *lhmTool_is = new CP::LhoodMM_tools(toolName.c_str());
317  lhmTool_sav.push_back(lhmTool_is);
318  ANA_CHECK( initialize(*lhmTool_sav[iSave], input, config.selection, config.process, config.verbose) );
319  if (config.test_histo) {
320  ANA_CHECK( lhmTool_is->register1DHistogram(h_lep_pt_lhoodMM, &lep_pt) );
321  ANA_CHECK( lhmTool_is->register1DHistogram(h_lep_eta_lhoodMM, &lep_eta) );
322  ANA_CHECK( lhmTool_is->register2DHistogram(h_lep_pt_eta_lhoodMM, &lep_pt, &lep_eta) );
323  }
324  toolName = "LhoodMM_tools_FF_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
325  CP::LhoodMM_tools *lhmTool_FF_is = new CP::LhoodMM_tools(toolName.c_str());
326  lhmTool_FF_sav.push_back(lhmTool_FF_is);
327  ANA_CHECK( initialize(*lhmTool_FF_sav[iSave], input, config.selection, config.process, config.verbose) );
328  ANA_CHECK( lhmTool_FF_sav[iSave]->setProperty("DoFakeFactorFit", true) );
329  if (config.test_histo) {
330  ANA_CHECK( lhmTool_FF_is->register1DHistogram(h_lep_pt_lhoodFF, &lep_pt) );
331  ANA_CHECK( lhmTool_FF_is->register1DHistogram(h_lep_eta_lhoodFF, &lep_eta) );
332  ANA_CHECK( lhmTool_FF_is->register2DHistogram(h_lep_pt_eta_lhoodFF, &lep_pt, &lep_eta) );
333  }
334 
335  toolName = "AsymptMatrixTool_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
336  CP::AsymptMatrixTool *asmTool_is = new CP::AsymptMatrixTool(toolName.c_str()); if (config.test_histo) {
337  ANA_CHECK( asmTool_is->register1DHistogram(h_lep_pt_asm, &lep_pt) );
338  ANA_CHECK( asmTool_is->register1DHistogram(h_lep_eta_asm, &lep_eta) );
339  ANA_CHECK( asmTool_is->register2DHistogram(h_lep_pt_eta_asm, &lep_pt, &lep_eta) );
340  }
341  asmTool_sav.push_back(asmTool_is);
342  ANA_CHECK( initialize(*asmTool_sav[iSave], input, config.selection, config.process, config.verbose) );
343 
344  toolName = "ApplyFakeFactor_save_" + std::to_string(icase) + "_" + std::to_string(iSave);
345  CP::ApplyFakeFactor *fkfTool_is = new CP::ApplyFakeFactor(toolName.c_str());
346  fkfTool_sav.push_back(fkfTool_is);
347  ANA_CHECK( initialize(*fkfTool_sav[iSave], input, config.selection, config.process, config.verbose) );
348  if (config.test_histo) {
349  ANA_CHECK( fkfTool_is->register1DHistogram(h_lep_pt_fkf, &lep_pt) );
350  ANA_CHECK( fkfTool_is->register1DHistogram(h_lep_eta_fkf, &lep_eta) );
351  ANA_CHECK( fkfTool_is->register2DHistogram(h_lep_pt_eta_fkf, &lep_pt, &lep_eta) );
352  }
353  }
354  }
355 
356 
357  Double_t realeff_mean_thiscase = rand.Gaus(config.realeff_mean, realeff_spread);
358  if (realeff_mean_thiscase > 0.99) realeff_mean_thiscase = 0.99;
359  Double_t fakeeff_mean_thiscase = rand.Gaus(config.fakeeff_mean, fakeeff_spread);
360  if (fakeeff_mean_thiscase < 0.01) fakeeff_mean_thiscase = 0.01;
361  if (fakeeff_mean_thiscase > realeff_mean_thiscase) fakeeff_mean_thiscase = realeff_mean_thiscase-0.01;
362 
363  fake_lep_frac = rand.Uniform(); // fraction of fake leptons in the loose sample
364 
365  totWeight_std = 0.;
366  err_std = 0;
367  n_fake_lhood = 0.;
370 
371  std::vector<LhoodMMEvent> mmevts;
372 
373  true_fakes = 0;
374 
375  std::vector<double> realeff, fakeeff;
376 
377  vector<FinalState*> fs;
378  FinalState* this_fs(0);
379  for (unsigned ilep(0); ilep <= config.maxnbaseline; ilep++) {
380  string error;
381  this_fs = new FinalState(0, ilep, config.selection, config.process, error);
382  fs.push_back(this_fs);
383  }
384 
385  if (config.poisson_fluctuations) {
386  nevents_thiscase = rand.Poisson(config.nevents);
387  } else {
388  nevents_thiscase = config.nevents;
389  }
390 
391  // need two passes to simulate subtraction of real lepton contribution
392  // in fake factor method with a statistically-independent sample
393  for (int pass(0); pass<2; pass++) {
394  int savIndex(0);
395 
396 
397  int nEventsMultFactor = 1;
398  if (pass > 0) nEventsMultFactor = 10; // simulates higher-stats "MC" for removal of real contribution to fake factor result
399  for (Long64_t ievt(0); ievt<nevents_thiscase*nEventsMultFactor; ievt++) {
400 
401  float nlep_frac = 1./(config.maxnbaseline-config.minnbaseline+1);
402  Int_t nlep_select = config.minnbaseline+rand.Uniform()/nlep_frac;
403 
404  float extraweight(1.0);
405 
406  realeff.clear();
407  fakeeff.clear();
408 
410  vector<FakeBkgTools::ParticleData> leptons_data;
411 
412  vector<bool> lep_real;
413 
414  // set up an ordered vector of lepton pts
415  vector<float> lep_pts;
416  for (int ilep(0); ilep < nlep_select; ilep++) {
417  lep_pts.push_back(100*rand.Uniform());
418  }
419  // sort in descending order
420  sort(lep_pts.begin(), lep_pts.end(), std::greater<float>());
421 
422  for (int ilep(0); ilep < nlep_select; ilep++) {
423  xAOD::Electron* lepton = new xAOD::Electron; // for toy MC the lepton flavor doesn't matter
424  // assign the lepton as real or fake
425  bool isReal(false);
426  if (rand.Uniform() > fake_lep_frac) {
427  isReal = true;
428  } else {
429  isReal = false;
430  }
431 
432  lep_real.push_back(isReal);
433  lepton->makePrivateStore();
434  lepton->setCharge(rand.Uniform() > 0.5 ? 1 : -1 );
435 
436  lep_pt = lep_pts[ilep];
437  lep_eta = -5. + 10*rand.Uniform();
438  lepton->setP4( 1000*lep_pt, lep_eta, 0, 0.511);
439 
440  FakeBkgTools::ParticleData lepton_data;
441  ANA_CHECK( lookupEfficiencies(*lepton, lepton_data) );
442  // decide if lepton is tight or not
443  if (isReal) {
444  if (rand.Uniform() < lepton_data.real_efficiency.nominal) {
445  lepton->auxdata<char>("Tight") = true;
446  } else {
447  lepton->auxdata<char>("Tight") = false;
448  }
449  } else {
450  if (rand.Uniform() < lepton_data.fake_efficiency.nominal) {
451  lepton->auxdata<char>("Tight") = true;
452  } else {
453  lepton->auxdata<char>("Tight") = false;
454  }
455  }
456  leptons.push_back(static_cast<xAOD::IParticle*>(lepton));
457 
458  leptons_data.push_back(lepton_data);
459  }
460 
461  if (pass == 0) {
462  ANA_CHECK( asmTool.addEvent(leptons, extraweight) );
463  ANA_CHECK( fkfTool.addEvent(leptons, extraweight) );
464  ANA_CHECK( lhmTool.addEvent(leptons, extraweight) );
465  ANA_CHECK( lhmTool_FF.addEvent(leptons, extraweight) );
466  if (config.test_save) {
467  ANA_CHECK( lhmTool_sav[savIndex]->addEvent(leptons, extraweight) );
468  ANA_CHECK( lhmTool_FF_sav[savIndex]->addEvent(leptons, extraweight) );
469  ANA_CHECK( asmTool_sav[savIndex]->addEvent(leptons, extraweight) );
470  ANA_CHECK( fkfTool_sav[savIndex]->addEvent(leptons, extraweight) );
471  }
472 
473  }
474 
475  bool all_real(true);
476  if (pass == 1) {
477  for (int ilep(0); ilep < nlep_select; ilep++) {
478  if (!lep_real[ilep]) {
479  all_real = false;
480  }
481  }
482  }
483 
484  // fkfTool.addEvent(leptons, extraweight);
485  if (pass == 1 && all_real) {
486  ANA_CHECK( fkfTool.addEvent(leptons, -extraweight/nEventsMultFactor) );
487  // probably not the fully correct way to do it for the LhoodMM,
488  // but might be close enough
489  ANA_CHECK( lhmTool_FF.addEvent(leptons, -extraweight/nEventsMultFactor) );
490 
491  if (config.test_save) {
492  ANA_CHECK( fkfTool_sav[savIndex]->addEvent(leptons, -extraweight/nEventsMultFactor) );
493  ANA_CHECK( lhmTool_FF_sav[savIndex]->addEvent(leptons, -extraweight/nEventsMultFactor) );
494  }
495  }
496 
497  // determine the expected number of fake lepton events
498  // start by looping over all possible number of tight leptons
499  vector<int> lep_indices;
500  std::bitset<64> tights, reals, charges;
501  for (int ilep(0); ilep < nlep_select; ilep++) {
502  lep_indices.push_back(ilep);
503  if (lep_real[ilep]) reals.set(ilep);
504  }
505 
506  if (pass == 0) {
507  for (long comb(0); comb < (1<<nlep_select); ++comb) {
508  tights = std::bitset<64>(comb);
509  if (fs[nlep_select]->accept_selection(tights, charges)) {
510  if (fs[nlep_select]->accept_process(nlep_select, reals, tights)) {
511  true_fakes += extraweight*comboProb(leptons_data, tights, reals);
512  }
513  }
514  }
515  // now see how many events actually passed the required selection
516  tights.reset();
517  for (int ilep = 0; ilep < nlep_select; ilep++) {
518  if (leptons[ilep]->auxdata<char>("Tight")) tights.set(ilep);
519  }
520  if (fs[nlep_select]->accept_selection(tights,charges) ) {
521  nevents_sel += extraweight;
522  }
523 
524  float wgt(1.);
525  ANA_CHECK( asmTool.getEventWeight(wgt, config.selection, config.process) );
526  asmYield += wgt;
527  asmErr += wgt*wgt;
528 
529  ANA_CHECK( fkfTool.getEventWeight(wgt, config.selection, config.process) );
530  fkfYield += wgt;
531  fkfErr += wgt*wgt;
532  } else {
533  // this is where the subtraction of the real contribution is simulated
534  if (all_real) {
535  float wgt(1.0);
536  ANA_CHECK( fkfTool.getEventWeight(wgt, config.selection, config.process) );
537  fkfYield -= wgt/nEventsMultFactor;
538  fkfErr += wgt*wgt/(nEventsMultFactor);
539  }
540  }
541 
542  if (config.test_save) {
543  if (pass == 0) {
544  if (ievt > 0 && (((nSave*ievt)%nevents_thiscase ==0) || ievt == nevents_thiscase -1) ) {
545  string saveFileName = config.saveFileNameBase;
546  saveFileName+= "_lhm_"+to_string(icase)+"_"+to_string(savIndex)+".root";
547  std::unique_ptr<TFile> saveFile(TFile::Open(saveFileName.c_str(), "RECREATE"));
548  ANA_CHECK( lhmTool_sav[savIndex]->saveProgress(saveFile->mkdir("fakes")) );
549  saveFile->Close();
550 
551  saveFileName = config.saveFileNameBase+"_asm_"+to_string(icase)+"_"+to_string(savIndex)+".root";
552  saveFile = std::make_unique<TFile>(saveFileName.c_str(), "RECREATE");
553  ANA_CHECK( asmTool_sav[savIndex]->saveProgress(saveFile.get()) );
554  saveFile->Close();
555 
556  savIndex++;
557  }
558  } else {
559  if (ievt > 0 && (((nSave*ievt)%(nevents_thiscase*nEventsMultFactor) ==0) || ievt == nevents_thiscase*nEventsMultFactor -1) ) {
560  string saveFileName = config.saveFileNameBase;
561 
562  saveFileName = config.saveFileNameBase+"_lhf_"+to_string(icase)+"_"+to_string(savIndex)+".root";
563  std::unique_ptr<TFile> saveFile(TFile::Open(saveFileName.c_str(), "RECREATE"));
564  ANA_CHECK( lhmTool_FF_sav[savIndex]->saveProgress(saveFile->mkdir("fakes")) );
565  saveFile->Close();
566 
567  saveFileName = config.saveFileNameBase+"_fkf_"+to_string(icase)+"_"+to_string(savIndex)+".root";
568  saveFile = std::make_unique<TFile>(saveFileName.c_str(), "RECREATE");
569  ANA_CHECK( fkfTool_sav[savIndex]->saveProgress(saveFile.get()) );
570  saveFile->Close();
571  savIndex++;
572 
573  float nfakes_tmp(0), err_tmp(0);
574  ANA_CHECK( fkfTool.getTotalYield(nfakes_tmp, err_tmp, err_tmp) );;
575  }
576  }
577  }
578 
579  for (xAOD::IParticleContainer::iterator it = leptons.begin(); it != leptons.end(); ++it) {
580  if (*it != nullptr) delete *it;
581  }
582  leptons.clear();
583  }
584  }
585  asm_err = sqrt(asmErr);
586  asm_fakes = asmYield;
587  ANA_CHECK( asmTool.getTotalYield(asmYield, asmErr, asmErr) );
588 
589 
590  ANA_CHECK( lhmTool.getTotalYield(lhoodMM_fakes, lhoodMM_poserr, lhoodMM_negerr) );
591 
592  ANA_CHECK( lhmTool_FF.getTotalYield(lhoodFF_fakes, lhoodFF_poserr, lhoodFF_negerr) );
593 
594  ANA_CHECK( fkfTool.getTotalYield(fkfYield, fkfErr, fkfErr) );
595  fkf_err = fkfErr;
596  fkf_fakes = fkfYield;
597 
598  if (config.test_systematics) {
599  auto sysvars = asmTool.affectingSystematics();
600  std::string systBrName, systBrNameF;
601 
602  for(auto& sysvar : sysvars){
603  if (config.verbose) asmTool.getSystDescriptor().printUncertaintyDescription(sysvar);
604 
605  float asm_syst_weight, asm_syst_err;
606  float fkf_syst_weight, fkf_syst_err;
607  float lhoodMM_syst_weight, lhoodMM_syst_poserr, lhoodMM_syst_negerr;
608  float lhoodFF_syst_weight, lhoodFF_syst_poserr, lhoodFF_syst_negerr;
609 
610  if (icase == 0) {
611  ANA_CHECK( setupSystBranches("asm", sysvar, asm_syst_weight, asm_syst_err, asm_weight_map, asm_err_map, ntuple) );
612  ANA_CHECK( setupSystBranches("fkf", sysvar, fkf_syst_weight, fkf_syst_err, fkf_weight_map, fkf_err_map, ntuple) );;
613  ANA_CHECK( setupSystBranchesAsym("lhoodMM", sysvar, lhoodMM_syst_weight, lhoodMM_syst_poserr, lhoodMM_syst_negerr, lhoodMM_weight_map, lhoodMM_poserr_map, lhoodMM_negerr_map, ntuple) );
614  ANA_CHECK( setupSystBranchesAsym("lhoodFF", sysvar, lhoodFF_syst_weight, lhoodFF_syst_poserr, lhoodFF_syst_negerr, lhoodFF_weight_map, lhoodFF_poserr_map, lhoodFF_negerr_map, ntuple) );
615  }
616  ANA_CHECK( asmTool.applySystematicVariation({sysvar}) );
617  ANA_CHECK( asmTool.getTotalYield(asm_weight_map.find(sysvar)->second,
618  asm_err_map.find(sysvar)->second,
619  asm_err_map.find(sysvar)->second));
620 
621  ANA_CHECK( fkfTool.applySystematicVariation({sysvar}) );;
622  ANA_CHECK( fkfTool.getTotalYield(fkf_weight_map.find(sysvar)->second,
623  fkf_err_map.find(sysvar)->second,
624  fkf_err_map.find(sysvar)->second) );
625  ANA_CHECK( lhmTool.applySystematicVariation({sysvar}) );;
626  ANA_CHECK( lhmTool.getTotalYield(lhoodMM_weight_map.find(sysvar)->second,
627  lhoodMM_poserr_map.find(sysvar)->second,
628  lhoodMM_negerr_map.find(sysvar)->second) );
629  ANA_CHECK( lhmTool_FF.applySystematicVariation({sysvar}) );;
630  ANA_CHECK( lhmTool_FF.getTotalYield(lhoodFF_weight_map.find(sysvar)->second,
631  lhoodFF_poserr_map.find(sysvar)->second,
632  lhoodFF_negerr_map.find(sysvar)->second) );
633  }
634  }
635 
636 
637  cout << "OUTPUT true_fakes = " << true_fakes << endl;
638  cout << "OUTPUT nfakes for lhoodMM = " << lhoodMM_fakes << " +" << lhoodMM_poserr << " -" << lhoodMM_negerr << endl;
639  cout << "OUTPUT nfakes for lhoodFF = " << lhoodFF_fakes << " +" << lhoodFF_poserr << " -" << lhoodFF_negerr << endl;
640  cout << "OUTPUT nfakes for asm = " << asm_fakes << " +- " << asm_err << endl;
641  cout << "OUTPUT nfakes for fkf = " << fkf_fakes << " +- " << fkf_err << endl;
642  cout << "OUTPUT true_fakes = " << true_fakes << endl;
643  } else {
644 
645  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) );
646  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) );
647  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) );
648  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) );
649  }
650 
651  ntuple->Fill();
652 
653  f_out->cd();
654  if (config.test_histo) {
655  h_lep_pt_lhoodMM->Write();
656  h_lep_eta_lhoodMM->Write();
657  h_lep_pt_eta_lhoodMM->Write();
658  h_lep_pt_lhoodFF->Write();
659  h_lep_eta_lhoodFF->Write();
660  h_lep_pt_eta_lhoodFF->Write();
661  h_lep_pt_asm->Write();
662  h_lep_eta_asm->Write();
663  h_lep_pt_eta_asm->Write();
664  h_lep_pt_fkf->Write();
665  h_lep_eta_fkf->Write();
666  h_lep_pt_eta_fkf->Write();
667 
668  delete h_lep_pt_lhoodMM;
669  delete h_lep_eta_lhoodMM;
670  delete h_lep_pt_eta_lhoodMM;
671  delete h_lep_pt_lhoodFF;
672  delete h_lep_eta_lhoodFF;
673  delete h_lep_pt_eta_lhoodFF;
674  delete h_lep_pt_asm;
675  delete h_lep_eta_asm;
676  delete h_lep_pt_eta_asm;
677  delete h_lep_pt_fkf;
678  delete h_lep_eta_fkf;
679  delete h_lep_pt_eta_fkf;
680 
681 
682  }
683  }
684 
685  f_out->Write();
686  f_out->Close();
687 
688  return StatusCode::SUCCESS;
689 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 129 of file fbtTestToyMC.cxx.

129  {
130  ANA_CHECK_SET_TYPE (int);
131 
133 
134  // defaults
135  config.nevents = 100;
136  config.ncases = 100;
137  config.realeff_mean = 0.90;
138  config.fakeeff_mean = 0.20;
139  config.eff_spread = 0.10;
140  config.eff_delta_with_pt = 0.;
141  config.minnbaseline = 1;
142  config.maxnbaseline = 4;
143  config.test_save = false;
144  config.saveFileNameBase = "saveProgress";
145  config.mergeFileNameBase = "saveProgress";
146  config.test_merge = false;
147  config.test_histo = false;
148  config.test_systematics = false;
149  config.poisson_fluctuations = false;
150  config.verbose = false;
151  config.selection = ">=1T";
152  config.process = ">=1F[T]";
153 
154  if (config.verbose) cout << "maxnbaseline = " << config.maxnbaseline << endl;
155 
157 
158  ANA_CHECK( Loop(config) );
159 }

◆ openRootFile()

std::unique_ptr< TFile > openRootFile ( fbtTestToyMC_config config)

Definition at line 874 of file fbtTestToyMC.cxx.

874  {
875  string outputdirname;
876  string rootfilename;
877  outputdirname = "FakeBkgTools_toy_MC_nevents_";
878  outputdirname += to_string(config.nevents);
879  outputdirname += "_ncases_";
880  outputdirname += to_string(config.ncases);
881  outputdirname += "_minnbaseline_";
882  outputdirname += to_string(config.minnbaseline);
883  outputdirname += "_maxnbaseline_";
884  outputdirname += to_string(config.maxnbaseline);
885  outputdirname += "_realeff_";
886  outputdirname += to_string(config.realeff_mean);
887  outputdirname += "_fakeeff_";
888  outputdirname += to_string(config.fakeeff_mean);
889  outputdirname += "_effspread_";
890  outputdirname += to_string(config.eff_spread);
891  outputdirname += "_selection_";
892  outputdirname += config.selection;
893  outputdirname += "_process_";
894  outputdirname += config.process;
895  if (config.poisson_fluctuations) {
896  outputdirname += "_poisson_";
897  }
898 
899  //now replace things like >, < from selection and process strings to get a
900  //legal directory name
901  size_t pos;
902  pos = outputdirname.find(">=");
903  while (pos != string::npos) {
904  outputdirname.replace(pos, 2, "ge");
905  pos = outputdirname.find(">=");
906  }
907  pos = outputdirname.find("<=");
908  while (pos != string::npos) {
909  outputdirname.replace(pos, 2, "le");
910  pos = outputdirname.find("<=");
911  }
912  pos = outputdirname.find(">");
913  while (pos != string::npos) {
914  outputdirname.replace(pos, 1, "gt");
915  pos = outputdirname.find(">");
916  }
917  pos = outputdirname.find("<");
918  while (pos != string::npos) {
919  outputdirname.replace(pos, 1, "lt");
920  pos = outputdirname.find("<");
921  }
922  pos = outputdirname.find("=");
923  while (pos != string::npos) {
924  outputdirname.replace(pos, 1, "eq");
925  pos = outputdirname.find("=");
926  }
927  pos = outputdirname.find(",");
928  while (pos != string::npos) {
929  outputdirname.replace(pos, 1, "");
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 
953  gSystem->mkdir(outputdirname.c_str());
954  rootfilename = outputdirname+"/output.root";
955 
956  config.outputdirname = outputdirname;
957 
958  std::unique_ptr<TFile> f_out(TFile::Open(rootfilename.c_str(),"RECREATE"));
959 
960  return f_out;
961 }

◆ parseArguments()

StatusCode parseArguments ( int  argc,
char *  argv[],
fbtTestToyMC_config config 
)

Definition at line 768 of file fbtTestToyMC.cxx.

768  {
769  static struct option long_options[] =
770  {
771  {"ncases", required_argument, 0, 'c'},
772  {"nevents", required_argument, 0, 'e'},
773  {"minnb", required_argument, 0, 'm'},
774  {"maxnb", required_argument, 0, 'n'},
775  {"rmean", required_argument, 0, 'r'},
776  {"fmean", required_argument, 0, 'f'},
777  {"effsigma", required_argument, 0, 's'},
778  {"effdeltawithpt", required_argument, 0, 'd'},
779  {"sel", required_argument, 0, 'l'},
780  {"proc", required_argument, 0, 'p'},
781  {"test_save", no_argument, 0, 'S'},
782  {"test_merge", required_argument, 0, 'M'},
783  {"test_histo", required_argument, 0, 'H'},
784  {"test_systematics", no_argument, 0, 'E'},
785  {"verbose", no_argument, 0, 'v'},
786  {"poisson", no_argument, 0, 'P'},
787  {"help", no_argument, 0, 'h'},
788  {0,0,0,0}
789  };
790 
791  int c;
792  // int optind;
793  int longindex = 0;
794 
795  while ((c = getopt_long(argc, argv, "c:e:m:n:r:f:s:d:l:p:S:M:HEPvh", long_options, &longindex)) != -1) {
796  switch(c) {
797  case 'c':
798  config.ncases = atoi(optarg);
799  break;
800  case 'e':
801  config.nevents = atoi(optarg);
802  break;
803  case 'r':
804  config.realeff_mean = atof(optarg);
805  break;
806  case 'f':
807  config.fakeeff_mean = atof(optarg);
808  break;
809  case 's':
810  config.eff_spread = atof(optarg);
811  break;
812  case 'd':
813  config.eff_delta_with_pt = atof(optarg);
814  break;
815  case 'l':
816  config.selection = optarg;
817  break;
818  case 'p':
819  config.process = optarg;
820  break;
821  case 'm':
822  config.minnbaseline = atoi(optarg);
823  break;
824  case 'n':
825  config.maxnbaseline = atoi(optarg);
826  break;
827  case 'S':
828  config.test_save = true;
829  config.saveFileNameBase = optarg;
830  break;
831  case 'M':
832  config.test_merge = true;
833  config.mergeFileNameBase = optarg;
834  break;
835  case 'H':
836  config.test_histo = true;
837  break;
838  case 'E':
839  config.test_systematics = true;
840  break;
841  case 'v':
842  config.verbose = true;
843  break;
844  case 'P':
845  config.poisson_fluctuations = true;
846  break;
847  case 'h':
848  ANA_CHECK( usage() );
849  exit(0);
850  case '?':
851  ANA_CHECK( usage() );
852  abort();
853  default:
854  abort();
855  }
856  }
857 
858  // remove any \ from selection and process strings
859  size_t pos;
860 
861  pos = config.selection.find("\"");
862  while (pos != string::npos) {
863  config.selection.replace(pos, 1, "");
864  pos = config.selection.find("\"");
865  }
866  pos = config.process.find("\"");
867  while (pos != string::npos) {
868  config.process.replace(pos, 1, "");
869  pos = config.process.find("\"");
870  }
871  return StatusCode::SUCCESS;
872 }

◆ setupEfficiencies()

StatusCode setupEfficiencies ( )

Definition at line 980 of file fbtTestToyMC.cxx.

980  {
981  rootEffFile = new TFile(rootEffFileName.c_str());
982  if (rootEffFile == 0) {
983  cout << "Um, no ROOT file!" << endl;
984  return StatusCode::FAILURE;
985  }
986 
987  h_realeff_e = (TH1F*)rootEffFile->Get("RealEfficiency_el_pt");
988  h_fakeeff_e = (TH1F*)rootEffFile->Get("FakeEfficiency_el_pt");
989  h_realeff_mu = (TH1F*)rootEffFile->Get("RealEfficiency_mu_pt");
990  h_fakeeff_mu = (TH1F*)rootEffFile->Get("FakeEfficiency_mu_pt");
991 
992  h_realeff_e->SetDirectory(0);
993  h_fakeeff_e->SetDirectory(0);
994  h_realeff_mu->SetDirectory(0);
995  h_fakeeff_mu->SetDirectory(0);
996 
997  if (h_realeff_e == 0) cout << "No real e" << endl;
998  if (h_fakeeff_e == 0) cout << "No fake e" << endl;
999  if (h_realeff_mu == 0) cout << "No real mu" << endl;
1000  if (h_fakeeff_mu == 0) cout << "No fake mu" << endl;
1001 
1002  rootEffFile->Close();
1003  delete rootEffFile;
1004  return StatusCode::SUCCESS;
1005 }

◆ 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 at line 1072 of file fbtTestToyMC.cxx.

1078  {
1079  syst_map.emplace(std::make_pair(sysvar, weight));
1080  std::string systBrName = baseName;
1081  systBrName = systBrName+"_fakes_"+sysvar.name();
1082  std::string systBrNameF = systBrName+"/F";
1083  ntuple->Branch(systBrName.c_str(), &(syst_map.find(sysvar)->second), systBrNameF.c_str());
1084  syst_err_map.emplace(std::make_pair(sysvar, weight_err));
1085  systBrName = baseName;
1086  systBrName = systBrName+"_err_"+sysvar.name();
1087  systBrNameF = systBrName+"/F";
1088  ntuple->Branch(systBrName.c_str(), &(syst_err_map.find(sysvar)->second), systBrNameF.c_str());
1089 
1090  return StatusCode::SUCCESS;
1091 }

◆ 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 at line 1093 of file fbtTestToyMC.cxx.

1101  {
1102  syst_map.emplace(std::make_pair(sysvar, weight));
1103  std::string systBrName = baseName;
1104  systBrName = systBrName+"_fakes_"+sysvar.name();
1105  std::string systBrNameF = systBrName+"/F";
1106  ntuple->Branch(systBrName.c_str(), &(syst_map.find(sysvar)->second), systBrNameF.c_str());
1107  syst_poserr_map.emplace(std::make_pair(sysvar, weight_poserr));
1108  systBrName = baseName;
1109  systBrName = systBrName+"_poserr_"+sysvar.name();
1110  systBrNameF = systBrName+"/F";
1111  ntuple->Branch(systBrName.c_str(), &(syst_poserr_map.find(sysvar)->second), systBrNameF.c_str());
1112  syst_negerr_map.emplace(std::make_pair(sysvar, weight_negerr));
1113  systBrName = baseName;
1114  systBrName = systBrName+"_negerr_"+sysvar.name();
1115  systBrNameF = systBrName+"/F";
1116  ntuple->Branch(systBrName.c_str(), &(syst_negerr_map.find(sysvar)->second), systBrNameF.c_str());
1117 
1118  return StatusCode::SUCCESS;
1119 }

◆ usage()

StatusCode usage ( )

Definition at line 1162 of file fbtTestToyMC.cxx.

1162  {
1163  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;
1164  std::cout << "Options: " << std::endl;
1165  std::cout << " --ncases, -c: number of pseudoexperiments to run (default: 100)" << std::endl;
1166  std::cout << " --nevents, -e: number of events in each pseudoexperiment (default: 100)" << std::endl;
1167  std::cout << " --poisson, -P: use Poisson-distributed number of events in each pseudoexperiment, rather than a fixed number (default: false)" << std::endl;
1168  std::cout << " --minnb, -m: minimum number of baseline leptons per event (default: 1)" << std::endl;
1169  std::cout << " --maxnb, -m: maximum number of baseline leptons per event (default: 4)" << std::endl;
1170  std::cout << " --rmean, -r: average real lepton efficiency (default: 0.9)" << std::endl;
1171  std::cout << " --fmean, -f: average fake lepton efficiency (default: 0.2)" << std::endl;
1172  std::cout << " --effsigma, -s: standard deviation for lepton-to-lepton variation in real and fake efficiencies (default: 0.10)" << std::endl;
1173  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;
1174  std::cout << " --sel, -l: selection string to be used by the tools (default \" >= 1T\") " << std::endl;
1175  std::cout << " --proc, -p: process string to be used by the tools (default \" >= 1F[T]\") " << std::endl;
1176  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;
1177  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;
1178  std::cout << " --test_histo, -H: test the filling of 1- and 2-dimensional histograms (default: false) " << std::endl;
1179  std::cout << " --test_systematics, -E: test the handling of systematic unceratinties (default: false) " << std::endl;
1180  std::cout << " --verbose, -v: enable verbose output (default: false) " << std::endl;
1181  std::cout << " --help, -h: print this help message" << std::endl;
1182  return StatusCode::SUCCESS;;
1183 }

◆ writeROOT()

StatusCode writeROOT ( const string &  name,
int  type,
float  realeff_mean,
float  fakeeff_mean,
float  eff_spread,
float  eff_delta_with_pt 
)

Definition at line 691 of file fbtTestToyMC.cxx.

691  {
692  TRandom3 rnd(235789);
693 
694  int nbin = 100;
695 
696  std::unique_ptr<TFile> file(TFile::Open(name.c_str(), "RECREATE"));
697 
698  if(type == 0)
699  {
700  TH1D hElFake("FakeEfficiency_el_pt","FakeEfficiency_el_pt", nbin, 0., 1.*nbin);
701  TH1D hMuFake("FakeEfficiency_mu_pt","FakeEfficiency_mu_pt", nbin, 0., 1.*nbin);
702  TH1D hElReal("RealEfficiency_el_pt","RealEfficiency_el_pt", nbin, 0., 1.*nbin);
703  TH1D hMuReal("RealEfficiency_mu_pt","RealEfficiency_mu_pt", nbin, 0., 1.*nbin);
704 
705  TH1D hElFake_bigSyst("FakeEfficiency_el_pt__bigSyst","FakeEfficiency_el_pt__bigSyst", nbin, 0., 1.*nbin);
706  TH1D hElFake_smallSyst("FakeEfficiency_el_pt__smallSyst","FakeEfficiency_el_pt__smallSyst", nbin, 0., 1.*nbin);
707  TH1D hMuFake_bigSyst("FakeEfficiency_mu_pt__bigSyst","FakeEfficiency_mu_pt__bigSyst", nbin, 0., 1.*nbin);
708  TH1D hMuFake_smallSyst("FakeEfficiency_mu_pt__smallSyst","FakeEfficiency_mu_pt__smallSyst", nbin, 0., 1.*nbin);
709  TH1D hElReal_bigSyst("RealEfficiency_el_pt__bigSyst","RealEfficiency_el_pt__bigSyst", nbin, 0., 1.*nbin);
710  TH1D hMuReal_bigSyst("RealEfficiency_mu_pt__bigSyst","RealEfficiency_mu_pt__bigSyst", nbin, 0., 1.*nbin);
711 
712  for (int ibin = 1; ibin <= nbin; ibin++) {
713  Double_t realeff = TMath::Min(rnd.Gaus(realeff_mean, eff_spread)+eff_delta_with_pt*(ibin-nbin/2), 0.99);
714  Double_t fakeeff = TMath::Max(rnd.Gaus(fakeeff_mean, eff_spread)-eff_delta_with_pt*(ibin-nbin/2), 0.01);
715 
716  float minrfdiff = 0.10;
717  if (realeff - fakeeff < minrfdiff) {
718  if (realeff > minrfdiff) {
719  fakeeff = realeff - minrfdiff;
720  } else {
721  realeff = realeff + 0.10;
722  }
723  }
724 
725  // sanity checks on the efficiencies
726  if (realeff < 0 || realeff > 1.) cout << "ERROR: Bad real efficiency value: " << realeff << endl;
727  if (fakeeff < 0 || fakeeff > 1.) cout << "ERROR: Bad fake efficiency value: " << fakeeff << endl;
728  if ((realeff - fakeeff) < minrfdiff) cout << "ERROR: Too small difference between real and fake efficiencies: " << realeff << " " << fakeeff << endl;
729 
730  hElFake.SetBinContent(ibin, fakeeff);
731  hElFake.SetBinError(ibin, eff_spread);
732  //hElFake.SetBinError(ibin, 0.);
733  hMuFake.SetBinContent(ibin, fakeeff);
734  hMuFake.SetBinError(ibin, eff_spread);
735  //hMuFake.SetBinError(ibin, 0.);
736  hElReal.SetBinContent(ibin, realeff);
737  hElReal.SetBinError(ibin, eff_spread);
738  //hElReal.SetBinError(ibin, 0.);
739  hMuReal.SetBinContent(ibin, realeff);
740  hMuReal.SetBinError(ibin, eff_spread);
741  //hMuReal.SetBinError(ibin, 0.);
742 
743  hElFake_bigSyst.SetBinContent(ibin, 0.20*hElFake.GetBinContent(ibin));
744  hElFake_smallSyst.SetBinContent(ibin, 0.02*hElFake.GetBinContent(ibin));
745  hMuFake_bigSyst.SetBinContent(ibin, 0.20*hMuFake.GetBinContent(ibin));
746  hMuFake_smallSyst.SetBinContent(ibin, 0.02*hMuFake.GetBinContent(ibin));
747  hElReal_bigSyst.SetBinContent(ibin, 0.20*hElReal.GetBinContent(ibin));
748  hMuReal_bigSyst.SetBinContent(ibin, 0.20*hMuReal.GetBinContent(ibin));
749 
750  }
751 
752  file->cd();
753  hElFake.Write();
754  hElReal.Write();
755  hMuFake.Write();
756  hMuReal.Write();
757  hElFake_bigSyst.Write();
758  hElReal_bigSyst.Write();
759  hElFake_smallSyst.Write();
760  hMuFake_bigSyst.Write();
761  hMuFake_smallSyst.Write();
762  hMuReal_bigSyst.Write();
763  }
764  file->Close();
765  return StatusCode::SUCCESS;
766 }

◆ writeXML()

StatusCode writeXML ( const string &  name,
int  type 
)

Variable Documentation

◆ err_std

double err_std

Definition at line 108 of file fbtTestToyMC.cxx.

◆ f_stdneg_lhood_pos

std::ofstream* f_stdneg_lhood_pos

Definition at line 124 of file fbtTestToyMC.cxx.

◆ f_stdpos_lhood_0

std::ofstream* f_stdpos_lhood_0

Definition at line 125 of file fbtTestToyMC.cxx.

◆ fitFailed

bool fitFailed

Definition at line 113 of file fbtTestToyMC.cxx.

◆ h_fakeeff_e

TH1F * h_fakeeff_e

Definition at line 69 of file fbtTestToyMC.cxx.

◆ h_fakeeff_mu

TH1F * h_fakeeff_mu

Definition at line 69 of file fbtTestToyMC.cxx.

◆ h_realeff_e

TH1F* h_realeff_e

Definition at line 69 of file fbtTestToyMC.cxx.

◆ h_realeff_mu

TH1F * h_realeff_mu

Definition at line 69 of file fbtTestToyMC.cxx.

◆ n_fake_lhood

Double_t n_fake_lhood

Definition at line 119 of file fbtTestToyMC.cxx.

◆ n_fake_lhood_tot_negerr

Double_t n_fake_lhood_tot_negerr

Definition at line 122 of file fbtTestToyMC.cxx.

◆ n_fake_lhood_tot_poserr

Double_t n_fake_lhood_tot_poserr

Definition at line 121 of file fbtTestToyMC.cxx.

◆ nSave

const int nSave = 4

Definition at line 127 of file fbtTestToyMC.cxx.

◆ rootEffFile

TFile* rootEffFile

Definition at line 70 of file fbtTestToyMC.cxx.

◆ rootEffFileName

string rootEffFileName

Definition at line 115 of file fbtTestToyMC.cxx.

◆ totWeight_std

double totWeight_std

Definition at line 107 of file fbtTestToyMC.cxx.

◆ weight_lepfakes_2tight

double weight_lepfakes_2tight

Definition at line 109 of file fbtTestToyMC.cxx.

◆ weight_lepfakes_2tight_1loose

double weight_lepfakes_2tight_1loose

Definition at line 111 of file fbtTestToyMC.cxx.

◆ weight_lepfakes_3tight

double weight_lepfakes_3tight

Definition at line 110 of file fbtTestToyMC.cxx.

h_realeff_mu
TH1F * h_realeff_mu
Definition: fbtTestToyMC.cxx:69
comboProb
double comboProb(const vector< FakeBkgTools::ParticleData > &leptons_data, const std::bitset< 64 > &tights, const std::bitset< 64 > &reals)
Definition: fbtTestToyMC.cxx:1023
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:127
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:272
h_fakeeff_mu
TH1F * h_fakeeff_mu
Definition: fbtTestToyMC.cxx:69
n_fake_lhood_tot_negerr
Double_t n_fake_lhood_tot_negerr
Definition: fbtTestToyMC.cxx:122
usage
StatusCode usage()
Definition: fbtTestToyMC.cxx:1162
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:69
skel.it
it
Definition: skel.GENtoEVGEN.py:423
downloadSingle.saveFile
saveFile
Definition: downloadSingle.py:30
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
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
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
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
lookupEfficiencies
StatusCode lookupEfficiencies(xAOD::IParticle &lepton, ParticleData &lepton_data)
Definition: fbtTestToyMC.cxx:1007
handi.long_options
list long_options
Definition: handi.py:43
setupEfficiencies
StatusCode setupEfficiencies()
Definition: fbtTestToyMC.cxx:980
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
initialize
StatusCode initialize(CP::BaseFakeBkgTool &tool, const std::vector< std::string > &input, const std::string &selection, const std::string &process, bool verbose)
Definition: fbtTestToyMC.cxx:963
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
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:1093
parseArguments
StatusCode parseArguments(int argc, char *argv[], fbtTestToyMC_config &config)
Definition: fbtTestToyMC.cxx:768
xAOD::Electron_v1::setCharge
void setCharge(float charge)
set the charge of the object
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:135
totWeight_std
double totWeight_std
Definition: fbtTestToyMC.cxx:107
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:70
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
err_std
double err_std
Definition: fbtTestToyMC.cxx:108
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
file
TFile * file
Definition: tile_monitor.h:29
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
h_fakeeff_e
TH1F * h_fakeeff_e
Definition: fbtTestToyMC.cxx:69
selection
std::string selection
Definition: fbtTestBasics.cxx:73
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
openRootFile
std::unique_ptr< TFile > openRootFile(fbtTestToyMC_config &config)
Definition: fbtTestToyMC.cxx:874
calibdata.exit
exit
Definition: calibdata.py:236
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:1072
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
n_fake_lhood
Double_t n_fake_lhood
Definition: fbtTestToyMC.cxx:119
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
rootEffFileName
string rootEffFileName
Definition: fbtTestToyMC.cxx:115
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
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:121
xAOD::Electron_v1
Definition: Electron_v1.h:34
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
downloadSingle.saveFileName
string saveFileName
Definition: downloadSingle.py:40
FakeBkgTools::FinalState
Definition: FakeBkgInternals.h:98
FakeBkgTools::Efficiency::nominal
float nominal
Definition: FakeBkgInternals.h:42
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:128
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:691
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
F
#define F(x, y, z)
Definition: MD5.cxx:112
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:72
xAOD::IParticle::auxdata
T & auxdata(const std::string &name, const std::string &clsname="")
Fetch an aux data variable, as a non-const reference.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:96
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
CP::LhoodMM_tools
Definition: LhoodMM_tools.h:29
fbtTestToyMC_config
Definition: fbtTestToyMC.cxx:42
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
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
Loop
StatusCode Loop(fbtTestToyMC_config config)
Definition: fbtTestToyMC.cxx:161
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:187
FakeBkgTools::ParticleData::fake_efficiency
Efficiency fake_efficiency
Definition: FakeBkgInternals.h:86
doMerge
StatusCode doMerge(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)
Definition: fbtTestToyMC.cxx:1121
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70
python.compressB64.c
def c
Definition: compressB64.py:93
CP::AsymptMatrixTool
Definition: AsymptMatrixTool.h:21
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:159