ATLAS Offline Software
Loading...
Searching...
No Matches
CP::MuonEfficiencyScaleFactors Class Reference

#include <MuonEfficiencyScaleFactors.h>

Inheritance diagram for CP::MuonEfficiencyScaleFactors:

Classes

struct  Accessors

Public Member Functions

 MuonEfficiencyScaleFactors (const std::string &name)
virtual ~MuonEfficiencyScaleFactors ()
virtual StatusCode initialize () override
 initialize the tool once all settings are in place!
virtual CorrectionCode getEfficiencyScaleFactor (const xAOD::Muon &mu, float &sf, const xAOD::EventInfo *info=0) const override
 Retrieve the Scale factor and decorate the muon.
CorrectionCode getEfficiencyScaleFactor (columnar::MuonId mu, float &sf, columnar::EventInfoId info) const
virtual CorrectionCode applyEfficiencyScaleFactor (const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
 decorate the muon with scale factor information
virtual CorrectionCode getEfficiencyScaleFactorReplicas (const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const override
 replica generation
virtual CorrectionCode applyEfficiencyScaleFactorReplicas (const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const override
 decorate the muon with a set of SF replica weights.
virtual bool isAffectedBySystematic (const SystematicVariation &systematic) const override
 returns: whether this tool is affected by the given systematis
virtual SystematicSet affectingSystematics () const override
 returns: the list of all systematics this tool can be affected by
virtual SystematicSet recommendedSystematics () const override
 returns: the list of all systematics this tool recommends to use
virtual StatusCode applySystematicVariation (const SystematicSet &systConfig) override
 effects: configure this tool for the given list of systematic variations.
virtual CorrectionCode getDataEfficiency (const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const override
 Obtain the muon efficiency measured using the data.
virtual CorrectionCode applyDataEfficiency (const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
 decorate a muon with the efficiency information
virtual CorrectionCode getDataEfficiencyReplicas (const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
virtual CorrectionCode applyDataEfficiencyReplicas (const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
virtual CorrectionCode getMCEfficiency (const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const override
 Obtain the muon efficiency measured using the MC.
virtual CorrectionCode applyMCEfficiency (const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
virtual CorrectionCode getMCEfficiencyReplicas (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
virtual int getUnCorrelatedSystBin (const xAOD::Muon &mu) const override
virtual std::string getUncorrelatedSysBinName (unsigned int Bin) const override
virtual std::string getUncorrelatedSysBinName (const SystematicSet &systConfig) const override
std::string filename_Central () const
 The following methods are meant to propagate information from the central tool to the subtool managing the individual scale-factor maps to keep their constructors small in number of arguments.
std::string filename_Calo () const
 Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0.1.
std::string filename_HighEta () const
 High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means of tag & probe, but rather by building the double ratio.
std::string filename_LowPt () const
 Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilon resonance.
std::string filename_LowPtCalo () const
std::string filename_LRTCentral () const
 LRT muons have their own efficiency maps.
std::string filename_LRTLowPt () const
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 available.
CP::MuonEfficiencyType measurement () const
 Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.
std::string sf_decoration () const
 The apply<Blah> methods decorate their result directly to the muon.
std::string data_effi_decoration () const
std::string mc_effi_decoration () const
std::string sf_replica_decoration () const
std::string data_effi_replica_decoration () const
std::string mc_effi_replica_deocration () const
size_t getPosition (const EffiCollection *coll) const
 Returns the position of the collection in the syst set vector.
size_t getNCollections () const
 Returns the number of EffiCollections stored in this class.
bool uncorrelate_sys () const
 Returns a boolean whether the uncorrelation of systematics has been switched on.
const std::string & close_by_jet_decoration () const
 Returns the string telling the tool in which float AuxElement the information of the separation to the closest jet is stored.
bool use_2D_iso_corrections () const
 option to set if we want to use 1D or 2D isolation SFs
bool use_lrt () const
 option to set if we want to use LRT muons
void callSingleEvent (columnar::MuonRange muons, columnar::EventInfoId event) const
virtual void callEvents (columnar::EventContextRange events) const override
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

unsigned int getRandomRunNumber (const xAOD::EventInfo *info) const
unsigned int getRandomRunNumber (columnar::EventInfoId info) const
StatusCode LoadInputs ()
 load the SF histos
std::map< std::string, unsigned intlookUpSystematics ()
 Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual components.
std::string resolve_file_location (const std::string &filename) const
 utility method to 'dress' a filename using the path resolver
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::EventInfom_eventInfo {this, "EventInfoContName", "EventInfo", "event info key"}
std::string m_wp
 the working point to operate on
std::vector< std::unique_ptr< EffiCollection > > m_sf_sets
 This vector stores all scale-factor maps.
EffiCollectionm_current_sf
 Pointer to the current active map in terms of systematics.
std::string m_custom_dir
std::string m_custom_file_Combined
std::string m_custom_file_Calo
std::string m_custom_file_HighEta
std::string m_custom_file_LowPt
std::string m_custom_file_LowPtCalo
std::string m_custom_file_LRTCombined
std::string m_custom_file_LRTLowPt
std::string m_efficiency_decoration_name_data
std::string m_efficiency_decoration_name_mc
std::string m_sf_decoration_name
std::string m_calibration_version
 subfolder to load from the calibration db
float m_lowpt_threshold
 threshold below which low-pt SF (i.e. from JPsi) should be used
std::string m_iso_jet_dR
 Name of the decoration to catch up the close by jets.
bool m_use2DIsoCorr
CP::SystematicSet m_affectingSys
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.
bool m_init
bool m_seperateSystBins
bool m_breakDownSyst
bool m_applyKineDepSys
bool m_useLRT
 Turn on if using LRT objects.
CP::MuonEfficiencyType m_Type
std::unique_ptr< Accessorsm_accessors
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 29 of file MuonEfficiencyScaleFactors.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonEfficiencyScaleFactors()

CP::MuonEfficiencyScaleFactors::MuonEfficiencyScaleFactors ( const std::string & name)

Name of the decorator carrying the information the distance to the next what ever jet (AntiKt4EMTopo,....)

Turn on if using LRT muons

Definition at line 33 of file MuonEfficiencyScaleFactors.cxx.

33 :
34 asg::AsgTool(name),
35 m_wp("Medium"),
36 m_sf_sets(),
49 m_calibration_version("230213_Preliminary_r22run2"),
51 m_iso_jet_dR("dRJet"),
52 m_use2DIsoCorr(false),
55 m_init(false),
56 m_seperateSystBins(false),
57 m_breakDownSyst(false),
59 m_useLRT(false),
61
62 m_accessors = std::make_unique<Accessors>(this);
63
64 declareProperty("WorkingPoint", m_wp);
65
66 // these are for debugging / testing, *not* for general use!
67 declareProperty("CustomInputFolder", m_custom_dir);
68 declareProperty("CustomFileCaloTag", m_custom_file_Calo);
69 declareProperty("CustomFileCombined", m_custom_file_Combined);
70 declareProperty("CustomFileHighEta", m_custom_file_HighEta);
71 declareProperty("CustomFileLowPt", m_custom_file_LowPt);
72 declareProperty("CustomFileLowPtCalo", m_custom_file_LowPtCalo);
73 declareProperty("CustomFileLRTCombined", m_custom_file_LRTCombined);
74 declareProperty("CustomFileLRTLowPt", m_custom_file_LRTLowPt);
75
76 // Apply additional systematics to account for negelected pt dependency
77 // in the maps themselves or for non-closure
78 declareProperty("ApplyKinematicSystematic", m_applyKineDepSys);
79
80 // Set specific names for the decorations of the scale-factors to the muon
81 declareProperty("DataEfficiencyDecorationName", m_efficiency_decoration_name_data);
82 declareProperty("MCEfficiencyDecorationName", m_efficiency_decoration_name_mc);
83 declareProperty("ScaleFactorDecorationName", m_sf_decoration_name);
84
85 declareProperty("CalibrationRelease", m_calibration_version);
86 // Set this property to -1 if you do not want to use the JPsi
87 // reconstruction scale-factors
88 declareProperty("LowPtThreshold", m_lowpt_threshold);
89 declareProperty("UncorrelateSystematics", m_seperateSystBins);
90 declareProperty("BreakDownSystematics", m_breakDownSyst);
93 declareProperty("CloseJetDRDecorator", m_iso_jet_dR);
94 declareProperty("Use2DIsoCorrections", m_use2DIsoCorr);
96 declareProperty("UseLRT", m_useLRT);
97 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
float m_lowpt_threshold
threshold below which low-pt SF (i.e. from JPsi) should be used
std::string m_wp
the working point to operate on
std::unique_ptr< Accessors > m_accessors
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::vector< std::unique_ptr< EffiCollection > > m_sf_sets
This vector stores all scale-factor maps.
std::string m_iso_jet_dR
Name of the decoration to catch up the close by jets.
EffiCollection * m_current_sf
Pointer to the current active map in terms of systematics.
std::string m_calibration_version
subfolder to load from the calibration db
bool m_useLRT
Turn on if using LRT objects.

◆ ~MuonEfficiencyScaleFactors()

CP::MuonEfficiencyScaleFactors::~MuonEfficiencyScaleFactors ( )
virtualdefault

Member Function Documentation

◆ affectingSystematics()

SystematicSet CP::MuonEfficiencyScaleFactors::affectingSystematics ( ) const
overridevirtual

returns: the list of all systematics this tool can be affected by

Implements CP::IReentrantSystematicsTool.

Definition at line 591 of file MuonEfficiencyScaleFactors.cxx.

591 {
592 if (!m_affectingSys.empty()) return m_affectingSys;
593 SystematicSet result;
594 for (auto& collection : m_sf_sets){
595 if (!collection->getSystSet()){
596 ATH_MSG_FATAL("No systematic defined for scale-factor map. ");
597 return SystematicSet();
598 }
599 result.insert(*collection->getSystSet());
600 }
601 return result;
602 }
#define ATH_MSG_FATAL(x)

◆ applyDataEfficiency()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyDataEfficiency ( const xAOD::Muon & mu,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

decorate a muon with the efficiency information

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 318 of file MuonEfficiencyScaleFactors.cxx.

318 {
319 if (!m_init) {
320 ATH_MSG_ERROR("The tool has not been initialized yet");
322 }
323 unsigned int RunNumber = getRandomRunNumber(info);
324 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyDataEfficiency(mu);
325 }
#define ATH_MSG_ERROR(x)
@ Error
Some error happened during the object correction.
unsigned int getRandomRunNumber(const xAOD::EventInfo *info) const

◆ applyDataEfficiencyReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyDataEfficiencyReplicas ( const xAOD::Muon & mu,
int nreplicas = 50,
const xAOD::EventInfo * info = 0 ) const
virtual

Definition at line 334 of file MuonEfficiencyScaleFactors.cxx.

334 {
335 if (!m_init) {
336 ATH_MSG_ERROR("The tool has not been initialized yet");
338 }
339 unsigned int RunNumber = getRandomRunNumber(info);
340 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyDataEfficiencyReplicas(mu, nreplicas);
341 }

◆ applyEfficiencyScaleFactor()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyEfficiencyScaleFactor ( const xAOD::Muon & mu,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

decorate the muon with scale factor information

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 285 of file MuonEfficiencyScaleFactors.cxx.

285 {
286 if (!m_init) {
287 ATH_MSG_ERROR("The tool has not been initialized yet");
289 }
290 unsigned int RunNumber = getRandomRunNumber(info);
291 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyScaleFactor(mu);
292 }

◆ applyEfficiencyScaleFactorReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyEfficiencyScaleFactorReplicas ( const xAOD::Muon & mu,
int nreplicas = 50,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

decorate the muon with a set of SF replica weights.

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 302 of file MuonEfficiencyScaleFactors.cxx.

302 {
303 if (!m_init) {
304 ATH_MSG_ERROR("The tool has not been initialized yet");
306 }
307 unsigned int RunNumber = getRandomRunNumber(info);
308 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyScaleFactorReplicas(mu, nreplicas);
309 }

◆ applyMCEfficiency()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyMCEfficiency ( const xAOD::Muon & mu,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 350 of file MuonEfficiencyScaleFactors.cxx.

350 {
351 if (!m_init) {
352 ATH_MSG_ERROR("The tool has not been initialized yet");
354 }
355 unsigned int RunNumber = getRandomRunNumber(info);
356 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyMCEfficiency(mu);
357 }

◆ applyMCEfficiencyReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::applyMCEfficiencyReplicas ( const xAOD::Muon & mu,
int nreplicas = 50,
const xAOD::EventInfo * info = 0 ) const
virtual

Definition at line 366 of file MuonEfficiencyScaleFactors.cxx.

366 {
367 if (!m_init) {
368 ATH_MSG_ERROR("The tool has not been initialized yet");
370 }
371 unsigned int RunNumber = getRandomRunNumber(info);
372 return m_current_sf->retrieveSF(mu, RunNumber)->ApplyMCEfficiencyReplicas(mu, nreplicas);
373 }

◆ applySystematicVariation()

StatusCode CP::MuonEfficiencyScaleFactors::applySystematicVariation ( const SystematicSet & systConfig)
overridevirtual

effects: configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored (unless they cause other errors). failures: systematic unknown failures: requesting multiple variations on the same systematic (e.g. up & down) failures: requesting an unsupported variation on an otherwise supported systematic (e.g. a 2 sigma variation and the tool only supports 1 sigma variations) failures: unsupported combination of supported systematic failures: other tool specific errors

Implements CP::ISystematicsTool.

Definition at line 612 of file MuonEfficiencyScaleFactors.cxx.

612 {
613 if (!m_init) {
614 ATH_MSG_ERROR("Initialize first the tool!");
615 return StatusCode::FAILURE;
616 }
617
618 //check if systematics is cached
619 std::unordered_map<CP::SystematicSet, EffiCollection*>::const_iterator itr = m_filtered_sys_sets.find (systConfig);
620
621 SystematicSet mySysConf(systConfig);
622
623 if (itr == m_filtered_sys_sets.end()) {
625 ATH_MSG_ERROR("Unsupported combination of systematics passed to the tool! ");
626 return StatusCode::FAILURE;
627 }
628 itr = m_filtered_sys_sets.find(mySysConf);
629 }
630
631 // No cache is available
632 if (itr == m_filtered_sys_sets.end()){
633 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);});
634 if (coll_itr == m_sf_sets.end()){
635 ATH_MSG_WARNING("Invalid systematic given.");
636 return StatusCode::FAILURE;
637 }
638 m_filtered_sys_sets.insert(std::pair<SystematicSet, EffiCollection*>(systConfig, coll_itr->get()));
639 itr = m_filtered_sys_sets.find(systConfig);
640 }
641 m_current_sf = itr->second;
642
643 if (m_seperateSystBins && !itr->first.name().empty()){
644 for (std::set<SystematicVariation>::const_iterator t = mySysConf.begin(); t != mySysConf.end(); ++t) {
645 if ((*t).isToyVariation()) {
646 // First entry corresponds to the bin number and
647 // the second entry to the position in which the map is ordered
648 // into the m_sf_sets container
649 std::pair<unsigned, float> pair = (*t).getToyVariation();
650 if (pair.first != 0 && !m_current_sf->SetSystematicBin(pair.first)){
651 ATH_MSG_WARNING("Could not apply systematic " << (*t).name() << " for bin " << pair.first);
652 return StatusCode::FAILURE;
653 }
654 return StatusCode::SUCCESS;
655 }
656 }
657 }
658 return StatusCode::SUCCESS;
659 }
#define ATH_MSG_WARNING(x)
static Double_t a
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...

◆ callEvents()

void CP::MuonEfficiencyScaleFactors::callEvents ( columnar::EventContextRange events) const
overridevirtual

Definition at line 708 of file MuonEfficiencyScaleFactors.cxx.

708 {
709 const auto& acc = *m_accessors;
710 for (columnar::EventContextId event : events)
711 {
712 auto eventInfo = acc.eventInfoCol(event);
713 callSingleEvent (acc.muons(event), eventInfo);
714 }
715 }
void callSingleEvent(columnar::MuonRange muons, columnar::EventInfoId event) const
ObjectId< ContainerId::eventContext > EventContextId
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.

◆ callSingleEvent()

void CP::MuonEfficiencyScaleFactors::callSingleEvent ( columnar::MuonRange muons,
columnar::EventInfoId event ) const

Definition at line 686 of file MuonEfficiencyScaleFactors.cxx.

687 {
688 const auto& acc = *m_accessors;
689 for (columnar::MuonId muon : muons)
690 {
691 float sf = 0;
692 switch (getEfficiencyScaleFactor(muon, sf, event).code())
693 {
695 acc.sfDec(muon) = sf;
696 acc.validDec(muon) = true;
697 break;
699 acc.sfDec(muon) = sf;
700 acc.validDec(muon) = false;
701 break;
702 default:
703 throw std::runtime_error("Error in getEfficiencyScaleFactor");
704 }
705 }
706 }
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon &mu, float &sf, const xAOD::EventInfo *info=0) const override
Retrieve the Scale factor and decorate the muon.
ObjectId< ContainerId::muon > MuonId
Definition MuonDef.h:25

◆ close_by_jet_decoration()

const std::string & CP::MuonEfficiencyScaleFactors::close_by_jet_decoration ( ) const

Returns the string telling the tool in which float AuxElement the information of the separation to the closest jet is stored.

Definition at line 99 of file MuonEfficiencyScaleFactors.cxx.

99 {
100 return m_iso_jet_dR;
101 }

◆ data_effi_decoration()

std::string CP::MuonEfficiencyScaleFactors::data_effi_decoration ( ) const

Definition at line 115 of file MuonEfficiencyScaleFactors.cxx.

115 {
116 return m_efficiency_decoration_name_data.empty() ? std::string("DataEffi") + m_wp : m_efficiency_decoration_name_data;
117 }

◆ data_effi_replica_decoration()

std::string CP::MuonEfficiencyScaleFactors::data_effi_replica_decoration ( ) const

Definition at line 124 of file MuonEfficiencyScaleFactors.cxx.

124 {
125 return std::string("Replica") + data_effi_decoration();
126 }

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ filename_Calo()

std::string CP::MuonEfficiencyScaleFactors::filename_Calo ( ) const

Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0.1.

If the scale-factor is isolation/TTVA then the central file name is returned

Definition at line 416 of file MuonEfficiencyScaleFactors.cxx.

416 {
417
420 return filename_Central();
421 } else return resolve_file_location("Reco_CaloTag_Z.root"); //note that in rel22 we switched from CaloTag to CaloScore. Now, we're not updating the filename yet to ensure backward compatibility, but it must be clear that in rel22 calibration areas this file will actually contain the CaloScore SFs.
422 }
std::string resolve_file_location(const std::string &filename) const
utility method to 'dress' a filename using the path resolver
std::string filename_Central() const
The following methods are meant to propagate information from the central tool to the subtool managin...

◆ filename_Central()

std::string CP::MuonEfficiencyScaleFactors::filename_Central ( ) const

The following methods are meant to propagate information from the central tool to the subtool managing the individual scale-factor maps to keep their constructors small in number of arguments.

The users do not have to call them. Construct the name of the input files from the configuration Make these methods public such that they can be used by the scale-factor managing EffiCollection class without piping All arguments to the constructor again

Definition at line 385 of file MuonEfficiencyScaleFactors.cxx.

385 {
388 return resolve_file_location(Form("Iso_%s_Z.root", m_wp.c_str()));
389 } else if (m_Type == CP::MuonEfficiencyType::TTVA) {
390 return resolve_file_location("TTVA_Z.root");
392 return resolve_file_location("BadMuonVeto_HighPt_Z.root");
393 } else if (m_Type == CP::MuonEfficiencyType::Reco) {
394 return resolve_file_location(Form("Reco_%s_Z.root", m_wp.c_str()));
395 }
396 ATH_MSG_ERROR("What?");
397 return "";
398 }

◆ filename_HighEta()

std::string CP::MuonEfficiencyScaleFactors::filename_HighEta ( ) const

High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means of tag & probe, but rather by building the double ratio.

The map is delivered in a dedicated file whose path is returned here

Definition at line 423 of file MuonEfficiencyScaleFactors.cxx.

423 {
424
427 return filename_Central();
428 } else return resolve_file_location("Reco_HighEta_Z.root");
429 }

◆ filename_LowPt()

std::string CP::MuonEfficiencyScaleFactors::filename_LowPt ( ) const

Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilon resonance.

Definition at line 430 of file MuonEfficiencyScaleFactors.cxx.

430 {
431
433 // for the no reco WPs, we currently use the existing Z SF also for the low pt regime
435 return filename_Central();
436 } else return resolve_file_location(Form("Reco_%s_JPsi.root", m_wp.c_str()));
437 }

◆ filename_LowPtCalo()

std::string CP::MuonEfficiencyScaleFactors::filename_LowPtCalo ( ) const

Definition at line 446 of file MuonEfficiencyScaleFactors.cxx.

446 {
447
449 // for the no reco WPs, we currently use the existing Z SF also for the low pt regime
451 return filename_Central();
452 } else return resolve_file_location("Reco_CaloTag_JPsi.root"); //note that in rel22 we switched from CaloTag to CaloScore. Now, we're not updating the filename yet to ensure backward compatibility, but it must be clear that in rel22 calibration areas this file will actually contain the CaloScore SFs.
453 }

◆ filename_LRTCentral()

std::string CP::MuonEfficiencyScaleFactors::filename_LRTCentral ( ) const

LRT muons have their own efficiency maps.

Definition at line 399 of file MuonEfficiencyScaleFactors.cxx.

399 {
402 ATH_MSG_WARNING("Using standard isolation SF for LRT muons");
403 return resolve_file_location(Form("Iso_%s_Z.root", m_wp.c_str()));
404 } else if (m_Type == CP::MuonEfficiencyType::TTVA) {
405 ATH_MSG_WARNING("Using standard TTVA SF for LRT muons");
406 return resolve_file_location("TTVA_Z.root");
408 ATH_MSG_WARNING("Using standard BadMuonVeto SF for LRT muons");
409 return resolve_file_location("BadMuonVeto_HighPt_Z.root");
410 } else if (m_Type == CP::MuonEfficiencyType::Reco) {
411 return resolve_file_location(Form("Reco_%sLRT_Z.root", m_wp.c_str()));
412 }
413 ATH_MSG_ERROR("What?");
414 return "";
415 }

◆ filename_LRTLowPt()

std::string CP::MuonEfficiencyScaleFactors::filename_LRTLowPt ( ) const

Definition at line 438 of file MuonEfficiencyScaleFactors.cxx.

438 {
439
441 // we use the Z SF for the low pt regime for Run-3
442 else if (m_Type != CP::MuonEfficiencyType::Reco || m_lowpt_threshold < 0 || m_calibration_version.find("run3") != std::string::npos) {
443 return filename_LRTCentral();
444 } else return resolve_file_location(Form("Reco_%sLRT_JPsi.root", m_wp.c_str()));
445 }
std::string filename_LRTCentral() const
LRT muons have their own efficiency maps.

◆ getDataEfficiency()

CorrectionCode CP::MuonEfficiencyScaleFactors::getDataEfficiency ( const xAOD::Muon & mu,
float & eff,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

Obtain the muon efficiency measured using the data.

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 310 of file MuonEfficiencyScaleFactors.cxx.

310 {
311 if (!m_init) {
312 ATH_MSG_ERROR("The tool has not been initialized yet");
314 }
315 unsigned int RunNumber = getRandomRunNumber(info);
316 return m_current_sf->retrieveSF(mu, RunNumber)->DataEfficiency(mu, eff);
317 }

◆ getDataEfficiencyReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::getDataEfficiencyReplicas ( const xAOD::Muon & mu,
std::vector< float > & sf_err,
const xAOD::EventInfo * info = 0 ) const
virtual

Definition at line 326 of file MuonEfficiencyScaleFactors.cxx.

326 {
327 if (!m_init) {
328 ATH_MSG_ERROR("The tool has not been initialized yet");
330 }
331 unsigned int RunNumber = getRandomRunNumber(info);
332 return m_current_sf->retrieveSF(mu, RunNumber)->DataEfficiencyReplicas(mu, sf_err);
333 }

◆ getEfficiencyScaleFactor() [1/2]

CorrectionCode CP::MuonEfficiencyScaleFactors::getEfficiencyScaleFactor ( columnar::MuonId mu,
float & sf,
columnar::EventInfoId info ) const

Definition at line 277 of file MuonEfficiencyScaleFactors.cxx.

277 {
278 if (!m_init) {
279 ATH_MSG_ERROR("The tool has not been initialized yet.");
281 }
282 unsigned int RunNumber = getRandomRunNumber(info);
283 return m_current_sf->retrieveSF(mu, RunNumber)->ScaleFactor(mu, sf);
284 }

◆ getEfficiencyScaleFactor() [2/2]

CorrectionCode CP::MuonEfficiencyScaleFactors::getEfficiencyScaleFactor ( const xAOD::Muon & mu,
float & sf,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

Retrieve the Scale factor and decorate the muon.

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 262 of file MuonEfficiencyScaleFactors.cxx.

262 {
263 if (!m_init) {
264 ATH_MSG_ERROR("The tool has not been initialized yet.");
266 }
267 if (!info) {
268 SG::ReadHandle<xAOD::EventInfo> evtInfo(m_eventInfo);
269 info = evtInfo.operator->();
270 if (!info) {
271 ATH_MSG_ERROR("Could not retrieve the xAOD::EventInfo. Return 999999");
273 }
274 }
276 }
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
ObjectId< ContainerId::eventInfo > EventInfoId

◆ getEfficiencyScaleFactorReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::getEfficiencyScaleFactorReplicas ( const xAOD::Muon & mu,
std::vector< float > & sf_err,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

replica generation

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 294 of file MuonEfficiencyScaleFactors.cxx.

294 {
295 if (!m_init) {
296 ATH_MSG_ERROR("The tool has not been initialized yet");
298 }
299 unsigned int RunNumber = getRandomRunNumber(info);
300 return m_current_sf->retrieveSF(mu, RunNumber)->ScaleFactorReplicas(mu, sfs);
301 }

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::TEvent, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getMCEfficiency()

CorrectionCode CP::MuonEfficiencyScaleFactors::getMCEfficiency ( const xAOD::Muon & mu,
float & eff,
const xAOD::EventInfo * info = 0 ) const
overridevirtual

Obtain the muon efficiency measured using the MC.

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 342 of file MuonEfficiencyScaleFactors.cxx.

342 {
343 if (!m_init) {
344 ATH_MSG_ERROR("The tool has not been initialized yet");
346 }
347 unsigned int RunNumber = getRandomRunNumber(info);
348 return m_current_sf->retrieveSF(mu, RunNumber)->MCEfficiency(mu, eff);
349 }

◆ getMCEfficiencyReplicas()

CorrectionCode CP::MuonEfficiencyScaleFactors::getMCEfficiencyReplicas ( const xAOD::Muon & mu,
std::vector< float > & sf_err,
const xAOD::EventInfo * info = 0 ) const
virtual

Definition at line 358 of file MuonEfficiencyScaleFactors.cxx.

358 {
359 if (!m_init) {
360 ATH_MSG_ERROR("The tool has not been initialized yet");
362 }
363 unsigned int RunNumber = getRandomRunNumber(info);
364 return m_current_sf->retrieveSF(mu, RunNumber)->MCEfficiencyReplicas(mu, sf_err);
365 }

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::TEvent, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getNCollections()

size_t CP::MuonEfficiencyScaleFactors::getNCollections ( ) const

Returns the number of EffiCollections stored in this class.

Definition at line 138 of file MuonEfficiencyScaleFactors.cxx.

138 {
139 return m_sf_sets.size();
140 }

◆ getPosition()

size_t CP::MuonEfficiencyScaleFactors::getPosition ( const EffiCollection * coll) const

Returns the position of the collection in the syst set vector.

If the collection is not part of this class -1 is returned

Definition at line 130 of file MuonEfficiencyScaleFactors.cxx.

130 {
131 size_t i = 0;
132 for (const auto& sf: m_sf_sets) {
133 if (sf.get() == coll) return i;
134 ++i;
135 }
136 return i;
137 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getRandomRunNumber() [1/2]

unsigned int CP::MuonEfficiencyScaleFactors::getRandomRunNumber ( columnar::EventInfoId info) const
private

Definition at line 247 of file MuonEfficiencyScaleFactors.cxx.

247 {
248 const auto& acc = *m_accessors;
249 if (!acc.eventTypeAcc(info,xAOD::EventInfo::IS_SIMULATION)) {
250 ATH_MSG_DEBUG("The current event is a data event. Return runNumber instead.");
251 return acc.runNumberAcc (info);
252 }
253 if (!acc.acc_rnd.isAvailable(info)) {
254 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.");
255 return 999999;
256 } else if (acc.acc_rnd(info) == 0) {
257 ATH_MSG_DEBUG("Pile up tool has given runNumber 0. Return SF from latest period.");
258 return 999999;
259 }
260 return acc.acc_rnd(info);
261 }
#define ATH_MSG_DEBUG(x)
@ IS_SIMULATION
true: simulation, false: data

◆ getRandomRunNumber() [2/2]

unsigned int CP::MuonEfficiencyScaleFactors::getRandomRunNumber ( const xAOD::EventInfo * info) const
private

Definition at line 236 of file MuonEfficiencyScaleFactors.cxx.

236 {
237 if (!info) {
238 SG::ReadHandle<xAOD::EventInfo> evtInfo(m_eventInfo);
239 info = evtInfo.operator->();
240 if (!info) {
241 ATH_MSG_ERROR("Could not retrieve the xAOD::EventInfo. Return 999999");
242 return 999999;
243 }
244 }
246 }

◆ getUncorrelatedSysBinName() [1/2]

std::string CP::MuonEfficiencyScaleFactors::getUncorrelatedSysBinName ( const SystematicSet & systConfig) const
overridevirtual

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 675 of file MuonEfficiencyScaleFactors.cxx.

675 {
676 for (std::set<SystematicVariation>::const_iterator t = systConfig.begin(); t != systConfig.end(); ++t) {
677 if ((*t).isToyVariation()) {
678 std::pair<unsigned, float> pair = (*t).getToyVariation();
679 return getUncorrelatedSysBinName(pair.first);
680 }
681 }
682 ATH_MSG_ERROR("The given systematic " << systConfig.name() << " is not an unfolded one. Return unknown bin ");
683 return "unknown bin";
684 }
virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const override
std::string name() const
returns: the systematics joined into a single string.
const_iterator end() const
description: const iterator to the end of the set
const_iterator begin() const
description: const iterator to the beginning of the set

◆ getUncorrelatedSysBinName() [2/2]

std::string CP::MuonEfficiencyScaleFactors::getUncorrelatedSysBinName ( unsigned int Bin) const
overridevirtual

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 660 of file MuonEfficiencyScaleFactors.cxx.

660 {
661 if (!m_current_sf){
662 throw std::runtime_error("No systematic has been loaded. Cannot return any syst-bin") ;
663 ATH_MSG_FATAL("No systematic has been loaded. Cannot return any syst-bin");
664
665 }
666 return m_current_sf->GetBinName(Bin);
667 }

◆ getUnCorrelatedSystBin()

int CP::MuonEfficiencyScaleFactors::getUnCorrelatedSystBin ( const xAOD::Muon & mu) const
overridevirtual

Implements CP::IMuonEfficiencyScaleFactors.

Definition at line 668 of file MuonEfficiencyScaleFactors.cxx.

668 {
669 if (!m_current_sf){
670 ATH_MSG_WARNING("No systematic has been loaded. Cannot return any syst-bin");
671 return -1;
672 }
673 return m_current_sf->getUnCorrelatedSystBin(mu);
674 }

◆ initialize()

StatusCode CP::MuonEfficiencyScaleFactors::initialize ( void )
overridevirtual

initialize the tool once all settings are in place!

Overwrite the property in case of the bad muon veto

for isolation efficiencies, we don't use a low pt component for now - set the low pt threshold to -1 same holds for TTVA SF, and for the HighPt WP

Reimplemented from asg::AsgTool.

Definition at line 144 of file MuonEfficiencyScaleFactors.cxx.

144 {
145 if (m_init) {
146 ATH_MSG_INFO("The tool using working point " << m_wp << " is already initialized.");
147 return StatusCode::SUCCESS;
148 }
149 if (m_wp.find("Iso") != std::string::npos) {
151
152 } else if (m_wp.find("BadMuon") != std::string::npos) {
155 m_applyKineDepSys = true;
156 } else if (m_wp.find("TTVA") != std::string::npos) {
158 } else {
160 if (m_useLRT && m_wp!="Medium") {
161 ATH_MSG_FATAL(Form("Only Medium identification WP is supported for LRT muons. You chose %s.", m_wp.c_str()));
162 return StatusCode::FAILURE;
163 }
164 }
165 ATH_MSG_INFO("Efficiency type is = " << EfficiencyTypeName(m_Type));
166
167 // temporary workaround to avoid bad Jpsi scale factors
168 if (m_lowpt_threshold < 0) { // not set by the user, use default values
169 if (m_calibration_version.find("run3") != std::string::npos) {
171 } else {
173 }
174 }
175
179 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!");
181 } else if (m_lowpt_threshold <= 0) {
182 ATH_MSG_INFO("Low pt SF turned off as crossover threshold is negative! Using Zmumu based SF for all pt values.");
183 } else {
184 ATH_MSG_INFO("JPsi based low pt SF will start to rock below " << m_lowpt_threshold / 1000. << " GeV!");
185 }
186
187 std::set<std::string> decorations{
188 sf_decoration() ,
194 };
195 if (decorations.size() != 6){
196 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");
197 return StatusCode::FAILURE;
198 }
199
200 ATH_CHECK(m_eventInfo.initialize());
201
202 if (!m_custom_dir.empty()) ATH_MSG_WARNING("Note: setting up with user specified input file location " << m_custom_dir << " - this is not encouraged!");
203 if (!m_custom_file_Calo.empty()) ATH_MSG_WARNING("Note: setting up with user specified CaloTag input file " << m_custom_file_Calo << " - this is not encouraged!");
204 if (!m_custom_file_Combined.empty()) ATH_MSG_WARNING("Note: setting up with user specified Central muon input file " << m_custom_file_Combined << " - this is not encouraged! ");
205 if (!m_custom_file_HighEta.empty()) ATH_MSG_WARNING("Note: setting up with user specified High Eta input file " << m_custom_file_HighEta << " - this is not encouraged! ");
206 if (!m_custom_file_LowPt.empty()) ATH_MSG_WARNING("Note: setting up with user specified Low Pt input file " << m_custom_file_LowPt << " - this is not encouraged! ");
207 if (!m_custom_file_LowPtCalo.empty()) ATH_MSG_WARNING("Note: setting up with user specified Low Pt CaloTag input file " << m_custom_file_LowPtCalo << " - this is not encouraged! ");
208 if (!m_custom_file_LRTCombined.empty()) ATH_MSG_WARNING("Note: setting up with user specified Central LRT muon input file " << m_custom_file_LRTCombined << " - this is not encouraged! ");
209 if (!m_custom_file_LRTLowPt.empty()) ATH_MSG_WARNING("Note: setting up with user specified Low Pt LRT muon input file " << m_custom_file_LowPt << " - this is not encouraged! ");
210 if (m_custom_dir.empty()) ATH_MSG_INFO("Trying to initialize, with working point " << m_wp << ", using calibration release " << m_calibration_version);
211
213
214 // m_init has to be true for affectingSystematics()
215 m_init = true;
217 // set up for default running without systematics
218 if (!applySystematicVariation(SystematicSet())) {
219 ATH_MSG_ERROR("loading the central value systematic set failed");
220 return StatusCode::FAILURE;
221 }
222
223 // Add the affecting systematics to the global registry
224 SystematicRegistry& registry = SystematicRegistry::getInstance();
225 if (!registry.registerSystematics(*this)) {
226 ATH_MSG_ERROR("unable to register the systematics");
227 return StatusCode::FAILURE;
228 }
229 ATH_MSG_INFO("Successfully initialized! ");
230
231 for (auto& sf_set : m_sf_sets)
232 addSubtool (*sf_set);
233 ATH_CHECK (initializeColumns());
234 return StatusCode::SUCCESS;
235 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
std::string sf_decoration() const
The apply<Blah> methods decorate their result directly to the muon.
virtual SystematicSet affectingSystematics() const override
returns: the list of all systematics this tool can be affected by
StatusCode LoadInputs()
load the SF histos
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
static std::string EfficiencyTypeName(CP::MuonEfficiencyType M)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isAffectedBySystematic()

bool CP::MuonEfficiencyScaleFactors::isAffectedBySystematic ( const SystematicVariation & systematic) const
overridevirtual

returns: whether this tool is affected by the given systematis

Implements CP::ISystematicsTool.

Definition at line 587 of file MuonEfficiencyScaleFactors.cxx.

587 {
588 return m_affectingSys.find(systematic) != m_affectingSys.end();
589 }

◆ LoadInputs()

StatusCode CP::MuonEfficiencyScaleFactors::LoadInputs ( )
private

load the SF histos

We've at least the stat and sys errors and nothing went wrong during loading the files

Push back the nominal options

Now we can fill the map with the individual sets

Filter the bits which are not assigning the files

J-psi stream... Kick all bits from the Z

...and the Z stream. Kick all bits from the JPsi

Definition at line 456 of file MuonEfficiencyScaleFactors.cxx.

456 {
457 if (!m_sf_sets.empty()){
458 ATH_MSG_DEBUG("Input already loaded will not do it again");
459 return StatusCode::SUCCESS;
460 }
461 std::map<std::string, unsigned int> systematics = lookUpSystematics();
464 if (systematics.empty()){
465 ATH_MSG_FATAL("No valid systematic could be loaded. Not even the statistical uncertainties");
466 return StatusCode::FAILURE;
467 }
468
470 m_sf_sets.push_back( std::make_unique<EffiCollection>(*this));
471 EffiCollection* nominal = m_sf_sets.back().get();
472
473 std::function<unsigned int(unsigned int, unsigned int)> not_inB = [](unsigned int a , unsigned int b){
474 unsigned int b_flipped = ~b;
475 return a & b_flipped;
476 };
478 for (const auto& syst: systematics){
480 if ((syst.second & EffiCollection::ZAnalysis) && (syst.second & EffiCollection::JPsiAnalysis)) {
482 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, not_inB(syst.second, EffiCollection::ZAnalysis), false));
483 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, not_inB(syst.second, EffiCollection::ZAnalysis), true));
485 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, not_inB(syst.second, EffiCollection::JPsiAnalysis), true));
486 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, not_inB(syst.second, EffiCollection::JPsiAnalysis), false));
487 } else {
488 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, syst.second, false));
489 m_sf_sets.push_back(std::make_unique < EffiCollection > (nominal, *this, syst.first, syst.second, true));
490 }
491 }
492 for(auto& sf: m_sf_sets){
493 if (!sf->CheckConsistency()) {
494 ATH_MSG_FATAL("Inconsistent scalefactor maps have been found for "<<(sf->getSystSet() ?sf->getSystSet()->name() : "UNKOWN"));
495 return StatusCode::FAILURE;
496 }
497 }
498 for (auto& sf_set : m_sf_sets)
499 addSubtool (*sf_set);
500 return StatusCode::SUCCESS;
501 }
static const std::vector< std::string > systematics
@ JPsiAnalysis
Distinguish these two because the systematics are named with an extra LOWPT.
std::map< std::string, unsigned int > lookUpSystematics()
Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual compo...
setRawEt setRawPhi int

