ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
src
JetRecAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// JetRecAlg.cxx
6
7
#include <memory>
8
#include "
JetRec/JetRecAlg.h
"
9
#include "
JetInterface/IJetExecuteTool.h
"
10
#include "
xAODJet/JetAuxContainer.h
"
11
12
#include "
AsgDataHandles/WriteDecorHandle.h
"
13
14
#if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
15
#include "
AthenaMonitoringKernel/Monitored.h
"
16
#include "GaudiKernel/SystemOfUnits.h"
17
#endif
18
19
using
std::string;
20
21
//**********************************************************************
22
23
StatusCode
JetRecAlg::initialize
() {
24
25
ATH_CHECK
(
m_output
.initialize());
26
27
if
(!
m_parentKey
.empty())
m_parentKey
=
m_output
.key() +
"."
+
m_parentKey
.key();
28
ATH_CHECK
(
m_parentKey
.initialize(!
m_parentKey
.empty()));
29
30
ATH_CHECK
(
m_jetprovider
.retrieve());
31
// Some providers (e.g. copy) need the output WriteHandle
32
// to be provided during initialisation
33
ATH_CHECK
(
m_jetprovider
->initWithOutput(
m_output
));
34
35
ATH_MSG_INFO
(
"Initialized IJetProvider : "
<<
m_jetprovider
->name());
36
37
ATH_MSG_DEBUG
(
"Initialize .... List of modifiers: "
);
38
ATH_CHECK
(
m_modifiers
.retrieve());
39
for
(
const
ToolHandle<IJetModifier>& t :
m_modifiers
){
40
ATH_MSG_DEBUG
(
" --> : "
<< t->name());
41
}
42
43
ATH_CHECK
(
m_output
.initialize());
44
45
#if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
46
if
(!
m_monTool
.empty())
ATH_CHECK
(
m_monTool
.retrieve());
47
#endif
48
49
return
StatusCode::SUCCESS;
50
}
51
52
//**********************************************************************
53
54
#if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
55
#define DOMONITORING
56
#endif
57
58
StatusCode
JetRecAlg::execute
(
const
EventContext& ctx)
const
{
59
// Get JetContainer by running fastjet, grooming or copying existing jets...
60
// Pass in the WriteHandle so that the provider can do the record, and we
61
// needn't know the type of the jet aux container
62
// We can subsequently access the jets from the handle and don't have to
63
// worry about memory management.
64
65
#ifdef DOMONITORING
66
auto
t_total =
Monitored::Timer<std::chrono::milliseconds>
(
"TIME_jetreco"
);
67
auto
t_jpv =
Monitored::Timer<std::chrono::milliseconds>
(
"TIME_jetprovider"
);
68
auto
t_mod =
Monitored::Timer<std::chrono::milliseconds>
(
"TIME_jetmod"
);
69
#endif
70
71
SG::WriteHandle<xAOD::JetContainer>
jetContHandle(
m_output
,ctx);
72
static
const
SG::AuxElement::ConstAccessor<ElementLink<xAOD::JetContainer> > parentELacc(
"Parent_TEMP"
);
73
74
// Define a scope to ease monitoring of the JetProvider action
75
{
76
#ifdef DOMONITORING
77
Monitored::ScopedTimer
time_provider(t_jpv);
78
#endif
79
ATH_CHECK
(
m_jetprovider
->getAndRecordJets(jetContHandle) );
80
ATH_MSG_DEBUG
(
"Created jet container of size "
<< (*jetContHandle).size() <<
" | writing to "
<<
m_output
.key() );
81
82
if
(!
m_parentKey
.empty()){
83
SG::WriteDecorHandle<xAOD::JetContainer, ElementLink<xAOD::JetContainer>
> parentDecorHandle(
m_parentKey
,ctx);
84
for
(
xAOD::Jet
*
jet
: *jetContHandle)
85
parentDecorHandle(*
jet
) = parentELacc(*
jet
);
86
}
87
}
88
89
// Define a scope to ease monitoring of the JetModifier action
90
{
91
#ifdef DOMONITORING
92
Monitored::ScopedTimer
time_modifiers(t_mod);
93
#endif
94
ATH_MSG_DEBUG
(
"Applying jet modifiers to "
<<
m_output
.key());
95
// Calculate moments, calibrate, sort, filter... -----------
96
for
(
const
ToolHandle<IJetModifier>& t :
m_modifiers
){
97
ATH_MSG_DEBUG
(
"Running "
<< t.name());
98
ATH_CHECK
(t->modify(*jetContHandle));
99
}
100
}
101
102
#ifdef DOMONITORING
103
// monitor jet multiplicity and basic jet kinematics
104
auto
njets =
Monitored::Scalar<int>
(
"JET_n"
);
105
njets = jetContHandle->size();
106
constexpr
float
invGeV
= 1./Gaudi::Units::GeV;
107
auto
pt =
Monitored::Collection
(
"JET_pt"
, *jetContHandle, [c=
invGeV
](
const
xAOD::Jet
*
jet
) {
return
jet
->pt()*c; });
108
auto
et
=
Monitored::Collection
(
"JET_et"
, *jetContHandle, [c=
invGeV
](
const
xAOD::Jet
*
jet
) {
return
jet
->p4().Et()*c; });
109
auto
mass =
Monitored::Collection
(
"JET_m"
, *jetContHandle, [c=
invGeV
](
const
xAOD::Jet
*
jet
) {
return
jet
->m()*c; });
110
auto
eta
=
Monitored::Collection
(
"JET_eta"
, *jetContHandle, [](
const
xAOD::Jet
*
jet
) {
return
jet
->eta(); });
111
auto
phi
=
Monitored::Collection
(
"JET_phi"
, *jetContHandle, [](
const
xAOD::Jet
*
jet
) {
return
jet
->phi(); });
112
113
auto
mon =
Monitored::Group
(
m_monTool
,t_total,t_jpv,t_mod,njets,pt,
et
,mass,
eta
,
phi
);
114
#endif
115
116
117
return
StatusCode::SUCCESS;
118
119
}
120
121
//**********************************************************************
122
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
IJetExecuteTool.h
JetAuxContainer.h
JetRecAlg.h
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
invGeV
constexpr float invGeV
Definition
PFTrackSelector.cxx:11
JetRecAlg::m_parentKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_parentKey
Definition
JetRecAlg.h:50
JetRecAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition
JetRecAlg.cxx:23
JetRecAlg::m_modifiers
ToolHandleArray< IJetModifier > m_modifiers
Definition
JetRecAlg.h:48
JetRecAlg::m_output
SG::WriteHandleKey< xAOD::JetContainer > m_output
Definition
JetRecAlg.h:49
JetRecAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
JetRecAlg.cxx:58
JetRecAlg::m_jetprovider
ToolHandle< IJetProvider > m_jetprovider
Athena configured tools.
Definition
JetRecAlg.h:47
JetRecAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition
JetRecAlg.h:52
Monitored::Group
Group of local monitoring quantities and retain correlation when filling histograms
Definition
MonitoredGroup.h:53
Monitored::Scalar
Declare a monitored scalar variable.
Definition
MonitoredScalar.h:34
Monitored::ScopedTimer
Helper class to create a scoped timer.
Definition
MonitoredTimer.h:95
Monitored::Timer
A monitored timer.
Definition
MonitoredTimer.h:32
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition
MonitoredCollection.h:38
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
et
Extra patterns decribing particle interation process.
Generated on
for ATLAS Offline Software by
1.17.0