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 #include <TFile.h>
14 #include <TH2F.h>
15 #include <TH3.h>
16 #include <string>
17 #include <vector>
18 #include <regex>
19 #include <stdexcept>
21 
22 using namespace FakeBkgTools;
23 using namespace CP;
24 
25 BaseFakeBkgTool::BaseFakeBkgTool(const std::string& toolname):
26  AsgTool(toolname),
27  m_initialized(false),
28  m_database(nullptr),
29  m_energyUnit("MeV"),
30  m_tightDecoNameAndType("Tight,as_char"),
31  m_progressFileName("none"),
32  m_progressFileDirectory(""),
33  m_accRealEff("real_eff"),
34  m_accFakeEff("fake_eff")
35 {
36  declareProperty("InputFiles",
38  "list of XML/ROOT files storing the efficiencies [default = {}]. If left empty, the tool "
39  "assumes that efficiencies are provided by the user as decorations (xAOD) or class "
40  "members (standalone) of the lepton objects");
41  declareProperty("Selection",
43  "Selection used to increment total yield / fill histograms [default = \""
44  + m_selection +"\"]");
45  declareProperty("Process",
47  "Process used to increment total yield / fill histograms [default = \""
48  + m_process +"\"]");
49  declareProperty("EnergyUnit",
51  "MeV or GeV -- keep consistent between the input (IParticle decorations/members) "
52  "and the configuration files! [default = \"MeV\"]");
53  declareProperty("ConvertWhenMissing",
55  "set to 'true' to compute fake factors from fake efficiencies if only the latter "
56  "are provided in the config files (and vice-versa) [default = false]");
57  declareProperty("TightDecoration",
59  "Name (and type) of the decoration used to indicate whether leptons pass the 'tight' "
60  "requirements or not [default = \"Tight,as_char\"]");
61  declareProperty("ProgressFileName",
63  "Name of ntuple file with results from a subset of the data");
64  declareProperty("ProgressFileDirectory",
66  "complementary to ProgressFileName, specifies the directory inside the file where the "
67  "results are stored [default = \"\"]");
68 }
69 
71 {
72  delete m_tightAccessor;
73 }
74 
76 {
77  return Client::NONE;
78 }
79 
81 {
82  if(m_initialized)
83  {
84  ATH_MSG_WARNING("the tool has already been initialized successfully");
85  return StatusCode::FAILURE;
86  }
87 
88  m_useDB = m_inputFiles.size();
89 
90 
91  bool useGeV;
92  if(m_energyUnit == "MeV" || m_energyUnit == "MEV") useGeV = false;
93  else if(m_energyUnit == "GeV" || m_energyUnit == "GEV" ) useGeV = true;
94  else
95  {
96  ATH_MSG_ERROR("unrecognized energy unit \"" << m_energyUnit << '"');
97  return StatusCode::FAILURE;
98  }
99 
100  std::unique_ptr<CP::ISelectionReadAccessor> tightAccessor;
102  m_tightAccessor = tightAccessor.release();
103 
104  if(!m_useDB)
105  {
106  ATH_MSG_WARNING("no input file(s) provided with the reference efficiencies, will try reading the efficiencies directly from the IParticle");
107  }
108 
110  {
111  auto db = new Database(clientForDB(), useGeV, m_convertWhenMissing);
112  if(!db) return StatusCode::FAILURE;
113  m_database = std::unique_ptr<Database>(db);
114  if(!importEfficiencies(true)){
115  ATH_MSG_ERROR("importEfficiencies failed!");
116  return StatusCode::FAILURE;
117  }
118  m_needEventInfo = db->needEventInfo();
119  }
120  else m_needEventInfo = false;
121 
122  m_initialized = true;
123 
124  return StatusCode::SUCCESS;
125 }
126 
128 {
129  if(resetDB) m_database->reset();
130  std::string filename;
131  try
132  {
133  for(const auto& fn : m_inputFiles)
134  {
136  auto pos = filename.rfind(".xml");
137  if(pos == filename.length()-4)
138  {
139  m_database->importXML(filename);
140  continue;
141  }
142  pos = filename.rfind(".root");
143  if(pos == filename.length()-5)
144  {
145  m_database->importDefaultROOT(fn);
146  continue;
147  }
148  ATH_MSG_ERROR("File extension not supported for " << filename);
149  return false;
150  }
151  }
152  catch(const Database::XmlError& err)
153  {
154  unsigned line1 = m_database->getXmlLineNumber(err.location.ptr);
155  unsigned line2 = m_database->getXmlLineNumber(err.location.endptr);
156  ATH_MSG_INFO("Exception caught while reading file " << filename << ", details follow");
157  std::string fullmsg = "(while parsing XML, line";
158  if(line2 != line1) fullmsg += "s " + std::to_string(line1) + " - " + std::to_string(line2);
159  else fullmsg += " " + std::to_string(line1);
160  fullmsg += "): " + err.reason;
161  ATH_MSG_ERROR(fullmsg);
162  return false;
163  }
164  catch(const Database::GenericError& err)
165  {
166  ATH_MSG_INFO("Exception caught while reading file " << filename << ", details follow");
167  ATH_MSG_ERROR(err.reason);
168  return false;
169  }
170  return m_database->ready();
171 }
172 
173 template<class C>
174 StatusCode BaseFakeBkgTool::addEventImpl(const C& iparticles, float mcWeight)
175 {
176  if(!m_initialized)
177  {
178  ATH_MSG_WARNING("the tool hasn't been initialized");
179  return StatusCode::FAILURE;
180  }
181  m_particles.clear();
183 
184  const xAOD::EventInfo* eventInfo = nullptr;
185  if(m_needEventInfo)
186  {
187  #ifdef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
188  ATH_CHECK( evtStore()->retrieve(eventInfo, "EventInfo") );
189  #else
190  eventInfo = &iparticles.eventInfo;
191  #endif
192  }
193 
194  for(const auto& pp : iparticles)
195  {
196  const auto& p = *pp;
197  m_particles.emplace_back();
198  auto& d = m_particles.back();
199  d.tight = m_tightAccessor->getBool(p);
200  d.type = p.type();
201  switch(p.type())
202  {
203  case xAOD::Type::Electron: d.charge = static_cast<const xAOD::Electron&>(p).charge(); break;
204  case xAOD::Type::Muon: d.charge = static_cast<const xAOD::Muon&>(p).charge(); break;
205  case xAOD::Type::Tau: d.charge = static_cast<const xAOD::TauJet&>(p).charge(); break;
206  case xAOD::Type::Photon: d.charge = 0; break;
207  default:
208  ATH_MSG_WARNING("unknown particle type, setting charge to 0");
209  d.charge = 0;
210  }
211  if(m_useDB)
212  {
213  std::string error;
214  if(!m_database->fillEfficiencies(d, p, *eventInfo, error))
215  {
216  ATH_MSG_ERROR("unable to retrieve efficiencies: " << error);
217  return StatusCode::FAILURE;
218  }
219  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));
220  }
221  else
222  {
223  d.real_efficiency.nominal = m_accRealEff(p);
224  d.fake_efficiency.nominal = m_accFakeEff(p);
225  }
226  }
227  if(m_particles.size() > maxParticles())
228  {
229  ATH_MSG_WARNING( "the input contains " << m_particles.size() << " particles but the maximum allowed is " << maxParticles()
230  << "; the last " << (m_particles.size()-maxParticles()) << " will be ignored");
231  m_particles.erase(m_particles.begin() + maxParticles(), m_particles.end());
232  }
233  m_externalWeight = mcWeight;
234  ATH_MSG_DEBUG("calling addEventCustom() with #particles = " << m_particles.size());
235  return addEventCustom();
236 }
237 
239 {
240  return addEventImpl(iparticles, mcWeight);
241 }
242 
244 {
245  return addEventImpl(iparticles, mcWeight);
246 }
247 
248 FinalState BaseFakeBkgTool::getCachedFinalState(uint8_t nparticles, const std::string& strPID, const std::string& strProc, bool& success)
249 {
250  success = true;
251  size_t hFS = m_hasher(strProc) ^ m_hasher(strPID) ^ nparticles;
252  auto itrFS = m_cachedFinalStates.find(FinalState(hFS));
253  if(itrFS != m_cachedFinalStates.end()) return *itrFS;
254  std::string error;
255  FinalState fs(hFS, nparticles, strPID, strProc, error);
256  if(error.length())
257  {
259  success = false;
260  return FinalState(0);
261  }
262  if(m_cachedFinalStates.size() < 1024)
263  {
264  m_cachedFinalStates.emplace(fs);
265  }
266  return fs;
267 }
268 
270 
271  if(!h1)
272  {
273  ATH_MSG_ERROR("invalid histogram pointer");
274  return StatusCode::FAILURE;
275  }
276  const std::string name = h1->GetName();
277  auto itr = m_values_1dhisto_map.begin();
278  const auto enditr = m_values_1dhisto_map.end();
279  for(;itr!=enditr;++itr)
280  {
281  if(itr->first == h1)
282  {
283  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
284  return StatusCode::FAILURE;
285  }
286  if(name == itr->first->GetName()) break;
287  }
288  if(itr == enditr)
289  {
290  m_values_1dhisto_map.emplace(h1, val);
291  }
292  else
293  {
294  ATH_CHECK( CheckHistogramCompatibility(h1, itr->first) );
295  }
296  return StatusCode::SUCCESS;
297 }
298 
299 StatusCode BaseFakeBkgTool::register2DHistogram(TH2* h2, const float *xval, const float *yval) {
300 
301  if(!h2)
302  {
303  ATH_MSG_ERROR("invalid histogram pointer");
304  return StatusCode::FAILURE;
305  }
306  const std::string name = h2->GetName();
307  auto itr = m_values_2dhisto_map.begin();
308  const auto enditr = m_values_2dhisto_map.end();
309  for(;itr!=enditr;++itr)
310  {
311  if(itr->first == h2)
312  {
313  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
314  return StatusCode::FAILURE;
315  }
316  if(name == itr->first->GetName()) break;
317  }
318  if(itr == enditr)
319  {
320  m_values_2dhisto_map.emplace(h2, std::make_pair(xval, yval));
321  }
322  else
323  {
324  ATH_CHECK( CheckHistogramCompatibility(h2, itr->first) );
325  }
326  return StatusCode::SUCCESS;
327 }
328 
329  StatusCode BaseFakeBkgTool::register3DHistogram(TH3* h3, const float *xval, const float *yval, const float *zval) {
330 
331  if(!h3)
332  {
333  ATH_MSG_ERROR("invalid histogram pointer");
334  return StatusCode::FAILURE;
335  }
336  const std::string name = h3->GetName();
337  auto itr = m_values_3dhisto_map.begin();
338  const auto enditr = m_values_3dhisto_map.end();
339  for(;itr!=enditr;++itr)
340  {
341  if(itr->first == h3)
342  {
343  ATH_MSG_ERROR("the histogram \"" << name << "\" has already been registered");
344  return StatusCode::FAILURE;
345  }
346  if(name == itr->first->GetName()) break;
347  }
348  if(itr == enditr)
349  {
350 m_values_3dhisto_map.emplace(h3, std::make_tuple(xval, yval, zval));
351  }
352  else
353  {
354  ATH_CHECK( CheckHistogramCompatibility(h3, itr->first) );
355  }
356  return StatusCode::SUCCESS;
357 }
358 
360 {
361  std::string error;
362  if(std::string(lhs->GetName()) != rhs->GetName()) error = "names";
363  else if(lhs->GetDimension() != rhs->GetDimension()) error = "dimensions";
364  else if(lhs->GetNbinsX()!=rhs->GetNbinsX() || lhs->GetNbinsY()!=rhs->GetNbinsY() || lhs->GetNbinsZ()!=rhs->GetNbinsZ()) error = "number of bins";
365  else
366  {
367  for(auto getAxis : std::initializer_list<const TAxis*(TH1::*)()const>{&TH1::GetXaxis, &TH1::GetYaxis, &TH1::GetZaxis})
368  {
369  auto lhsAxis=(lhs->*getAxis)(), rhsAxis=(rhs->*getAxis)();
370  for(int i=0;i<=lhsAxis->GetNbins();++i)
371  {
372  auto x=lhsAxis->GetBinUpEdge(i), y=rhsAxis->GetBinUpEdge(i), width=lhsAxis->GetBinWidth(i?i:1);
373  if(std::fabs(x-y) > 0.01*width) error = "bin edges";
374  }
375  }
376  }
377  if(error.length())
378  {
379  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.");
380  return StatusCode::FAILURE;
381  }
382  return StatusCode::SUCCESS;
383 }
384 
385 std::string BaseFakeBkgTool::getListOfEfficienciesAffectedBy(unsigned short uid) const
386 {
387  if(!m_initialized || !m_database)
388  {
389  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
390  return "";
391  }
392  std::bitset<Database::N_EFFICIENCY_TYPES> affects;
393  auto stat = m_database->findStat(uid);
394  if(stat) affects = stat->affects;
395  else
396  {
397  auto syst = m_database->findSyst(uid);
398  if(syst) affects = syst->affects;
399  else
400  {
401  ATH_MSG_ERROR("uncertainty with UID " << std::hex << uid << std::dec << " not found in database");
402  return "";
403  }
404  }
405  std::string info;
406  if(affects[Database::ELECTRON_REAL_EFFICIENCY]) info += "electron real efficiencies, ";
407  if(affects[Database::ELECTRON_FAKE_EFFICIENCY]) info += "electron fake efficiencies, ";
408  if(affects[Database::ELECTRON_FAKE_FACTOR]) info += "electron fake factors, ";
409  if(affects[Database::MUON_REAL_EFFICIENCY]) info += "muon real efficiencies, ";
410  if(affects[Database::MUON_FAKE_EFFICIENCY]) info += "muon fake efficiencies, ";
411  if(affects[Database::MUON_FAKE_FACTOR]) info += "muon fake factors, ";
412  if(affects[Database::PHOTON_ELE_FAKE_FACTOR]) info += "electron->photon fake rate, ";
413  if(affects[Database::PHOTON_ELE_FAKE_FACTOR_SF]) info += "electron->photon fake rate scale factor, ";
414  return info.substr(0, info.size()-2);
415 }
416 
417 std::pair<uint16_t, float> BaseFakeBkgTool::identifyCpSystematicVariation(const CP::SystematicVariation& systematic) const
418 {
419  if(!m_initialized || !m_database)
420  {
421  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...");
422  throw std::logic_error("BaseFakeBkgTool::identifyCpSystematicVariation() called before initialization");
423  }
424  std::smatch smr;
425  auto bn = systematic.basename();
426  if(!std::regex_match(bn, smr, std::regex("FAKEBKG_(STAT|SYST)_VAR(\\d+)"))) return {{0}, 0.f};
427  unsigned index = std::stol(smr[2].str());
428  float sigma = systematic.parameter();
429  if(smr[1].str() == "SYST") return {m_database->systIndexToUID(index), sigma};
430  else return {m_database->statIndexToUID(index), sigma};
431 }
432 
434 {
435  return identifyCpSystematicVariation(systematic).first;
436 }
437 
439 {
440  if(!m_initialized || !m_database)
441  {
442  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...");
443  throw std::logic_error("BaseFakeBkgTool::affectingSystematics() called before initialization");
444  }
445  CP::SystematicSet affecting;
446  for(int step=0;step<2;++step)
447  {
448  std::string type = step? "STAT" : "SYST";
449  const int imax = step? m_database->numberOfStats() : m_database->numberOfSysts();
450  for(int i=0;i<imax;++i)
451  {
452  std::string name = "FAKEBKG_" + type + "_VAR" + std::to_string(i);
453  affecting.insert(CP::SystematicVariation(name, 1.f));
454  affecting.insert(CP::SystematicVariation(name, -1.f));
455  }
456  }
457  return affecting;
458 }
459 
461 {
462  return affectingSystematics();
463 }
464 
466 {
467  if(!m_initialized || !m_database)
468  {
469  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
470  throw std::logic_error("BaseFakeBkgTool::applySystematicVariation() called before initialization");
471  }
473  {
474  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.");
475  throw std::logic_error("BaseFakeBkgTool::applySystematicVariation() called at a wrong time");
476  }
478  if(!systConfig.size())
479  {
480  m_selectedUncertainties = nullptr;
481  return StatusCode::SUCCESS;
482  }
483  auto itr = m_systSetDict.find(systConfig);
484  if(itr != m_systSetDict.end())
485  {
486  m_selectedUncertainties = &itr->second;
487  return StatusCode::SUCCESS;
488  }
489  CP::SystematicSet mysys;
491  if(sc != StatusCode::SUCCESS) return sc;
492  std::unique_ptr<UncertaintyList> uncertainties;
493  for(auto& sysvar : mysys)
494  {
495  auto var = identifyCpSystematicVariation(sysvar);
496  if(!var.first)
497  {
498  ATH_MSG_ERROR("The systematic variation " << sysvar.name() << " is not recognized, despite being present in affectingSystematics()...");
499  return StatusCode::FAILURE;
500  }
501  if(!uncertainties) uncertainties.reset(new UncertaintyList(var.first, var.second));
502  else uncertainties->extraVariation(var.first, var.second);
503  }
504  if(uncertainties)
505  {
506  auto emplaced = m_systSetDict.emplace(systConfig, std::move(*uncertainties));
507  m_selectedUncertainties = &emplaced.first->second;
508  }
509  else m_selectedUncertainties = nullptr;
510  return StatusCode::SUCCESS;
511 }
512 
514 {
515  auto info = getUncertaintyDescription(systematic);
516  if(info.length()) ATH_MSG_INFO(info);
517 }
518 
520 {
521  if(!m_initialized || !m_database)
522  {
523  ATH_MSG_ERROR("This function can be called only once the tool has been initialized");
524  return "";
525  }
526 
527  auto UID = identifyCpSystematicVariation(systematic).first;
528  if(!UID)
529  {
530  ATH_MSG_WARNING("Systematic variation " + systematic.name() + " is not recognized by BaseFakeBkgTool");
531  return "";
532  }
533 
534  if(UID == 0)
535  {
536  return "Total statistical uncertainty in the event yield";
537  }
538  std::string info;
539  auto stat = m_database->findStat(UID);
540  if(stat)
541  {
542  info = "Statistical uncertainty affecting ";
544  }
545  else
546  {
547  auto syst = m_database->findSyst(UID);
548  if(syst)
549  {
550  info = "Systematic uncertainty \"" + syst->name + "\" affecting ";
551  }
552  else
553  {
554  ATH_MSG_ERROR("uncertainty with UID " << std::hex << UID << std::dec << " not found in database");
555  return "";
556  }
557  }
559  return info;
560 }
561 
563 {
564  uint16_t UID = identifyCpSystematicVariation(systematic).first;
565  if(UID) return Database::isSystUID(UID);
566  return false;
567 }
568 
570 {
571  uint16_t UID = identifyCpSystematicVariation(systematic).first;
572  if(UID) return Database::isStatUID(UID);
573  return false;
574 }
575 
577 {
578  uint16_t UID = identifyCpSystematicVariation(systematic).first;
579  if(UID) return getListOfEfficienciesAffectedBy(UID).find("electron") != std::string::npos;
580  return false;
581 }
582 
584 {
585  uint16_t UID = identifyCpSystematicVariation(systematic).first;
586  if(UID) return getListOfEfficienciesAffectedBy(UID).find("muon") != std::string::npos;
587  return false;
588 }
589 
591 {
592  uint16_t UID = identifyCpSystematicVariation(systematic).first;
593  if(UID) return getListOfEfficienciesAffectedBy(UID).find("tau") != std::string::npos;
594  return false;
595 }
596 
598 {
599  uint16_t UID = identifyCpSystematicVariation(systematic).first;
600  if(UID) return getListOfEfficienciesAffectedBy(UID).find("real eff") != std::string::npos;
601  return false;
602 }
603 
605 {
606  uint16_t UID = identifyCpSystematicVariation(systematic).first;
607  if(UID) return getListOfEfficienciesAffectedBy(UID).find("fake eff") != std::string::npos;
608  return false;
609 }
610 
612 {
613  uint16_t UID = identifyCpSystematicVariation(systematic).first;
614  if(UID) return getListOfEfficienciesAffectedBy(UID).find("fake factor") != std::string::npos;
615  return false;
616 }
617 
618 CP::SystematicSet BaseFakeBkgTool::affectingSystematicsFor(const std::string& nuisanceParameter) const
619 {
620  CP::SystematicSet affecting;
621  if(!m_initialized || !m_database)
622  {
623  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...");
624  return {};
625  }
626  bool up=true, down=true;
627  auto pos1=nuisanceParameter.find("__up"), pos2=nuisanceParameter.find("__down");
628  if(pos1!=std::string::npos && pos1+4==nuisanceParameter.length()) down = false;
629  else if(pos2!=std::string::npos && pos2+6==nuisanceParameter.length()) up = false;
630  std::string np = nuisanceParameter.substr(0, std::min(pos1, pos2));
631  for(unsigned i=0;i<m_database->numberOfSysts();++i)
632  {
633  auto syst = m_database->findSyst(m_database->systIndexToUID(i));
634  if(syst && syst->name==np)
635  {
636  std::string name = "FAKEBKG_SYST_VAR" + std::to_string(i);
637  if(up) affecting.insert(CP::SystematicVariation(name, 1.f));
638  if(down) affecting.insert(CP::SystematicVariation(name, -1.f));
639  }
640  }
641  return affecting;
642 }
grepfile.info
info
Definition: grepfile.py:38
CP::BaseFakeBkgTool::CheckHistogramCompatibility
StatusCode CheckHistogramCompatibility(const TH1 *lhs, const TH1 *rhs)
Definition: BaseFakeBkgTool.cxx:359
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:269
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:519
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:248
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
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:557
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:417
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:460
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:465
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:433
FakeBkgTools::Client
Client
Definition: FakeBkgInternals.h:141
CP::BaseFakeBkgTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: BaseFakeBkgTool.cxx:80
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:562
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:127
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:576
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:604
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:329
CP::BaseFakeBkgTool::m_cachedFinalStates
std::set< FakeBkgTools::FinalState > m_cachedFinalStates
Definition: BaseFakeBkgTool.h:99
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
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
plotting.yearwise_efficiency_vs_mu.xval
float xval
Definition: yearwise_efficiency_vs_mu.py:35
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
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:85
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:583
FakeBkgTools
Definition: BaseFakeBkgTool.h:23
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
CP::BaseFakeBkgTool::m_accRealEff
SG::ConstAccessor< float > m_accRealEff
Definition: BaseFakeBkgTool.h:175
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
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
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
hist_file_dump.f
f
Definition: hist_file_dump.py:135
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:299
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
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:385
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:569
PathResolver.h
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:221
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:538
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:70
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
plotting.yearwise_efficiency_vs_mu.yval
float yval
Definition: yearwise_efficiency_vs_mu.py:36
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:33
FakeBkgTools::FinalState
Definition: FakeBkgInternals.h:98
PathResolverFindDataFile
std::string PathResolverFindDataFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:379
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:590
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:75
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
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:513
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:438
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:597
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:611
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:238
get_generator_info.error
error
Definition: get_generator_info.py:40
CP::BaseFakeBkgTool::addEventImpl
StatusCode addEventImpl(const C &iparticles, float mcWeight)
only used when m_useDB is false
Definition: BaseFakeBkgTool.cxx:174
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:38
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::m_accFakeEff
SG::ConstAccessor< float > m_accFakeEff
only used when m_useDB is false
Definition: BaseFakeBkgTool.h:177
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:618
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