◆ lookUpSystematics()

std::map< std::string, unsigned int > CP::MuonEfficiencyScaleFactors::lookUpSystematics ( )
private

Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual components.

This method loads all systematics and looks their systematics up and returns them in a map together with a bitmask which files are affected by the systematic

All file_name methods return the central filename if there is no proper map for that component use a set to sort out all non-defined maps

The bad muon veto measurement only provides a combined systematic uncertainty of the bad-muon veto. No stat error needed in this case

If the systematics shall be split into bins

At the moment the systematic break down is not part of all files ignore if there is no break down

Activate the pt-dependent systematic for the old calibration files by hand

Read out the systematic tree from the scale-factor files

Definition at line 502 of file MuonEfficiencyScaleFactors.cxx.

502 {
503 std::map<std::string, unsigned int> syst_map;
506 std::set<std::string> files_to_look_up{
512 };
513 if (m_useLRT) {
514 files_to_look_up.insert(filename_LRTCentral());
515 files_to_look_up.insert(filename_LRTLowPt());
516 }
517 std::function<int(const std::string&)> get_bit = [this](const std::string& file_name){
518 if (file_name == filename_Central()) return EffiCollection::Central;
519 if (file_name == filename_LowPt()) return EffiCollection::CentralLowPt;
520 if (file_name == filename_Calo()) return EffiCollection::Calo;
521 if (file_name == filename_LowPtCalo()) return EffiCollection::CaloLowPt;
522 if (this->use_lrt()) {
523 if (file_name == filename_LRTCentral()) return EffiCollection::Central;
524 if (file_name == filename_LRTLowPt()) return EffiCollection::CentralLowPt;
525 }
526 // last file which remains is forward
528 };
529
530 std::function<void(const std::string&,int)> insert_bit =[&syst_map](const std::string& key, unsigned int bit){
531 if (syst_map.find(key) == syst_map.end()) syst_map.insert(std::pair<std::string, unsigned int>(key,bit));
532 else syst_map[key] = syst_map[key] | bit;
533 };
534 for (const auto& look_up : files_to_look_up){
535 std::unique_ptr<TFile> root_file(TFile::Open(look_up.c_str(), "READ"));
536 if (!root_file || !root_file->IsOpen()){
537 ATH_MSG_FATAL("Could not open file "<<look_up);
538 syst_map.clear();
539 break;
540 }
544 insert_bit("STAT", get_bit(look_up));
545 }
547 if (m_seperateSystBins) insert_bit("STAT", EffiCollection::UnCorrelated);
548
549 TTree* syst_tree = nullptr;
550 root_file->GetObject("Systematics", syst_tree);
551
554 if (!m_breakDownSyst || syst_tree == nullptr){
555 ATH_MSG_DEBUG("The file "<<look_up<<" does not contain any systematic tree. No break down for that one will be considered");
556 insert_bit("SYS",get_bit(look_up));
559 insert_bit("SYS", EffiCollection::PtDependent);
560 }
561 continue;
562 }
564 std::string* syst_name = nullptr;
565 bool is_symmetric(0), has_pt_sys(0), uncorrelated(0);
566 if (syst_tree->SetBranchAddress("Name", &syst_name) != 0 ||
567 syst_tree->SetBranchAddress("IsSymmetric", &is_symmetric) != 0 ||
568 syst_tree->SetBranchAddress("HasPtDependentSys", &has_pt_sys) !=0 ||
569 syst_tree->SetBranchAddress("CanBeUncorrelated", &uncorrelated) !=0){
570
571
572 ATH_MSG_FATAL("Although "<<look_up<<" has a systematic tree. There is no proper connection to the branches");
573 syst_map.clear();
574 break;
575 }
576 for (int i =0; syst_tree->GetEntry(i); ++i){
577 insert_bit( *syst_name, get_bit(look_up));
578 if (is_symmetric) insert_bit(*syst_name, EffiCollection::Symmetric);
579
580 if (m_applyKineDepSys && has_pt_sys) {
581 insert_bit(*syst_name, EffiCollection::PtDependent);
582 }if (m_seperateSystBins && uncorrelated) insert_bit(*syst_name, EffiCollection::UnCorrelated);
583 }
584 }
585 return syst_map;
586 }
@ Central
The five different scale-factor maps.
std::string filename_HighEta() const
High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means ...
std::string filename_Calo() const
Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0....
CP::MuonEfficiencyType measurement() const
Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.
bool use_lrt() const
option to set if we want to use LRT muons
std::string filename_LowPt() const
Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilo...

