|
ATLAS Offline Software
|
Go to the documentation of this file.
26 m_custom_file_Combined(),
28 m_custom_file_HighEta(),
29 m_custom_file_LowPt(),
30 m_custom_file_LowPtCalo(),
31 m_custom_file_LRTCombined(),
32 m_custom_file_LRTLowPt(),
33 m_efficiency_decoration_name_data(),
34 m_efficiency_decoration_name_mc(),
35 m_sf_decoration_name(),
36 m_calibration_version(
"230213_Preliminary_r22run2"),
37 m_lowpt_threshold(-1.),
38 m_iso_jet_dR(
"dRJet"),
39 m_use2DIsoCorr(false),
41 m_filtered_sys_sets(),
43 m_seperateSystBins(false),
44 m_breakDownSyst(false),
45 m_applyKineDepSys(true),
117 if (
sf.get() == coll)
return i;
130 ATH_MSG_INFO(
"The tool using working point " <<
m_wp <<
" is already initialized.");
131 return StatusCode::SUCCESS;
133 if (
m_wp.find(
"Iso") != std::string::npos) {
136 }
else if (
m_wp.find(
"BadMuon") != std::string::npos) {
140 }
else if (
m_wp.find(
"TTVA") != std::string::npos) {
145 ATH_MSG_FATAL(Form(
"Only Medium identification WP is supported for LRT muons. You chose %s.",
m_wp.c_str()));
146 return StatusCode::FAILURE;
163 ATH_MSG_DEBUG(
"We are running Isolation or TTVA or High Pt reco SF, so we use Zmumu based SF for the whole pt range!");
166 ATH_MSG_INFO(
"Low pt SF turned off as crossover threshold is negative! Using Zmumu based SF for all pt values.");
171 std::set<std::string> decorations{
179 if (decorations.size() != 6){
180 ATH_MSG_FATAL(
"At least one of the decoration names for scale-factor/ data-efficiency / mc-efficiency is not uniquely defined... Please check your properties");
181 return StatusCode::FAILURE;
203 ATH_MSG_ERROR(
"loading the central value systematic set failed");
204 return StatusCode::FAILURE;
209 if (!
registry.registerSystematics(*
this)) {
211 return StatusCode::FAILURE;
215 return StatusCode::SUCCESS;
220 info = evtInfo.operator->();
222 ATH_MSG_ERROR(
"Could not retrieve the xAOD::EventInfo. Return 999999");
227 ATH_MSG_DEBUG(
"The current event is a data event. Return runNumber instead.");
228 return info->runNumber();
230 if (!acc_rnd.isAvailable(*
info)) {
231 ATH_MSG_WARNING(
"Failed to find the RandomRunNumber decoration. Please call the apply() method from the PileupReweightingTool before hand in order to get period dependent SFs. You'll receive SFs from the most recent period.");
233 }
else if (acc_rnd(*
info) == 0) {
234 ATH_MSG_DEBUG(
"Pile up tool has given runNumber 0. Return SF from latest period.");
237 return acc_rnd(*
info);
342 if (fullPathToFile.empty()) {
345 return fullPathToFile;
421 return StatusCode::SUCCESS;
427 ATH_MSG_FATAL(
"No valid systematic could be loaded. Not even the statistical uncertainties");
428 return StatusCode::FAILURE;
432 m_sf_sets.push_back( std::make_unique<EffiCollection>(*
this));
435 std::function<
unsigned int(
unsigned int,
unsigned int)> not_inB = [](
unsigned int a ,
unsigned int b){
436 unsigned int b_flipped = ~
b;
437 return a & b_flipped;
450 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, syst.second,
false));
451 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *
this, syst.first, syst.second,
true));
455 if (!
sf->CheckConsistency()) {
456 ATH_MSG_FATAL(
"Inconsistent scalefactor maps have been found for "<<(
sf->getSystSet() ?
sf->getSystSet()->name() :
"UNKOWN"));
457 return StatusCode::FAILURE;
460 return StatusCode::SUCCESS;
463 std::map<std::string, unsigned int> syst_map;
466 std::set<std::string> files_to_look_up{
477 std::function<
int(
const std::string&)> get_bit = [
this](
const std::string&
file_name){
490 std::function<void(
const std::string&,
int)> insert_bit =[&syst_map](
const std::string&
key,
unsigned int bit){
491 if (syst_map.find(
key) == syst_map.end()) syst_map.insert(std::pair<std::string, unsigned int>(
key,bit));
492 else syst_map[
key] = syst_map[
key] | bit;
494 for (
const auto& look_up : files_to_look_up){
495 std::unique_ptr<TFile> root_file(TFile::Open(look_up.c_str(),
"READ"));
496 if (!root_file || !root_file->IsOpen()){
504 insert_bit(
"STAT", get_bit(look_up));
509 TTree* syst_tree =
nullptr;
510 root_file->GetObject(
"Systematics", syst_tree);
515 ATH_MSG_DEBUG(
"The file "<<look_up<<
" does not contain any systematic tree. No break down for that one will be considered");
516 insert_bit(
"SYS",get_bit(look_up));
524 std::string* syst_name =
nullptr;
525 bool is_symmetric(0), has_pt_sys(0), uncorrelated(0);
526 if (syst_tree->SetBranchAddress(
"Name", &syst_name) != 0 ||
527 syst_tree->SetBranchAddress(
"IsSymmetric", &is_symmetric) != 0 ||
528 syst_tree->SetBranchAddress(
"HasPtDependentSys", &has_pt_sys) !=0 ||
529 syst_tree->SetBranchAddress(
"CanBeUncorrelated", &uncorrelated) !=0){
532 ATH_MSG_FATAL(
"Although "<<look_up<<
" has a systematic tree. There is no proper connection to the branches");
536 for (
int i =0; syst_tree->GetEntry(
i); ++
i){
537 insert_bit( *syst_name, get_bit(look_up));
555 if (!collection->getSystSet()){
556 ATH_MSG_FATAL(
"No systematic defined for scale-factor map. ");
559 result.insert(*collection->getSystSet());
575 return StatusCode::FAILURE;
579 std::unordered_map<CP::SystematicSet, EffiCollection*>::const_iterator itr =
m_filtered_sys_sets.find (systConfig);
585 ATH_MSG_ERROR(
"Unsupported combination of systematics passed to the tool! ");
586 return StatusCode::FAILURE;
593 std::vector<std::unique_ptr<EffiCollection>>::const_iterator coll_itr = std::find_if(
m_sf_sets.begin(),
m_sf_sets.end(),[&mySysConf](
const std::unique_ptr<EffiCollection>&
a){return a->isAffectedBySystematic(mySysConf);});
596 return StatusCode::FAILURE;
598 m_filtered_sys_sets.insert(std::pair<SystematicSet, EffiCollection*>(systConfig, coll_itr->get()));
604 for (std::set<SystematicVariation>::const_iterator
t = mySysConf.
begin();
t != mySysConf.
end(); ++
t) {
605 if ((*t).isToyVariation()) {
609 std::pair<unsigned, float> pair = (*t).getToyVariation();
611 ATH_MSG_WARNING(
"Could not apply systematic " << (*t).name() <<
" for bin " << pair.first);
612 return StatusCode::FAILURE;
614 return StatusCode::SUCCESS;
618 return StatusCode::SUCCESS;
622 throw std::runtime_error(
"No systematic has been loaded. Cannot return any syst-bin") ;
623 ATH_MSG_FATAL(
"No systematic has been loaded. Cannot return any syst-bin");
630 ATH_MSG_WARNING(
"No systematic has been loaded. Cannot return any syst-bin");
636 for (std::set<SystematicVariation>::const_iterator
t = systConfig.
begin();
t != systConfig.
end(); ++
t) {
637 if ((*t).isToyVariation()) {
638 std::pair<unsigned, float> pair = (*t).getToyVariation();
642 ATH_MSG_ERROR(
"The given systematic " << systConfig.
name() <<
" is not an unfolded one. Return unknown bin ");
643 return "unknown bin";
std::string filename_Calo() const
Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0....
std::string m_custom_file_LowPtCalo
std::string filename_Central() const
The following methods are meant to propagate information from the central tool to the subtool managin...
std::string filename_LRTLowPt() const
CorrectionCode DataEfficiency(const xAOD::Muon &mu, float &Eff) const
... and absolute efficiencies
CorrectionCode ScaleFactorReplicas(const xAOD::Muon &mu, std::vector< float > &SF)
std::unordered_map< CP::SystematicSet, EffiCollection * > m_filtered_sys_sets
It turned out that the code spends a large time in the look up of the systematics.
std::string m_custom_file_LRTLowPt
The EffiCollection class handles the 5 different scale-factor maps binned in time.
virtual CorrectionCode applyMCEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
std::string data_effi_replica_decoration() const
StatusCode LoadInputs()
load the SF histos
CorrectionCode MCEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &eff)
float lowPtTransition() const
If the pt of the muon is below that threshold the J/Psi or Upsilon map is used given that it's availa...
bool m_useLRT
Turn on if using LRT objects.
std::string sf_replica_decoration() const
std::string m_iso_jet_dR
Name of the decoration to catch up the close by jets.
virtual CorrectionCode getDataEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
virtual CorrectionCode applyMCEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
std::string sf_decoration() const
The apply<Blah> methods decorate their result directly to the muon.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
bool empty() const
returns: whether the set is empty
@ Central
The five different scale-factor maps.
virtual SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
Class to wrap a set of SystematicVariations.
virtual CorrectionCode applyEfficiencyScaleFactor(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
decorate the muon with scale factor information
std::string m_custom_file_LRTCombined
virtual CorrectionCode getMCEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
std::string name() const
returns: the systematics joined into a single string.
Helper class to provide constant type-safe access to aux data.
std::vector< std::unique_ptr< EffiCollection > > m_sf_sets
This vector stores all scale-factor maps.
std::string m_custom_file_Combined
@ IS_SIMULATION
true: simulation, false: data
Select isolated Photons, Electrons and Muons.
CorrectionCode ApplyScaleFactor(const xAOD::Muon &mu) const
or you can just decorate the scale-factor to the muon
std::string filename_LRTCentral() const
LRT muons have their own efficiency maps.
CorrectionCode DataEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &eff)
std::string m_sf_decoration_name
size_t getPosition(const EffiCollection *coll) const
Returns the position of the collection in the syst set vector.
std::string filename_LowPt() const
Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilo...
virtual CorrectionCode getDataEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const
Obtain the muon efficiency measured using the data.
MuonEfficiencyScaleFactors(const std::string &name)
@ Error
Some error happened during the object correction.
std::string m_efficiency_decoration_name_mc
virtual CorrectionCode applyDataEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
::StatusCode StatusCode
StatusCode definition for legacy code.
std::string m_efficiency_decoration_name_data
std::string resolve_file_location(const std::string &filename) const
utility method to 'dress' a filename using the path resolver
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
CorrectionCode MCEfficiency(const xAOD::Muon &mu, float &Eff) const
... mc efficiency
virtual int getUnCorrelatedSystBin(const xAOD::Muon &mu) const
const_iterator end() const
description: const iterator to the end of the set
std::string GetBinName(unsigned int bin) const
Returns the global bin name conststucted from the axis titles and the bin borders.
virtual StatusCode initialize()
initialize the tool once all settings are in place!
CorrectionCode ApplyDataEfficiency(const xAOD::Muon &mu) const
You can decorate the data efficiecny as well.
EffiCollection * m_current_sf
Pointer to the current active map in terms of systematics.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
CP::SystematicSet m_affectingSys
CorrectionCode ApplyDataEfficiencyReplicas(const xAOD::Muon &mu, int n_replicas)
std::string filename_HighEta() const
High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means ...
EfficiencyScaleFactor * retrieveSF(const xAOD::Muon &mu, unsigned int RunNumber) const
return the correct SF type to provide, depending on eta and the author
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematis
std::string m_wp
the working point to operate on
virtual CorrectionCode applyDataEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
decorate a muon with the efficiency information
std::string m_custom_file_Calo
size_t getNCollections() const
Returns the number of EffiCollections stored in this class.
virtual CorrectionCode getEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
replica generation
std::string m_custom_file_HighEta
Class describing the basic event information.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
iterator find(const SystematicVariation &sys) const
description: find an element in the set
virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon &mu, float &sf, const xAOD::EventInfo *info=0) const
Retrieve the Scale factor and decorate the muon.
CorrectionCode ApplyMCEfficiency(const xAOD::Muon &mu) const
... or decorate them directly
@ JPsiAnalysis
Distinguish these two because the systematics are named with an extra LOWPT.
unsigned int getRandomRunNumber(const xAOD::EventInfo *info) const
std::string mc_effi_decoration() const
#define ATH_MSG_WARNING(x)
CorrectionCode ApplyScaleFactorReplicas(const xAOD::Muon &mu, int n_replicas)
This module implements the central registry for handling systematic uncertainties with CP tools.
bool use_lrt() const
option to set if we want to use LRT muons
std::string m_custom_file_LowPt
const_iterator begin() const
description: const iterator to the beginning of the set
std::map< std::string, unsigned int > lookUpSystematics()
Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual compo...
virtual CorrectionCode applyEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
decorate the muon with a set of SF replica weights.
std::string mc_effi_replica_deocration() const
bool uncorrelate_sys() const
Returns a boolean whether the uncorrelation of systematics has been switched on.
Return value from object correction CP tools.
CorrectionCode ScaleFactor(const xAOD::Muon &mu, float &SF) const
the important bits - extract SF info
const std::string & close_by_jet_decoration() const
Returns the string telling the tool in which float AuxElement the information of the separation to th...
CorrectionCode ApplyMCEfficiencyReplicas(const xAOD::Muon &mu, int n_replicas)
std::string filename_LowPtCalo() const
float m_lowpt_threshold
threshold below which low-pt SF (i.e. from JPsi) should be used
int getUnCorrelatedSystBin(const xAOD::Muon &mu) const
Returns the bin number from which the scale-factor of the muon is going to be retrieved....
bool use_2D_iso_corrections() const
option to set if we want to use 1D or 2D isolation SFs
bool SetSystematicBin(unsigned int Bin)
If systematic decorrelation is activated then the user needs to loop manually over the syst bins.
virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const
CP::MuonEfficiencyType measurement() const
Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.
CP::MuonEfficiencyType m_Type
std::string data_effi_decoration() const
virtual CorrectionCode getMCEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const
Obtain the muon efficiency measured using the MC.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
std::string m_calibration_version
subfolder to load from the calibration db
virtual SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by