ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
MuonID
MuonIDAnalysis
MuonEfficiencyCorrections
src
MuonScaleFactorTestAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Local include(s):
6
#include "
MuonScaleFactorTestAlg.h
"
7
#include "
StoreGate/ReadHandle.h
"
8
#include "
MuonTesterTree/EventInfoBranch.h
"
9
#include "
PATInterfaces/SystematicsTool.h
"
10
#include <cmath>
11
12
namespace
{
13
constexpr
double
MeVtoGeV
= 1.e-3;
14
}
15
16
namespace
CP
{
17
MuonScaleFactorTestAlg::MuonScaleFactorTestAlg
(
const
std::string&
name
, ISvcLocator* svcLoc) :
18
AthHistogramAlgorithm
(
name
, svcLoc) {
19
// force strict checking of return codes
20
CP::CorrectionCode::enableFailure
();
21
}
22
23
StatusCode
MuonScaleFactorTestAlg::initialize
() {
24
ATH_CHECK
(
m_eventInfo
.initialize());
25
ATH_CHECK
(
m_sgKey
.initialize());
26
ATH_CHECK
(
m_prw_Tool
.retrieve());
27
ATH_CHECK
(
m_sel_tool
.retrieve());
28
29
ATH_MSG_DEBUG
(
"PileupReweightingTool = "
<<
m_prw_Tool
);
30
ATH_CHECK
(
m_effiTools
.retrieve());
31
ATH_CHECK
(
m_comparisonTools
.retrieve());
32
for
(
auto
& tool :
m_effiTools
) {
33
auto
sfBranch = std::make_shared<TestMuonSF::MuonSFBranches>(
m_tree
,tool,
34
m_comparisonTools
.empty() ?
""
:
m_defaultRelease
.value());
35
36
m_sfBranches
.push_back(sfBranch);
37
m_tree
.addBranch(sfBranch);
38
39
auto
replicaBranch = std::make_shared<TestMuonSF::MuonReplicaBranches>(
m_tree
, tool,
40
m_comparisonTools
.empty() ?
""
:
m_defaultRelease
.value());
41
42
m_sfBranches
.push_back(replicaBranch);
43
m_tree
.addBranch(replicaBranch);
44
}
45
for
(
auto
& tool :
m_comparisonTools
) {
46
auto
sfBranch = std::make_shared<TestMuonSF::MuonSFBranches>(
m_tree
, tool,
m_validRelease
);
47
m_sfBranches
.push_back(sfBranch);
48
m_tree
.addBranch(sfBranch);
49
50
auto
replicaBranch = std::make_shared<TestMuonSF::MuonReplicaBranches>(
m_tree
,tool,
m_validRelease
);
51
m_sfBranches
.push_back(replicaBranch);
52
m_tree
.addBranch(replicaBranch);
53
}
54
m_tree
.addBranch(std::make_shared<MuonVal::EventInfoBranch>(
m_tree
, 0));
55
ATH_CHECK
(
m_tree
.init(
this
));
56
return
StatusCode::SUCCESS;
57
}
58
StatusCode
MuonScaleFactorTestAlg::finalize
() {
59
ATH_CHECK
(
m_tree
.write());
60
return
StatusCode::SUCCESS;
61
}
62
63
StatusCode
MuonScaleFactorTestAlg::execute
(
const
EventContext& ctx) {
64
// Retrieve the muons:
65
SG::ReadHandle<xAOD::MuonContainer>
muons{
m_sgKey
, ctx};
66
// Retrieve the EventInfo:
67
SG::ReadHandle<xAOD::EventInfo>
ei{
m_eventInfo
, ctx};
68
69
ATH_MSG_DEBUG
(
"Start to run over event "
<<ei->eventNumber()<<
" in run"
<<ei->runNumber());
70
71
//Apply the prwTool first before calling the efficiency correction methods
72
ATH_CHECK
(
m_prw_Tool
->apply(*ei));
73
74
for
(
const
xAOD::Muon
* mu : *muons) {
75
if
(mu->pt() <
m_pt_cut
|| (
m_eta_cut
> 0 && std::abs(mu->eta()) >=
m_eta_cut
))
continue
;
76
// reject all loose muons
77
if
(
Muon::MuonStationIndex::toInt
(
m_sel_tool
->getQuality(*mu)) >
m_muon_quality
)
continue
;
78
79
m_muonPt
= mu->pt() *
MeVtoGeV
;
80
m_muonEta
= mu->eta();
81
m_muonPhi
= mu->phi();
82
m_muonQ
= mu->charge();
83
for
(
auto
& br :
m_sfBranches
) {
84
br->setMuon(*mu);
85
}
86
ATH_CHECK
(
m_tree
.fill(ctx));
87
}
88
ATH_MSG_DEBUG
(
"Done with processing the event"
);
89
// Return gracefully:
90
return
StatusCode::SUCCESS;
91
}
92
93
}
// namespace CP
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
EventInfoBranch.h
MuonScaleFactorTestAlg.h
ReadHandle.h
Handle class for reading from StoreGate.
SystematicsTool.h
AthHistogramAlgorithm::AthHistogramAlgorithm
AthHistogramAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition
AthHistogramAlgorithm.cxx:31
CP::CorrectionCode::enableFailure
static void enableFailure() noexcept
Definition
CorrectionCode.h:64
CP::MuonScaleFactorTestAlg::m_muonPt
MuonVal::ScalarBranch< float > & m_muonPt
Definition
MuonScaleFactorTestAlg.h:66
CP::MuonScaleFactorTestAlg::m_prw_Tool
ToolHandle< IPileupReweightingTool > m_prw_Tool
Scale factor tool.
Definition
MuonScaleFactorTestAlg.h:50
CP::MuonScaleFactorTestAlg::m_effiTools
ToolHandleArray< IMuonEfficiencyScaleFactors > m_effiTools
Definition
MuonScaleFactorTestAlg.h:46
CP::MuonScaleFactorTestAlg::finalize
StatusCode finalize() override
Function finalizing the algortihm.
Definition
MuonScaleFactorTestAlg.cxx:58
CP::MuonScaleFactorTestAlg::execute
StatusCode execute(const EventContext &ctx) override
Function executing the algorithm.
Definition
MuonScaleFactorTestAlg.cxx:63
CP::MuonScaleFactorTestAlg::m_sgKey
SG::ReadHandleKey< xAOD::MuonContainer > m_sgKey
muon container
Definition
MuonScaleFactorTestAlg.h:44
CP::MuonScaleFactorTestAlg::m_validRelease
Gaudi::Property< std::string > m_validRelease
Definition
MuonScaleFactorTestAlg.h:57
CP::MuonScaleFactorTestAlg::m_sel_tool
ToolHandle< IMuonSelectionTool > m_sel_tool
Definition
MuonScaleFactorTestAlg.h:51
CP::MuonScaleFactorTestAlg::m_tree
MuonVal::MuonTesterTree m_tree
Definition
MuonScaleFactorTestAlg.h:64
CP::MuonScaleFactorTestAlg::m_sfBranches
std::vector< std::shared_ptr< TestMuonSF::MuonEffiBranch > > m_sfBranches
Definition
MuonScaleFactorTestAlg.h:71
CP::MuonScaleFactorTestAlg::m_eta_cut
Gaudi::Property< float > m_eta_cut
Definition
MuonScaleFactorTestAlg.h:60
CP::MuonScaleFactorTestAlg::m_muonPhi
MuonVal::ScalarBranch< float > & m_muonPhi
Definition
MuonScaleFactorTestAlg.h:68
CP::MuonScaleFactorTestAlg::m_comparisonTools
ToolHandleArray< IMuonEfficiencyScaleFactors > m_comparisonTools
Definition
MuonScaleFactorTestAlg.h:47
CP::MuonScaleFactorTestAlg::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition
MuonScaleFactorTestAlg.h:42
CP::MuonScaleFactorTestAlg::m_defaultRelease
Gaudi::Property< std::string > m_defaultRelease
Definition
MuonScaleFactorTestAlg.h:56
CP::MuonScaleFactorTestAlg::MuonScaleFactorTestAlg
MuonScaleFactorTestAlg(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition
MuonScaleFactorTestAlg.cxx:17
CP::MuonScaleFactorTestAlg::m_muon_quality
Gaudi::Property< int > m_muon_quality
Definition
MuonScaleFactorTestAlg.h:61
CP::MuonScaleFactorTestAlg::m_pt_cut
Gaudi::Property< float > m_pt_cut
Definition
MuonScaleFactorTestAlg.h:59
CP::MuonScaleFactorTestAlg::m_muonQ
MuonVal::ScalarBranch< int > & m_muonQ
Definition
MuonScaleFactorTestAlg.h:69
CP::MuonScaleFactorTestAlg::initialize
StatusCode initialize() override
Function initialising the algorithm.
Definition
MuonScaleFactorTestAlg.cxx:23
CP::MuonScaleFactorTestAlg::m_muonEta
MuonVal::ScalarBranch< float > & m_muonEta
Definition
MuonScaleFactorTestAlg.h:67
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::MeVtoGeV
constexpr float MeVtoGeV
Definition
IsolationCloseByCorrectionTool.cxx:38
Muon::MuonStationIndex::toInt
constexpr int toInt(const EnumType enumVal)
Definition
MuonStationIndex.h:62
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
Generated on
for ATLAS Offline Software by
1.17.0