◆ lowPtTransition()

float CP::MuonEfficiencyScaleFactors::lowPtTransition ( ) const

If the pt of the muon is below that threshold the J/Psi or Upsilon map is used given that it's available.

Definition at line 105 of file MuonEfficiencyScaleFactors.cxx.

105 {
106 return m_lowpt_threshold;
107 }

◆ mc_effi_decoration()

std::string CP::MuonEfficiencyScaleFactors::mc_effi_decoration ( ) const

Definition at line 118 of file MuonEfficiencyScaleFactors.cxx.

118 {
119 return m_efficiency_decoration_name_mc.empty() ? std::string("MCEffi") + m_wp : m_efficiency_decoration_name_mc;
120 }

◆ mc_effi_replica_deocration()

std::string CP::MuonEfficiencyScaleFactors::mc_effi_replica_deocration ( ) const

Definition at line 127 of file MuonEfficiencyScaleFactors.cxx.

127 {
128 return std::string("Replica") + mc_effi_decoration();
129 }

◆ measurement()

CP::MuonEfficiencyType CP::MuonEfficiencyScaleFactors::measurement ( ) const

Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.

Definition at line 109 of file MuonEfficiencyScaleFactors.cxx.

109 {
110 return m_Type;
111 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ recommendedSystematics()

SystematicSet CP::MuonEfficiencyScaleFactors::recommendedSystematics ( ) const
overridevirtual

returns: the list of all systematics this tool recommends to use

Implements CP::IReentrantSystematicsTool.

Definition at line 605 of file MuonEfficiencyScaleFactors.cxx.

605 {
606 if (!m_init) {
607 ATH_MSG_ERROR("The tool has not been initialized yet");
608 return CP::SystematicSet();
609 }
610 return affectingSystematics();
611 }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ resolve_file_location()

std::string CP::MuonEfficiencyScaleFactors::resolve_file_location ( const std::string & filename) const
private

utility method to 'dress' a filename using the path resolver

Definition at line 375 of file MuonEfficiencyScaleFactors.cxx.

375 {
376 if (!m_custom_dir.empty()) {
377 return m_custom_dir + "/" + filename;
378 }
379 std::string fullPathToFile = PathResolverFindCalibFile(Form("MuonEfficiencyCorrections/%s/%s", m_calibration_version.c_str(), filename.c_str()));
380 if (fullPathToFile.empty()) {
381 ATH_MSG_ERROR("Unable to resolve the input file " << m_calibration_version << "/" << filename << " via the PathResolver!");
382 }
383 return fullPathToFile;
384 }
std::string PathResolverFindCalibFile(const std::string &logical_file_name)

◆ sf_decoration()

std::string CP::MuonEfficiencyScaleFactors::sf_decoration ( ) const

The apply<Blah> methods decorate their result directly to the muon.

The name of the decorators can be set by the users themselves using several properties. To avoid that systmatics overwrite each other and the nominal the final maps are decorating the muon following the logic <decoration>__<syst_name> The following methods propagate the basic decoration names to the maps

Definition at line 112 of file MuonEfficiencyScaleFactors.cxx.

112 {
113 return m_sf_decoration_name.empty() ? std::string("SF") + m_wp : m_sf_decoration_name;
114 }

◆ sf_replica_decoration()

std::string CP::MuonEfficiencyScaleFactors::sf_replica_decoration ( ) const

Definition at line 121 of file MuonEfficiencyScaleFactors.cxx.

121 {
122 return std::string("Replica") + sf_decoration();
123 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ uncorrelate_sys()

bool CP::MuonEfficiencyScaleFactors::uncorrelate_sys ( ) const

Returns a boolean whether the uncorrelation of systematics has been switched on.

Definition at line 108 of file MuonEfficiencyScaleFactors.cxx.

108{ return m_seperateSystBins; }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ use_2D_iso_corrections()

bool CP::MuonEfficiencyScaleFactors::use_2D_iso_corrections ( ) const

option to set if we want to use 1D or 2D isolation SFs

Definition at line 102 of file MuonEfficiencyScaleFactors.cxx.

102 {
103 return m_use2DIsoCorr;
104 }

◆ use_lrt()

bool CP::MuonEfficiencyScaleFactors::use_lrt ( ) const

option to set if we want to use LRT muons

Definition at line 141 of file MuonEfficiencyScaleFactors.cxx.

141 {
142 return m_useLRT;
143 }

Member Data Documentation

◆ m_accessors

std::unique_ptr<Accessors> CP::MuonEfficiencyScaleFactors::m_accessors
private

Definition at line 217 of file MuonEfficiencyScaleFactors.h.

◆ m_affectingSys

CP::SystematicSet CP::MuonEfficiencyScaleFactors::m_affectingSys
private

Definition at line 200 of file MuonEfficiencyScaleFactors.h.

◆ m_applyKineDepSys

bool CP::MuonEfficiencyScaleFactors::m_applyKineDepSys
private

Definition at line 208 of file MuonEfficiencyScaleFactors.h.

◆ m_breakDownSyst

bool CP::MuonEfficiencyScaleFactors::m_breakDownSyst
private

Definition at line 207 of file MuonEfficiencyScaleFactors.h.

◆ m_calibration_version

std::string CP::MuonEfficiencyScaleFactors::m_calibration_version
private

subfolder to load from the calibration db

Definition at line 192 of file MuonEfficiencyScaleFactors.h.

◆ m_current_sf

EffiCollection* CP::MuonEfficiencyScaleFactors::m_current_sf
private

Pointer to the current active map in terms of systematics.

Definition at line 174 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_dir

std::string CP::MuonEfficiencyScaleFactors::m_custom_dir
private

Definition at line 176 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_Calo

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_Calo
private

Definition at line 178 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_Combined

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_Combined
private

Definition at line 177 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_HighEta

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_HighEta
private

Definition at line 179 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_LowPt

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_LowPt
private

Definition at line 180 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_LowPtCalo

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_LowPtCalo
private

Definition at line 181 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_LRTCombined

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_LRTCombined
private

Definition at line 182 of file MuonEfficiencyScaleFactors.h.

◆ m_custom_file_LRTLowPt

std::string CP::MuonEfficiencyScaleFactors::m_custom_file_LRTLowPt
private

Definition at line 183 of file MuonEfficiencyScaleFactors.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_efficiency_decoration_name_data

std::string CP::MuonEfficiencyScaleFactors::m_efficiency_decoration_name_data
private

Definition at line 187 of file MuonEfficiencyScaleFactors.h.

◆ m_efficiency_decoration_name_mc

std::string CP::MuonEfficiencyScaleFactors::m_efficiency_decoration_name_mc
private

Definition at line 188 of file MuonEfficiencyScaleFactors.h.

◆ m_eventInfo

SG::ReadHandleKey<xAOD::EventInfo> CP::MuonEfficiencyScaleFactors::m_eventInfo {this, "EventInfoContName", "EventInfo", "event info key"}
private

Definition at line 85 of file MuonEfficiencyScaleFactors.h.

85{this, "EventInfoContName", "EventInfo", "event info key"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_filtered_sys_sets

std::unordered_map<CP::SystematicSet, EffiCollection*> CP::MuonEfficiencyScaleFactors::m_filtered_sys_sets
private

It turned out that the code spends a large time in the look up of the systematics.

This map tries to mitigate this issue.

Definition at line 203 of file MuonEfficiencyScaleFactors.h.

◆ m_init

bool CP::MuonEfficiencyScaleFactors::m_init
private

Definition at line 205 of file MuonEfficiencyScaleFactors.h.

◆ m_iso_jet_dR

std::string CP::MuonEfficiencyScaleFactors::m_iso_jet_dR
private

Name of the decoration to catch up the close by jets.

Definition at line 198 of file MuonEfficiencyScaleFactors.h.

◆ m_lowpt_threshold

float CP::MuonEfficiencyScaleFactors::m_lowpt_threshold
private

threshold below which low-pt SF (i.e. from JPsi) should be used

Definition at line 196 of file MuonEfficiencyScaleFactors.h.

◆ m_seperateSystBins

bool CP::MuonEfficiencyScaleFactors::m_seperateSystBins
private

Definition at line 206 of file MuonEfficiencyScaleFactors.h.

◆ m_sf_decoration_name

std::string CP::MuonEfficiencyScaleFactors::m_sf_decoration_name
private

Definition at line 189 of file MuonEfficiencyScaleFactors.h.

◆ m_sf_sets

std::vector<std::unique_ptr<EffiCollection> > CP::MuonEfficiencyScaleFactors::m_sf_sets
private

This vector stores all scale-factor maps.

Definition at line 171 of file MuonEfficiencyScaleFactors.h.

◆ m_Type

CP::MuonEfficiencyType CP::MuonEfficiencyScaleFactors::m_Type
private

Definition at line 212 of file MuonEfficiencyScaleFactors.h.

◆ m_use2DIsoCorr

bool CP::MuonEfficiencyScaleFactors::m_use2DIsoCorr
private

Definition at line 199 of file MuonEfficiencyScaleFactors.h.

◆ m_useLRT

bool CP::MuonEfficiencyScaleFactors::m_useLRT
private

Turn on if using LRT objects.

Definition at line 210 of file MuonEfficiencyScaleFactors.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_wp

std::string CP::MuonEfficiencyScaleFactors::m_wp
private

the working point to operate on

Definition at line 168 of file MuonEfficiencyScaleFactors.h.


The documentation for this class was generated from the following files: