ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSFTestHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef XAOD_STANDALONE
5#ifndef MUONEFFICIENCYCORRECTION_MUONSFTESTHELPER_H
6#define MUONEFFICIENCYCORRECTION_MUONSFTESTHELPER_H
7
8// EDM include(s):
9#include "xAODMuon/Muon.h"
10
11// Tool Includes
15
19
20#include <GaudiKernel/ToolHandle.h>
21
22//General includes
23#include <memory>
24#include <map>
25#include <TTree.h>
26#include <TH1.h>
27#include <TFile.h>
28//Helper class to test the Muon efficiency SFs plus their systematics
29namespace TestMuonSF {
30 //####################################################
31 // Helper class to write ntuples to test the #
32 // MuonTriggerScaleFactors #
33 //####################################################
34
36 public:
38 const ToolHandle<CP::IMuonTriggerScaleFactors>& Handle,
39 const std::string& muonContainer,
40 const std::string& Trigger);
41 virtual ~TriggerSFBranches() = default;
42
43 bool fill(const EventContext& ctx) override final;
44 bool init() override final;
45
46 private:
48 MuonVal::ScalarBranch<double> &Var,
50
51 SG::ReadHandleKey<xAOD::MuonContainer> m_key{};
52
53 ToolHandle<CP::IMuonTriggerScaleFactors> m_handle{};
54 std::string m_trigger{};
60 };
61
62
64 public:
65 virtual void setMuon(const xAOD::Muon& muon) = 0;
66 };
67 //###################################################################
68 // Helper class to write the scale-factor ntuples to test the #
69 // MuonReconstruction/ Isolation/ TTVA scalefactors #
70 //###################################################################
72 public:
74 const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle,
75 const std::string& rel_name = "");
76
77 virtual ~MuonSFBranches() = default;
78
79
80 void setMuon(const xAOD::Muon& muon) override final;
81
82 bool fill(const EventContext& ctx) override final;
83
84 bool init() override final;
85
87 static std::string systName(const CP::SystematicSet& set) {
88 return set.name().empty() ? std::string("") : std::string("__") + set.name();
89 }
90
91 private:
92 ToolHandle<CP::IMuonEfficiencyScaleFactors> m_handle{};
93 bool m_uncorrelate_sys{false};
94
97 struct SFSet {
98 SFSet(const CP::SystematicSet& cpSet_,
99 MuonSFBranches& parent_):
100 cpSet{cpSet_}, parent{parent_}{}
101
102 bool init() {
103 return scaleFactor.init() && mcEff.init() && dataEff.init();
104 }
105
106 bool fill(const EventContext& ctx) {
107 return scaleFactor.fill(ctx) && mcEff.fill(ctx) && dataEff.fill(ctx);
108 }
109
117 };
118
119 CP::CorrectionCode fillSystematic(const xAOD::Muon& muon, SFSet& set);
120
121 std::vector<std::unique_ptr<SFSet>> m_SFs{};
122
123 };
124 //#######################################################
125 // Helper class for writing #
126 // scale-factor replicas to the test-ntuples #
127 //#######################################################
128
130 public:
132 const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle,
133 const std::string& rel_name = "");
134
135 void setMuon(const xAOD::Muon& muon) override final;
136
137 bool init() override;
138
139 bool fill(const EventContext& ctx) override;
140
141 private:
142 ToolHandle<CP::IMuonEfficiencyScaleFactors> m_handle{};
143
144 std::map<CP::SystematicSet, std::shared_ptr<MuonVal::VectorBranch<float>>> m_SFs{};
145 };
146}
147#endif
148#endif
xAOD::MuonContainer * muonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
static const Attributes_t empty
Return value from object correction CP tools.
Class to wrap a set of SystematicVariations.
Return value from object correction CP tools.
std::string name() const override final
Returns the name of the branch.
TTree * tree() override final
Returns the underlying TTree object.
Class to wrap a set of SystematicVariations.
virtual void setMuon(const xAOD::Muon &muon)=0
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
virtual ~MuonSFBranches()=default
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
virtual ~TriggerSFBranches()=default
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
STL class.
Select isolated Photons, Electrons and Muons.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19
Forward declaration.
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Muon_v1 Muon
Reference the current persistent version:
const CP::SystematicSet cpSet
Systematic set.
MuonSFBranches & parent
Parent from which the TTree pointer & name is retrieved.
MuonVal::ScalarBranch< float > scaleFactor
Actual branches storing scaleFactor & mcEff & dataEff.
bool fill(const EventContext &ctx)
check that all branches are set properly
SFSet(const CP::SystematicSet &cpSet_, MuonSFBranches &parent_)
MuonVal::ScalarBranch< float > dataEff
bool init()
Initialization of the branches.
MuonVal::ScalarBranch< float > mcEff
#define private