|
ATLAS Offline Software
|
Go to the documentation of this file.
14 #ifndef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
15 #define declareProperty(n, p, h) declareProperty(n, &BaseFakeBkgTool::p, h)
30 m_initialized(false), m_database(nullptr), m_energyUnit(
"MeV"), m_tightDecoNameAndType(
"Tight,as_char"), m_progressFileName(
"none"), m_progressFileDirectory(
"")
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");
42 declareProperty(
"EnergyUnit",
m_energyUnit,
"MeV or GeV -- keep consistent between the input (IParticle decorations/members) and the configuration files! [default = \"MeV\"]");
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]");
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\"]");
50 declareProperty(
"ProgressFileDirectory",
m_progressFileDirectory,
"complementary to ProgressFileName, specifies the directory inside the file where the results are stored [default = \"\"]");
68 return StatusCode::FAILURE;
79 return StatusCode::FAILURE;
82 std::unique_ptr<CP::ISelectionReadAccessor> tightAccessor;
88 ATH_MSG_WARNING(
"no input file(s) provided with the reference efficiencies, will try reading the efficiencies directly from the IParticle");
94 if(!
db)
return StatusCode::FAILURE;
98 return StatusCode::FAILURE;
106 return StatusCode::SUCCESS;
139 std::string fullmsg =
"(while parsing XML, line";
142 fullmsg +=
"): " +
err.reason;
160 return StatusCode::FAILURE;
168 #ifdef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
171 eventInfo = &iparticles.eventInfo;
175 for(
const auto& pp : iparticles)
198 return StatusCode::FAILURE;
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));
204 d.real_efficiency.nominal =
p.auxdataConst<
float>(
"real_eff");
205 d.fake_efficiency.nominal =
p.auxdataConst<
float>(
"fake_eff");
245 return StatusCode::FAILURE;
247 const std::string
name =
h1->GetName();
250 for(;itr!=enditr;++itr)
255 return StatusCode::FAILURE;
257 if(
name == itr->first->GetName())
break;
267 return StatusCode::SUCCESS;
275 return StatusCode::FAILURE;
277 const std::string
name = h2->GetName();
280 for(;itr!=enditr;++itr)
285 return StatusCode::FAILURE;
287 if(
name == itr->first->GetName())
break;
297 return StatusCode::SUCCESS;
305 return StatusCode::FAILURE;
307 const std::string
name = h3->GetName();
310 for(;itr!=enditr;++itr)
315 return StatusCode::FAILURE;
317 if(
name == itr->first->GetName())
break;
327 return StatusCode::SUCCESS;
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";
338 for(
auto getAxis : std::initializer_list<
const TAxis*(TH1::*)()
const>{&TH1::GetXaxis, &TH1::GetYaxis, &TH1::GetZaxis})
341 for(
int i=0;
i<=lhsAxis->GetNbins();++
i)
343 auto x=lhsAxis->GetBinUpEdge(
i),
y=rhsAxis->GetBinUpEdge(
i),
width=lhsAxis->GetBinWidth(
i?
i:1);
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;
353 return StatusCode::SUCCESS;
360 ATH_MSG_ERROR(
"This function can be called only once the tool has been initialized");
363 std::bitset<Database::N_EFFICIENCY_TYPES> affects;
369 if(syst) affects = syst->affects;
372 ATH_MSG_ERROR(
"uncertainty with UID " << std::hex << uid << std::dec <<
" not found in database");
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);
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");
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());
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");
419 std::string
type =
step?
"STAT" :
"SYST";
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");
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");
449 if(!systConfig.
size())
452 return StatusCode::SUCCESS;
458 return StatusCode::SUCCESS;
462 if(
sc != StatusCode::SUCCESS)
return sc;
463 std::unique_ptr<UncertaintyList> uncertainties;
464 for(
auto& sysvar : mysys)
469 ATH_MSG_ERROR(
"The systematic variation " << sysvar.name() <<
" is not recognized, despite being present in affectingSystematics()...");
470 return StatusCode::FAILURE;
477 auto emplaced =
m_systSetDict.emplace(systConfig, std::move(*uncertainties));
481 return StatusCode::SUCCESS;
494 ATH_MSG_ERROR(
"This function can be called only once the tool has been initialized");
501 ATH_MSG_WARNING(
"Systematic variation " + systematic.
name() +
" is not recognized by BaseFakeBkgTool");
507 return "Total statistical uncertainty in the event yield";
513 info =
"Statistical uncertainty affecting ";
521 info =
"Systematic uncertainty \"" + syst->name +
"\" affecting ";
525 ATH_MSG_ERROR(
"uncertainty with UID " << std::hex << UID << std::dec <<
" not found in database");
536 if(UID)
return Database::isSystUID(UID);
543 if(UID)
return Database::isStatUID(UID);
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...");
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));
605 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
#define ATH_MSG_WARNING(x)
@ 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...