20 const T* HandlePtr = asg_tool->
getProperty < T > (prop_name);
21 if (!HandlePtr) Error(
"getProperty()",
"Failed to retrieve property %s ", prop_name.c_str());
22 else prop = (*HandlePtr);
30 const ToolHandle<CP::IMuonTriggerScaleFactors>& Handle,
32 const std::string& Trigger):
76 if (
m_handle->applySystematicVariation(syst_set) != StatusCode::SUCCESS) {
91 const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle,
92 const std::string& relName) :
100 ATH_MSG_ERROR(
"Given tool not MuonCP::MuonEfficiencyScaleFactors");
106 m_SFs.emplace_back(std::make_unique<SFSet>(
set, *
this));
107 if (!
m_SFs.back()->init())
return false;
113 for (
auto& sys :
m_SFs) {
114 if (!sys->fill(ctx))
return false;
124 for (
auto& Syst_SF :
m_SFs) {
133 ATH_MSG_WARNING(
"Did not find a valid bin for muon with pT: "<<muon.pt() *MeVtoGeV <<
" GeV, eta:"<<
134 muon.eta()<<
", phi: "<<muon.phi());
137 for (
auto& Syst_SF:
m_SFs){
139 bool process = Syst_SF->cpSet.name().empty() ||
140 std::find_if(Syst_SF->cpSet.begin(), Syst_SF->cpSet.end(),
142 return t.isToyVariation() && t.getToyVariation().first ==
143 static_cast<unsigned>(bin);
144 }) != Syst_SF->cpSet.end();
156 if (
m_handle->applySystematicVariation(Syst_SF.
cpSet) != StatusCode::SUCCESS) {
169 if (std::abs(muon.eta()) > 2.5) {
174 cc =
m_handle->getDataEfficiency(muon, sf);
180 cc =
m_handle->getMCEfficiency(muon, sf);
194 const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle,
195 const std::string& relName) :
204 if(!br->init())
return false;
209 for (
auto& [sys, br] :
m_SFs) {
210 if (!br->fill(ctx)) {
219 for (
auto& [cpSys, br] :
m_SFs) {
220 if (
m_handle->applySystematicVariation(cpSys) != StatusCode::SUCCESS) {
223 std::vector<float> replica{};
228 for (
auto repl : replica) {
#define ATH_MSG_WARNING(x)
xAOD::MuonContainer * muonContainer
static const Attributes_t empty
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
bool empty() const noexcept
Returns true if the collection is empty.
MuonTesterBranch(MuonTesterTree &tree, const std::string &br_name)
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
std::string name() const override final
Returns the name of the branch.
TTree * tree() override final
Returns the underlying TTree object.
const_pointer_type cptr()
Dereference the pointer.
bool isPresent() const
Is the referenced object present in SG?
bool init() override
The init method checks whether the branch name has already registered to the MuonTree and tries then ...
void setMuon(const xAOD::Muon &muon) override final
ToolHandle< CP::IMuonEfficiencyScaleFactors > m_handle
bool fill(const EventContext &ctx) override
The fill method checks if enough information is provided such that the branch is cleared from the inf...
std::map< CP::SystematicSet, std::shared_ptr< MuonVal::VectorBranch< float > > > m_SFs
MuonReplicaBranches(MuonVal::MuonTesterTree &tree, const ToolHandle< CP::IMuonEfficiencyScaleFactors > &handle, const std::string &rel_name="")
MuonSFBranches(MuonVal::MuonTesterTree &tree, const ToolHandle< CP::IMuonEfficiencyScaleFactors > &handle, const std::string &rel_name="")
static std::string systName(const CP::SystematicSet &set)
Dummy helper function that encodes the systname set.
bool init() override final
The init method checks whether the branch name has already registered to the MuonTree and tries then ...
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
std::vector< std::unique_ptr< SFSet > > m_SFs
CP::CorrectionCode fillSystematic(const xAOD::Muon &muon, SFSet &set)
ToolHandle< CP::IMuonEfficiencyScaleFactors > m_handle
void setMuon(const xAOD::Muon &muon) override final
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
TriggerSFBranches(MuonVal::MuonTesterTree &tree, const ToolHandle< CP::IMuonTriggerScaleFactors > &Handle, const std::string &muonContainer, const std::string &Trigger)
ToolHandle< CP::IMuonTriggerScaleFactors > m_handle
MuonVal::ScalarBranch< double > m_sys_down_SF
bool init() override final
The init method checks whether the branch name has already registered to the MuonTree and tries then ...
MuonVal::ScalarBranch< double > m_nominal_SF
SG::ReadHandleKey< xAOD::MuonContainer > m_key
MuonVal::ScalarBranch< double > m_stat_up_SF
CP::CorrectionCode getSF(const xAOD::MuonContainer *muons, MuonVal::ScalarBranch< double > &Var, const CP::SystematicVariation &syst)
MuonVal::ScalarBranch< double > m_stat_down_SF
MuonVal::ScalarBranch< double > m_sys_up_SF
const std::string process
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
std::vector< CP::SystematicSet > make_systematics_vector(const SystematicSet &systematics)
utility functions for working with systematics
Class to store array like branches into the n-tuples.
T getProperty(const asg::IAsgTool *interface_tool, const std::string &prop_name)
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Helper struct to store scale factor, data efficiency + mc efficiency for each systematic variation.
const CP::SystematicSet cpSet
Systematic set.
MuonVal::ScalarBranch< float > scaleFactor
Actual branches storing scaleFactor & mcEff & dataEff.
MuonVal::ScalarBranch< float > dataEff
MuonVal::ScalarBranch< float > mcEff