|
ATLAS Offline Software
|
Go to the documentation of this file.
25 BaseFakeBkgTool::BaseFakeBkgTool(
const std::string&
toolname):
30 m_tightDecoNameAndType(
"Tight,as_char"),
31 m_progressFileName(
"none"),
32 m_progressFileDirectory(
""),
33 m_accRealEff(
"real_eff"),
34 m_accFakeEff(
"fake_eff")
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");
43 "Selection used to increment total yield / fill histograms [default = \""
47 "Process used to increment total yield / fill histograms [default = \""
51 "MeV or GeV -- keep consistent between the input (IParticle decorations/members) "
52 "and the configuration files! [default = \"MeV\"]");
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]");
59 "Name (and type) of the decoration used to indicate whether leptons pass the 'tight' "
60 "requirements or not [default = \"Tight,as_char\"]");
63 "Name of ntuple file with results from a subset of the data");
66 "complementary to ProgressFileName, specifies the directory inside the file where the "
67 "results are stored [default = \"\"]");
85 return StatusCode::FAILURE;
97 return StatusCode::FAILURE;
100 std::unique_ptr<CP::ISelectionReadAccessor> tightAccessor;
106 ATH_MSG_WARNING(
"no input file(s) provided with the reference efficiencies, will try reading the efficiencies directly from the IParticle");
112 if(!
db)
return StatusCode::FAILURE;
116 return StatusCode::FAILURE;
124 return StatusCode::SUCCESS;
157 std::string fullmsg =
"(while parsing XML, line";
160 fullmsg +=
"): " +
err.reason;
179 return StatusCode::FAILURE;
187 #ifdef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
190 eventInfo = &iparticles.eventInfo;
194 for(
const auto& pp : iparticles)
217 return StatusCode::FAILURE;
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));
274 return StatusCode::FAILURE;
276 const std::string
name =
h1->GetName();
279 for(;itr!=enditr;++itr)
284 return StatusCode::FAILURE;
286 if(
name == itr->first->GetName())
break;
296 return StatusCode::SUCCESS;
304 return StatusCode::FAILURE;
306 const std::string
name = h2->GetName();
309 for(;itr!=enditr;++itr)
314 return StatusCode::FAILURE;
316 if(
name == itr->first->GetName())
break;
326 return StatusCode::SUCCESS;
334 return StatusCode::FAILURE;
336 const std::string
name = h3->GetName();
339 for(;itr!=enditr;++itr)
344 return StatusCode::FAILURE;
346 if(
name == itr->first->GetName())
break;
356 return StatusCode::SUCCESS;
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";
367 for(
auto getAxis : std::initializer_list<
const TAxis*(TH1::*)()
const>{&TH1::GetXaxis, &TH1::GetYaxis, &TH1::GetZaxis})
370 for(
int i=0;
i<=lhsAxis->GetNbins();++
i)
372 auto x=lhsAxis->GetBinUpEdge(
i),
y=rhsAxis->GetBinUpEdge(
i),
width=lhsAxis->GetBinWidth(
i?
i:1);
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;
382 return StatusCode::SUCCESS;
389 ATH_MSG_ERROR(
"This function can be called only once the tool has been initialized");
392 std::bitset<Database::N_EFFICIENCY_TYPES> affects;
398 if(syst) affects = syst->affects;
401 ATH_MSG_ERROR(
"uncertainty with UID " << std::hex << uid << std::dec <<
" not found in database");
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);
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");
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());
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");
448 std::string
type =
step?
"STAT" :
"SYST";
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");
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");
478 if(!systConfig.
size())
481 return StatusCode::SUCCESS;
487 return StatusCode::SUCCESS;
491 if(
sc != StatusCode::SUCCESS)
return sc;
492 std::unique_ptr<UncertaintyList> uncertainties;
493 for(
auto& sysvar : mysys)
498 ATH_MSG_ERROR(
"The systematic variation " << sysvar.name() <<
" is not recognized, despite being present in affectingSystematics()...");
499 return StatusCode::FAILURE;
506 auto emplaced =
m_systSetDict.emplace(systConfig, std::move(*uncertainties));
510 return StatusCode::SUCCESS;
523 ATH_MSG_ERROR(
"This function can be called only once the tool has been initialized");
530 ATH_MSG_WARNING(
"Systematic variation " + systematic.
name() +
" is not recognized by BaseFakeBkgTool");
536 return "Total statistical uncertainty in the event yield";
542 info =
"Statistical uncertainty affecting ";
550 info =
"Systematic uncertainty \"" + syst->name +
"\" affecting ";
554 ATH_MSG_ERROR(
"uncertainty with UID " << std::hex << UID << std::dec <<
" not found in database");
565 if(UID)
return Database::isSystUID(UID);
572 if(UID)
return Database::isStatUID(UID);
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...");
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));
634 if(syst && syst->name==
np)
def retrieve(aClass, aKey=None)
Electron_v1 Electron
Definition of the current "egamma version".
std::string basename() const
description: the base name, i.e.
size_t size() const
returns: size of the set
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
const std::string & name() const
description: the full systematics name, for use in strings, etc.
Class to wrap a set of SystematicVariations.
Select isolated Photons, Electrons and Muons.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
constexpr auto getAxis(H *hist)
Helper to get corresponding TAxis selected by Monitored::Axis.
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a tau jet.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
std::string to_string(const DetectorType &type)
double charge(const T &p)
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
virtual bool getBool(const SG::AuxElement &element, const CP::SystematicSet *sys=nullptr) const =0
get the selection decoration
Class describing the basic event information.
Photon_v1 Photon
Definition of the current "egamma version".
struct TBPatternUnitContext Muon
std::string PathResolverFindDataFile(const std::string &logical_file_name)
#define ATH_MSG_WARNING(x)
DataVector adapter that acts like it holds const pointers.
@ Tau
The object is a tau (jet)
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
float parameter() const
description: the numeric parameter contained in the subvariation(), or 0 if the subvariation can't be...