ATLAS Offline Software
BaseFakeBkgTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "xAODEgamma/Electron.h"
9 #include "xAODEgamma/Photon.h"
10 #include "xAODMuon/Muon.h"
11 #include "xAODTau/TauJet.h"
13 
14 #ifndef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
15  #define declareProperty(n, p, h) declareProperty(n, &BaseFakeBkgTool::p, h)
16 #endif
17 
18 #include <TFile.h>
19 #include <TH2F.h>
20 #include <TH3.h>
21 #include <string>
22 #include <vector>
23 #include <regex>
24 #include <stdexcept>
25 
26 using namespace FakeBkgTools;
27 using namespace CP;
28 
29 BaseFakeBkgTool::BaseFakeBkgTool(const std::string& toolname) : AsgTool(toolname),
30  m_initialized(false), m_database(nullptr), m_energyUnit("MeV"), m_tightDecoNameAndType("Tight,as_char"), m_progressFileName("none"), m_progressFileDirectory("")
31 {
33 
34  declareProperty("InputFiles", m_inputFiles, "list of XML/ROOT files storing the efficiencies [default = {}]. If left empty, the tool assumes that efficiencies are provided by the user as decorations (xAOD) or class members (standalone) of the lepton objects");
35 
37  declareProperty("Selection", m_selection, "Selection used to increment total yield / fill histograms [default = \"" + m_selection +"\"]");
38 
40  declareProperty("Process", m_process, "Process used to increment total yield / fill histograms [default = \"" + m_process +"\"]");
41 
42  declareProperty("EnergyUnit", m_energyUnit, "MeV or GeV -- keep consistent between the input (IParticle decorations/members) and the configuration files! [default = \"MeV\"]");
43 
44  declareProperty("ConvertWhenMissing", m_convertWhenMissing, "set to 'true' to compute fake factors from fake efficiencies if only the latter are provided in the config files (and vice-versa) [default = false]");
45 
46  declareProperty("TightDecoration", m_tightDecoNameAndType, "Name (and type) of the decoration used to indicate whether leptons pass the 'tight' requirements or not [default = \"Tight,as_char\"]");
47 
48  declareProperty("ProgressFileName", m_progressFileName, "Name of ntuple file with results from a subset of the data");
49 
50  declareProperty("ProgressFileDirectory", m_progressFileDirectory, "complementary to ProgressFileName, specifies the directory inside the file where the results are stored [default = \"\"]");
51 }
52 
54 {
55  delete m_tightAccessor;
56 }
57 
59 {
60  return Client::NONE;
61 }
62 
64 {
65  if(m_initialized)
66  {
67  ATH_MSG_WARNING("the tool has already been initialized successfully");
68  return StatusCode::FAILURE;
69  }
70 
71  m_useDB = m_inputFiles.size();
72 
73  bool useGeV;
74  if(m_energyUnit == "MeV" || m_energyUnit == "MEV") useGeV = false;
75  else if(m_energyUnit == "GeV" || m_energyUnit == "GEV" ) useGeV = true;
76  else
77  {
78  ATH_MSG_ERROR("unrecognized energy unit \"" << m_energyUnit << '"');
79  return StatusCode::FAILURE;
80  }
81 
82  std::unique_ptr<CP::ISelectionReadAccessor> tightAccessor;
84  m_tightAccessor = tightAccessor.release();
85 
86  if(!m_useDB)
87  {
88  ATH_MSG_WARNING("no input file(s) provided with the reference efficiencies, will try reading the efficiencies directly from the IParticle");
89  }
90 
92  {
93  auto db = new Database(clientForDB(), useGeV, m_convertWhenMissing);
94  if(!db) return StatusCode::FAILURE;
95  m_database = std::unique_ptr<Database>(db);
96  if(!importEfficiencies(true)){
97  ATH_MSG_ERROR("importEfficiencies failed!");
98  return StatusCode::FAILURE;
99  }
100  m_needEventInfo = db->needEventInfo();
101  }
102  else m_needEventInfo = false;
103 
104  m_initialized = true;
105 
106  return StatusCode::SUCCESS;
107 }
108 
110 {
111  if(resetDB) m_database->reset();
112  std::string filename;
113  try
114  {
115  for(const auto& fn : m_inputFiles)
116  {
117  filename = fn;
118  auto pos = filename.rfind(".xml");
119  if(pos == filename.length()-4)
120  {
121  m_database->importXML(filename);
122  continue;
123  }
124  pos = filename.rfind(".root");
125  if(pos == filename.length()-5)
126  {
127  m_database->importDefaultROOT(fn);
128  continue;
129  }
130  ATH_MSG_ERROR("File extension not supported for " << filename);
131  return false;
132  }
133  }
134  catch(const Database::XmlError& err)
135  {
136  unsigned line1 = m_database->getXmlLineNumber(err.location.ptr);
137  unsigned line2 = m_database->getXmlLineNumber(err.location.endptr);
138  ATH_MSG_INFO("Exception caught while reading file " << filename << ", details follow");
139  std::string fullmsg = "(while parsing XML, line";
140  if(line2 != line1) fullmsg += "s " + std::to_string(line1) + " - " + std::to_string(line2);
141  else fullmsg += " " + std::to_string(line1);
142  fullmsg += "): " + err.reason;
143  ATH_MSG_ERROR(fullmsg);
144  return false;
145  }
146  catch(const Database::GenericError& err)
147  {
148  ATH_MSG_INFO("Exception caught while reading file " << filename << ", details follow");
149  ATH_MSG_ERROR(err.reason);
150  return false;
151  }
152  return m_database->ready();
153 }
154 
156 {
157  if(!m_initialized)
158  {
159  ATH_MSG_WARNING("the tool hasn't been initialized");
160  return StatusCode::FAILURE;
161  }
162  m_particles.clear();
164 
165  const xAOD::EventInfo* eventInfo = nullptr;
166  if(m_needEventInfo)
167  {
168  #ifdef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
169  ATH_CHECK( evtStore()->retrieve(eventInfo, "EventInfo") );
170  #else
171  eventInfo = &iparticles.eventInfo;
172  #endif
173  }
174 
175  for(const auto& pp : iparticles)
176  {
177  const auto& p = *pp;
178  m_particles.emplace_back();
179  auto& d = m_particles.back();
180  d.tight = m_tightAccessor->getBool(p);
181  d.type = p.type();
182  switch(p.type())
183  {
184  case xAOD::Type::Electron: d.charge = static_cast<const xAOD::Electron&>(p).charge(); break;
185  case xAOD::Type::Muon: d.charge = static_cast<const xAOD::Muon&>(p).charge(); break;
186  case xAOD::Type::Tau: d.charge = static_cast<const xAOD::TauJet&>(p).charge(); break;
187  case xAOD::Type::Photon: d.charge = 0; break;
188  default:
189  ATH_MSG_WARNING("unknown particle type, setting charge to 0");
190  d.charge = 0;
191  }
192  if(m_useDB)
193  {
194  std::string error;
195  if(!m_database->fillEfficiencies(d, p, *eventInfo, error))
196  {
197  ATH_MSG_ERROR("unable to retrieve efficiencies: " << error);
198  return StatusCode::FAILURE;
199  }
200  ATH_MSG_DEBUG("particle has fake fact. = " << d.fake_factor.value(this) <<", fake eff. = " << d.fake_efficiency.value(this) <<", real eff. = " << d.real_efficiency.value(this));
201  }
202  else
203  {
204  d.real_efficiency.nominal = p.auxdataConst<float>("real_eff");
205  d.fake_efficiency.nominal = p.auxdataConst<float>("fake_eff");
206  }
207  }
208  if(m_particles.size() > maxParticles())
209  {
210  ATH_MSG_WARNING( "the input contains " << m_particles.size() << " particles but the maximum allowed is " << maxParticles()
211  << "; the last " << (m_particles.size()-maxParticles()) << " will be ignored");
212  m_particles.erase(m_particles.begin() + maxParticles(), m_particles.end());
213  }
214  m_externalWeight = mcWeight;
215  ATH_MSG_DEBUG("calling addEventCustom() with #particles = " << m_particles.size());
216  return addEventCustom();
217 }
218 
219 FinalState BaseFakeBkgTool::getCachedFinalState(uint8_t nparticles, const std::string& strPID, const std::string& strProc, bool& success)
220 {
221  success = true;
222  size_t hFS = m_hasher(strProc) ^ m_hasher(strPID) ^ nparticles;
223  auto itrFS = m_cachedFinalStates.find(FinalState(hFS));
224  if(itrFS != m_cachedFinalStates.end()) return *itrFS;
225  std::string error;
226  FinalState fs(hFS, nparticles, strPID, strProc, error);
227  if(error.length())
228  {
230  success = false;
231  return FinalState(0);
232  }
233  if(m_cachedFinalStates.size() < 1024)
234  {
235  m_cachedFinalStates.emplace(fs);
236  }
237  return fs;
238 }
239 
241 
242  if(!h1)
243  {
244  ATH_MSG_ERROR("invalid histogram pointer");
245  return StatusCode::FAILURE;
246  }
247  const std::string name = h1->GetName();
248  auto itr = m_values_1dhisto_map.begin();
249  const auto enditr = m_values_1dhisto_map.end();
250  for(;itr!=enditr;++itr)
251  {
252  if(itr->first == h1)
253  {
254  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
255  return StatusCode::FAILURE;
256  }
257  if(name == itr->first->GetName()) break;
258  }
259  if(itr == enditr)
260  {
261  m_values_1dhisto_map.emplace(h1, val);
262  }
263  else
264  {
265  ATH_CHECK( CheckHistogramCompatibility(h1, itr->first) );
266  }
267  return StatusCode::SUCCESS;
268 }
269 
270 StatusCode BaseFakeBkgTool::register2DHistogram(TH2* h2, const float *xval, const float *yval) {
271 
272  if(!h2)
273  {
274  ATH_MSG_ERROR("invalid histogram pointer");
275  return StatusCode::FAILURE;
276  }
277  const std::string name = h2->GetName();
278  auto itr = m_values_2dhisto_map.begin();
279  const auto enditr = m_values_2dhisto_map.end();
280  for(;itr!=enditr;++itr)
281  {
282  if(itr->first == h2)
283  {
284  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
285  return StatusCode::FAILURE;
286  }
287  if(name == itr->first->GetName()) break;
288  }
289  if(itr == enditr)
290  {
291  m_values_2dhisto_map.emplace(h2, std::make_pair(xval, yval));
292  }
293  else
294  {
295  ATH_CHECK( CheckHistogramCompatibility(h2, itr->first) );
296  }
297  return StatusCode::SUCCESS;
298 }
299 
300  StatusCode BaseFakeBkgTool::register3DHistogram(TH3* h3, const float *xval, const float *yval, const float *zval) {
301 
302  if(!h3)
303  {
304  ATH_MSG_ERROR("invalid histogram pointer");
305  return StatusCode::FAILURE;
306  }
307  const std::string name = h3->GetName();
308  auto itr = m_values_3dhisto_map.begin();
309  const auto enditr = m_values_3dhisto_map.end();
310  for(;itr!=enditr;++itr)
311  {
312  if(itr->first == h3)
313  {
314  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
315  return StatusCode::FAILURE;
316  }
317  if(name == itr->first->GetName()) break;
318  }
319  if(itr == enditr)
320  {
321 m_values_3dhisto_map.emplace(h3, std::make_tuple(xval, yval, zval));
322  }
323  else
324  {
325  ATH_CHECK( CheckHistogramCompatibility(h3, itr->first) );
326  }
327  return StatusCode::SUCCESS;
328 }
329 
331 {
332  std::string error;
333  if(std::string(lhs->GetName()) != rhs->GetName()) error = "names";
334  else if(lhs->GetDimension() != rhs->GetDimension()) error = "dimensions";
335  else if(lhs->GetNbinsX()!=rhs->GetNbinsX() || lhs->GetNbinsY()!=rhs->GetNbinsY() || lhs->GetNbinsZ()!=rhs->GetNbinsZ()) error = "number of bins";
336  else
337  {
338  for(auto getAxis : std::initializer_list<const TAxis*(TH1::*)()const>{&TH1::GetXaxis, &TH1::GetYaxis, &TH1::GetZaxis})
339  {
340  auto lhsAxis=(lhs->*getAxis)(), rhsAxis=(rhs->*getAxis)();
341  for(int i=0;i<=lhsAxis->GetNbins();++i)
342  {
343  auto x=lhsAxis->GetBinUpEdge(i), y=rhsAxis->GetBinUpEdge(i), width=lhsAxis->GetBinWidth(i?i:1);
344  if(std::fabs(x-y) > 0.01*width) error = "bin edges";
345  }
346  }
347  }
348  if(error.length())
349  {
350  ATH_MSG_ERROR("the registered histogram \"" << lhs->GetName() << "\" is not compatible with the one saved in the in-progress ROOT file (mismatching " << error << "). Or, you tried registering two different histograms with the same name.");
351  return StatusCode::FAILURE;
352  }
353  return StatusCode::SUCCESS;
354 }
355 
356 std::string BaseFakeBkgTool::getListOfEfficienciesAffectedBy(unsigned short uid) const
357 {
358  if(!m_initialized || !m_database)
359  {
360  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
361  return "";
362  }
363  std::bitset<Database::N_EFFICIENCY_TYPES> affects;
364  auto stat = m_database->findStat(uid);
365  if(stat) affects = stat->affects;
366  else
367  {
368  auto syst = m_database->findSyst(uid);
369  if(syst) affects = syst->affects;
370  else
371  {
372  ATH_MSG_ERROR("uncertainty with UID " << std::hex << uid << std::dec << " not found in database");
373  return "";
374  }
375  }
376  std::string info;
377  if(affects[Database::ELECTRON_REAL_EFFICIENCY]) info += "electron real efficiencies, ";
378  if(affects[Database::ELECTRON_FAKE_EFFICIENCY]) info += "electron fake efficiencies, ";
379  if(affects[Database::ELECTRON_FAKE_FACTOR]) info += "electron fake factors, ";
380  if(affects[Database::MUON_REAL_EFFICIENCY]) info += "muon real efficiencies, ";
381  if(affects[Database::MUON_FAKE_EFFICIENCY]) info += "muon fake efficiencies, ";
382  if(affects[Database::MUON_FAKE_FACTOR]) info += "muon fake factors, ";
383  if(affects[Database::PHOTON_ELE_FAKE_FACTOR]) info += "electron->photon fake rate, ";
384  if(affects[Database::PHOTON_ELE_FAKE_FACTOR_SF]) info += "electron->photon fake rate scale factor, ";
385  return info.substr(0, info.size()-2);
386 }
387 
388 std::pair<uint16_t, float> BaseFakeBkgTool::identifyCpSystematicVariation(const CP::SystematicVariation& systematic) const
389 {
390  if(!m_initialized || !m_database)
391  {
392  ATH_MSG_ERROR("This function can be called only once the tool has been initialized, since the number of systematic variations depends on the configuration...");
393  throw std::logic_error("BaseFakeBkgTool::identifyCpSystematicVariation() called before initialization");
394  }
395  std::smatch smr;
396  auto bn = systematic.basename();
397  if(!std::regex_match(bn, smr, std::regex("FAKEBKG_(STAT|SYST)_VAR(\\d+)"))) return {{0}, 0.f};
398  unsigned index = std::stol(smr[2].str());
399  float sigma = systematic.parameter();
400  if(smr[1].str() == "SYST") return {m_database->systIndexToUID(index), sigma};
401  else return {m_database->statIndexToUID(index), sigma};
402 }
403 
405 {
406  return identifyCpSystematicVariation(systematic).first;
407 }
408 
410 {
411  if(!m_initialized || !m_database)
412  {
413  ATH_MSG_ERROR("This function can be called only once the tool has been initialized, since the number of systematic variations depends on the configuration...");
414  throw std::logic_error("BaseFakeBkgTool::affectingSystematics() called before initialization");
415  }
416  CP::SystematicSet affecting;
417  for(int step=0;step<2;++step)
418  {
419  std::string type = step? "STAT" : "SYST";
420  const int imax = step? m_database->numberOfStats() : m_database->numberOfSysts();
421  for(int i=0;i<imax;++i)
422  {
423  std::string name = "FAKEBKG_" + type + "_VAR" + std::to_string(i);
424  affecting.insert(CP::SystematicVariation(name, 1.f));
425  affecting.insert(CP::SystematicVariation(name, -1.f));
426  }
427  }
428  return affecting;
429 }
430 
432 {
433  return affectingSystematics();
434 }
435 
437 {
438  if(!m_initialized || !m_database)
439  {
440  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
441  throw std::logic_error("BaseFakeBkgTool::applySystematicVariation() called before initialization");
442  }
444  {
445  ATH_MSG_ERROR("this particular method doesn't support multiple calls to applySystematicVariation(), or after the first call to addEvent(). Please use a separate instance of the tool for each variation.");
446  throw std::logic_error("BaseFakeBkgTool::applySystematicVariation() called at a wrong time");
447  }
449  if(!systConfig.size())
450  {
451  m_selectedUncertainties = nullptr;
452  return StatusCode::SUCCESS;
453  }
454  auto itr = m_systSetDict.find(systConfig);
455  if(itr != m_systSetDict.end())
456  {
457  m_selectedUncertainties = &itr->second;
458  return StatusCode::SUCCESS;
459  }
460  CP::SystematicSet mysys;
462  if(sc != StatusCode::SUCCESS) return sc;
463  std::unique_ptr<UncertaintyList> uncertainties;
464  for(auto& sysvar : mysys)
465  {
466  auto var = identifyCpSystematicVariation(sysvar);
467  if(!var.first)
468  {
469  ATH_MSG_ERROR("The systematic variation " << sysvar.name() << " is not recognized, despite being present in affectingSystematics()...");
470  return StatusCode::FAILURE;
471  }
472  if(!uncertainties) uncertainties.reset(new UncertaintyList(var.first, var.second));
473  else uncertainties->extraVariation(var.first, var.second);
474  }
475  if(uncertainties)
476  {
477  auto emplaced = m_systSetDict.emplace(systConfig, std::move(*uncertainties));
478  m_selectedUncertainties = &emplaced.first->second;
479  }
480  else m_selectedUncertainties = nullptr;
481  return StatusCode::SUCCESS;
482 }
483 
485 {
486  auto info = getUncertaintyDescription(systematic);
487  if(info.length()) ATH_MSG_INFO(info);
488 }
489 
491 {
492  if(!m_initialized || !m_database)
493  {
494  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
495  return "";
496  }
497 
498  auto UID = identifyCpSystematicVariation(systematic).first;
499  if(!UID)
500  {
501  ATH_MSG_WARNING("Systematic variation " + systematic.name() + " is not recognized by BaseFakeBkgTool");
502  return "";
503  }
504 
505  if(UID == 0)
506  {
507  return "Total statistical uncertainty in the event yield";
508  }
509  std::string info;
510  auto stat = m_database->findStat(UID);
511  if(stat)
512  {
513  info = "Statistical uncertainty affecting ";
515  }
516  else
517  {
518  auto syst = m_database->findSyst(UID);
519  if(syst)
520  {
521  info = "Systematic uncertainty \"" + syst->name + "\" affecting ";
522  }
523  else
524  {
525  ATH_MSG_ERROR("uncertainty with UID " << std::hex << UID << std::dec << " not found in database");
526  return "";
527  }
528  }
530  return info;
531 }
532 
534 {
535  uint16_t UID = identifyCpSystematicVariation(systematic).first;
536  if(UID) return Database::isSystUID(UID);
537  return false;
538 }
539 
541 {
542  uint16_t UID = identifyCpSystematicVariation(systematic).first;
543  if(UID) return Database::isStatUID(UID);
544  return false;
545 }
546 
548 {
549  uint16_t UID = identifyCpSystematicVariation(systematic).first;
550  if(UID) return getListOfEfficienciesAffectedBy(UID).find("electron") != std::string::npos;
551  return false;
552 }
553 
555 {
556  uint16_t UID = identifyCpSystematicVariation(systematic).first;
557  if(UID) return getListOfEfficienciesAffectedBy(UID).find("muon") != std::string::npos;
558  return false;
559 }
560 
562 {
563  uint16_t UID = identifyCpSystematicVariation(systematic).first;
564  if(UID) return getListOfEfficienciesAffectedBy(UID).find("tau") != std::string::npos;
565  return false;
566 }
567 
569 {
570  uint16_t UID = identifyCpSystematicVariation(systematic).first;
571  if(UID) return getListOfEfficienciesAffectedBy(UID).find("real eff") != std::string::npos;
572  return false;
573 }
574 
576 {
577  uint16_t UID = identifyCpSystematicVariation(systematic).first;
578  if(UID) return getListOfEfficienciesAffectedBy(UID).find("fake eff") != std::string::npos;
579  return false;
580 }
581 
583 {
584  uint16_t UID = identifyCpSystematicVariation(systematic).first;
585  if(UID) return getListOfEfficienciesAffectedBy(UID).find("fake factor") != std::string::npos;
586  return false;
587 }
588 
589 CP::SystematicSet BaseFakeBkgTool::affectingSystematicsFor(const std::string& nuisanceParameter) const
590 {
591  CP::SystematicSet affecting;
592  if(!m_initialized || !m_database)
593  {
594  ATH_MSG_ERROR("This function can be called only once the tool has been initialized, since the number of systematic variations depends on the configuration...");
595  return {};
596  }
597  bool up=true, down=true;
598  auto pos1=nuisanceParameter.find("__up"), pos2=nuisanceParameter.find("__down");
599  if(pos1!=std::string::npos && pos1+4==nuisanceParameter.length()) down = false;
600  else if(pos2!=std::string::npos && pos2+6==nuisanceParameter.length()) up = false;
601  std::string np = nuisanceParameter.substr(0, std::min(pos1, pos2));
602  for(unsigned i=0;i<m_database->numberOfSysts();++i)
603  {
604  auto syst = m_database->findSyst(m_database->systIndexToUID(i));
605  if(syst && syst->name==np)
606  {
607  std::string name = "FAKEBKG_SYST_VAR" + std::to_string(i);
608  if(up) affecting.insert(CP::SystematicVariation(name, 1.f));
609  if(down) affecting.insert(CP::SystematicVariation(name, -1.f));
610  }
611  }
612  return affecting;
613 }
grepfile.info
info
Definition: grepfile.py:38
CP::BaseFakeBkgTool::CheckHistogramCompatibility
StatusCode CheckHistogramCompatibility(const TH1 *lhs, const TH1 *rhs)
Definition: BaseFakeBkgTool.cxx:330
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::BaseFakeBkgTool::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: BaseFakeBkgTool.cxx:240
NONE
@ NONE
Definition: sTGCenumeration.h:13
python.changerun.bn
bn
Definition: changerun.py:79
CP::BaseFakeBkgTool::getUncertaintyDescription
virtual std::string getUncertaintyDescription(const CP::SystematicVariation &systematic) const override final
returns a human-readable description of the source of systematic uncertainty specified as argument
Definition: BaseFakeBkgTool.cxx:490
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
CP::BaseFakeBkgTool::getCachedFinalState
FakeBkgTools::FinalState getCachedFinalState(uint8_t nparticles, const std::string &strPID, const std::string &strProc, bool &success)
Definition: BaseFakeBkgTool.cxx:219
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
pdg_comparison.sigma
sigma
Definition: pdg_comparison.py:324
python.exampleDriverScript.Database
Database
Definition: exampleDriverScript.py:28
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CP::BaseFakeBkgTool::m_inputFiles
std::vector< std::string > m_inputFiles
property InputFiles
Definition: BaseFakeBkgTool.h:127
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
CP::SystematicVariation::basename
std::string basename() const
description: the base name, i.e.
Definition: SystematicVariation.cxx:312
CP::BaseFakeBkgTool::m_useDB
bool m_useDB
Definition: BaseFakeBkgTool.h:124
CP::BaseFakeBkgTool::identifyCpSystematicVariation
std::pair< uint16_t, float > identifyCpSystematicVariation(const CP::SystematicVariation &systematic) const
Definition: BaseFakeBkgTool.cxx:388
Muon.h
CP::SystematicSet::size
size_t size() const
returns: size of the set
Definition: SystematicSet.h:71
LArG4FSStartPointFilterLegacy.line1
line1
Definition: LArG4FSStartPointFilterLegacy.py:58
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CP::BaseFakeBkgTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
the list of all systematics this tool recommends to use
Definition: BaseFakeBkgTool.cxx:431
hist_file_dump.d
d
Definition: hist_file_dump.py:137
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:436
FakeBkgTools::Database::GenericError
This propagates an error message.
Definition: Database.h:136
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
CP::SystematicVariation::name
const std::string & name() const
description: the full systematics name, for use in strings, etc.
Definition: SystematicVariation.cxx:303
CP::BaseFakeBkgTool::m_lockedSystematicVariations
bool m_lockedSystematicVariations
when m_unlimitedSystematicVariations=false, keeps track of prior calls to applySystematicVariation() ...
Definition: BaseFakeBkgTool.h:173
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::BaseFakeBkgTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
Declare the interface that this class provides.
Definition: BaseFakeBkgTool.cxx:404
FakeBkgTools::Client
Client
Definition: FakeBkgInternals.h:141
CP::BaseFakeBkgTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: BaseFakeBkgTool.cxx:63
CP::BaseFakeBkgTool::isSystematicUncertainty
virtual bool isSystematicUncertainty(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty originates from a systematic uncertainty in the ef...
Definition: BaseFakeBkgTool.cxx:533
CP::BaseFakeBkgTool::m_database
std::unique_ptr< FakeBkgTools::Database > m_database
Definition: BaseFakeBkgTool.h:91
CP::BaseFakeBkgTool::importEfficiencies
bool importEfficiencies(bool resetDB=false)
load the config file(s) storing efficiencies
Definition: BaseFakeBkgTool.cxx:109
CP::SystematicVariation
Definition: SystematicVariation.h:47
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
x
#define x
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::BaseFakeBkgTool::affectsElectrons
virtual bool affectsElectrons(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects electrons
Definition: BaseFakeBkgTool.cxx:547
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
CP::BaseFakeBkgTool::affectsFakeEfficiencies
virtual bool affectsFakeEfficiencies(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects fake efficiencies
Definition: BaseFakeBkgTool.cxx:575
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::BaseFakeBkgTool::m_tightDecoNameAndType
std::string m_tightDecoNameAndType
property TightDecoration
Definition: BaseFakeBkgTool.h:130
CP::BaseFakeBkgTool::register3DHistogram
virtual StatusCode register3DHistogram(TH3 *h3, const float *xval, const float *yval, const float *zval) override
associates a 3D histogram to the tool, to obtain a binned estimate of the fake lepton background
Definition: BaseFakeBkgTool.cxx:300
CP::BaseFakeBkgTool::m_cachedFinalStates
std::set< FakeBkgTools::FinalState > m_cachedFinalStates
Definition: BaseFakeBkgTool.h:99
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
CP::BaseFakeBkgTool::UncertaintyList::extraVariation
void extraVariation(uint16_t extra_UID, float extra_sigma)
Definition: BaseFakeBkgTool.h:148
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
Monitored::detail::getAxis
constexpr auto getAxis(H *hist)
Helper to get corresponding TAxis selected by Monitored::Axis.
Definition: HistogramFillerUtils.h:40
lumiFormat.i
int i
Definition: lumiFormat.py:92
CP::BaseFakeBkgTool::m_initialized
bool m_initialized
Definition: BaseFakeBkgTool.h:78
CP::BaseFakeBkgTool::affectsMuons
virtual bool affectsMuons(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects muons
Definition: BaseFakeBkgTool.cxx:554
FakeBkgTools
Definition: BaseFakeBkgTool.h:21
Photon.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::BaseFakeBkgTool::m_convertWhenMissing
bool m_convertWhenMissing
Definition: BaseFakeBkgTool.h:80
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
CP::BaseFakeBkgTool::m_progressFileDirectory
std::string m_progressFileDirectory
property ProgressFileDirectory
Definition: BaseFakeBkgTool.h:139
TH3
Definition: rootspy.cxx:440
FakeBkgTools::Database::XmlError
This propagates an error message + the reference to the faulty piece of XML when an exception is rais...
Definition: Database.h:124
CalibCoolCompareRT.up
up
Definition: CalibCoolCompareRT.py:109
CP::BaseFakeBkgTool::m_systSetDict
std::unordered_map< CP::SystematicSet, UncertaintyList > m_systSetDict
List of uncertainties in internal format, associated with a particular SystematicSet the m_selectedUn...
Definition: BaseFakeBkgTool.h:166
plotting.yearwise_efficiency.yval
float yval
Definition: yearwise_efficiency.py:43
CP::BaseFakeBkgTool::m_hasher
std::hash< std::string > m_hasher
comes from Event passed to addEvent()
Definition: BaseFakeBkgTool.h:97
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BaseFakeBkgTool.h
CP::BaseFakeBkgTool::m_process
std::string m_process
'process' settings used to compute the total yield / fill histograms
Definition: BaseFakeBkgTool.h:118
CP::BaseFakeBkgTool::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: BaseFakeBkgTool.cxx:270
CP::BaseFakeBkgTool::m_unlimitedSystematicVariations
bool m_unlimitedSystematicVariations
used to prevent multiple calls to applySystematicVariation() when unsupported set to true in a partic...
Definition: BaseFakeBkgTool.h:170
plotting.yearwise_efficiency.xval
float xval
Definition: yearwise_efficiency.py:42
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
beamspotman.stat
stat
Definition: beamspotman.py:266
CP::BaseFakeBkgTool::m_values_1dhisto_map
std::map< TH1 *, const float * > m_values_1dhisto_map
Definition: BaseFakeBkgTool.h:108
CP::BaseFakeBkgTool::getListOfEfficienciesAffectedBy
std::string getListOfEfficienciesAffectedBy(uint16_t uid) const
Definition: BaseFakeBkgTool.cxx:356
min
#define min(a, b)
Definition: cfImp.cxx:40
CP::BaseFakeBkgTool::isStatisticalUncertainty
virtual bool isStatisticalUncertainty(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty originates from a statistical uncertainty in the e...
Definition: BaseFakeBkgTool.cxx:540
Database.h
CP::BaseFakeBkgTool::m_needEventInfo
bool m_needEventInfo
Definition: BaseFakeBkgTool.h:79
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
python.hypoToolDisplay.toolname
def toolname(tool)
Definition: hypoToolDisplay.py:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
CP::BaseFakeBkgTool::m_tightAccessor
CP::ISelectionReadAccessor * m_tightAccessor
this can't be a unique_ptr as this can cause issues with the dictionary in some particular circumstan...
Definition: BaseFakeBkgTool.h:133
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
charge
double charge(const T &p)
Definition: AtlasPID.h:494
CP::makeSelectionReadAccessor
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition: ISelectionAccessor.cxx:54
CP::BaseFakeBkgTool::~BaseFakeBkgTool
virtual ~BaseFakeBkgTool()
Definition: BaseFakeBkgTool.cxx:53
FakeBkgTools::maxParticles
constexpr uint8_t maxParticles()
Definition: FakeBkgInternals.h:93
FakeBkgInternals.h
CP::ISelectionReadAccessor::getBool
virtual bool getBool(const SG::AuxElement &element, const CP::SystematicSet *sys=nullptr) const =0
get the selection decoration
CP::BaseFakeBkgTool::m_externalWeight
float m_externalWeight
Definition: BaseFakeBkgTool.h:95
CP::BaseFakeBkgTool::m_particles
std::vector< FakeBkgTools::ParticleData > m_particles
Definition: BaseFakeBkgTool.h:85
CP::BaseFakeBkgTool::UncertaintyList
List of systematic variations (UID + sigma) to be considered This is implemented as a basic linked li...
Definition: BaseFakeBkgTool.h:144
xAOD::Electron_v1
Definition: Electron_v1.h:34
CP::BaseFakeBkgTool::m_selectedUncertainties
UncertaintyList * m_selectedUncertainties
Pointer to a value of the 'm_systSetDict' map it must be invalidated each time the map is updated in ...
Definition: BaseFakeBkgTool.h:161
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Muon
struct TBPatternUnitContext Muon
CP::BaseFakeBkgTool::addEventCustom
virtual StatusCode addEventCustom()=0
CP::IFakeBkgTool::defaultSelection
static constexpr const char * defaultSelection()
default value taken by the 'selection' argument of several methods or properties It indicates how the...
Definition: IFakeBkgTool.h:32
FakeBkgTools::FinalState
Definition: FakeBkgInternals.h:98
y
#define y
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CP::BaseFakeBkgTool::affectsTaus
virtual bool affectsTaus(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects taus
Definition: BaseFakeBkgTool.cxx:561
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
CP::BaseFakeBkgTool::clientForDB
virtual FakeBkgTools::Client clientForDB()=0
This indicates which type of efficiencies/fake factor need to be filled.
Definition: BaseFakeBkgTool.cxx:58
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CP::BaseFakeBkgTool::printUncertaintyDescription
virtual void printUncertaintyDescription(const CP::SystematicVariation &systematic) const override final
prints a human-readable description of the source of systematic uncertainty specified as argument
Definition: BaseFakeBkgTool.cxx:484
TauJet.h
CP::BaseFakeBkgTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
Definition: BaseFakeBkgTool.cxx:409
CP::BaseFakeBkgTool::affectsRealEfficiencies
virtual bool affectsRealEfficiencies(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects real efficiencies
Definition: BaseFakeBkgTool.cxx:568
Herwig7_QED_EvtGen_ll.fs
dictionary fs
Definition: Herwig7_QED_EvtGen_ll.py:17
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CP::BaseFakeBkgTool::affectsFakeFactors
virtual bool affectsFakeFactors(const CP::SystematicVariation &systematic) const override final
checks whether the specified source of uncertainty affects fake factors
Definition: BaseFakeBkgTool.cxx:582
CP::BaseFakeBkgTool::m_selection
std::string m_selection
'selection' settings used to compute the total yield / fill histograms
Definition: BaseFakeBkgTool.h:115
ISelectionReadAccessor.h
LArCellBinning.step
step
Definition: LArCellBinning.py:158
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
LArG4FSStartPointFilterLegacy.line2
line2
Definition: LArG4FSStartPointFilterLegacy.py:59
Electron.h
CP::BaseFakeBkgTool::m_values_2dhisto_map
std::map< TH2 *, std::pair< const float *, const float * > > m_values_2dhisto_map
Definition: BaseFakeBkgTool.h:109
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:155
get_generator_info.error
error
Definition: get_generator_info.py:40
CP::IFakeBkgTool::defaultProcess
static constexpr const char * defaultProcess()
default value taken by the 'process' argument of several methods or properties It indicates what shou...
Definition: IFakeBkgTool.h:37
CP::BaseFakeBkgTool::m_energyUnit
std::string m_energyUnit
property EnergyUnit user can choose between MeV or GeV to indicate the unit of the pT parametrization...
Definition: BaseFakeBkgTool.h:122
error
Definition: IImpactPoint3dEstimator.h:70
CP::BaseFakeBkgTool::m_values_3dhisto_map
std::map< TH3 *, std::tuple< const float *, const float *, const float * > > m_values_3dhisto_map
Definition: BaseFakeBkgTool.h:110
CP::BaseFakeBkgTool::m_progressFileName
std::string m_progressFileName
property ProgressFileName
Definition: BaseFakeBkgTool.h:136
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition: SystematicSet.cxx:213
CP::BaseFakeBkgTool::affectingSystematicsFor
virtual CP::SystematicSet affectingSystematicsFor(const std::string &nuisanceParameter) const override
These functions are slow, don't use them in the tools implementations.
Definition: BaseFakeBkgTool.cxx:589
CP::SystematicVariation::parameter
float parameter() const
description: the numeric parameter contained in the subvariation(), or 0 if the subvariation can't be...
Definition: SystematicVariation.cxx:340