ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetRec
src
JetViewAlg.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
// JetViewAlg.cxx
6
7
#if !defined(XAOD_STANDALONE)
8
// We do not compile JetViewAlg yet in AnalysisBase : need support for ShallowCopyDecorDeps
9
10
#include <memory>
11
#include "
JetRec/JetViewAlg.h
"
12
13
//**********************************************************************
14
15
// Called before event loop
16
StatusCode
JetViewAlg::initialize
() {
17
18
// Initialise HandleKeys so that the scheduler is aware of
19
// data dependencies & products
20
if
(
m_input
.key().empty() ||
m_output
.key().empty()) {
21
ATH_MSG_ERROR
(
"Input/output key(s) is/are blank!"
);
22
return
StatusCode::FAILURE;
23
}
24
25
ATH_CHECK
(
m_input
.initialize());
26
ATH_CHECK
(
m_output
.initialize());
27
ATH_CHECK
(
m_decorDeps
.initialize(
m_input
,
m_output
) );
28
29
ATH_MSG_DEBUG
(
"Will select jets from "
<<
m_input
.key()
30
<<
" and write them to "
<<
m_output
.key());
31
ATH_MSG_DEBUG
(
"Selection criteria are: \n"
32
<<
" pT > "
<<
m_ptmin
<<
" MeV"
33
<<
" |eta| < "
<<
m_absetamax
34
);
35
36
return
StatusCode::SUCCESS;
37
}
38
39
//**********************************************************************
40
41
bool
JetViewAlg::selected
(
const
xAOD::Jet
&
jet
)
const
{
42
43
if
(
jet
.pt() <
m_ptmin
) {
return
false
;}
44
if
(std::abs(
jet
.eta()) >
m_absetamax
) {
return
false
;}
45
46
return
true
;
47
}
48
49
//**********************************************************************
50
51
StatusCode
JetViewAlg::execute
(
const
EventContext& ctx)
const
{
52
53
SG::ReadHandle<xAOD::JetContainer>
inputHandle(
m_input
,ctx);
54
55
// Need to place jets into a CDV because we can't put const objects in a DataVector
56
auto
selected_jets = std::make_unique<ConstDataVector<xAOD::JetContainer> >(
SG::VIEW_ELEMENTS
);
57
for
(
const
xAOD::Jet
*
jet
: *inputHandle) {
58
ATH_MSG_VERBOSE
(
"Jet "
<<
jet
->index() << std::setprecision(3)
59
<<
" with pt "
<<
jet
->pt()
60
<<
" eta "
<<
jet
->eta()
61
);
62
if
(
selected
(*
jet
) ) {
63
selected_jets->push_back(
jet
);
64
ATH_MSG_VERBOSE
(
" Passed selection"
);
65
}
else
{
66
ATH_MSG_VERBOSE
(
" Failed selection"
);
67
}
68
}
69
ATH_MSG_DEBUG
(
"Selected "
<< selected_jets->size() <<
" from input container of size "
<< inputHandle->size() );
70
71
// To use ShallowCopyDecorDeps, the input and output handle types have to be the same, i.e. JetContainer
72
// So create a new unique_ptr here using the pointer to the CDV converted to DV
73
std::unique_ptr<const xAOD::JetContainer> selected_jets_jetc(selected_jets.release()->asDataVector());
74
75
// Write out JetContainer and JetAuxContainer
76
SG::WriteHandle<xAOD::JetContainer>
jetContHandle(
m_output
,ctx);
77
// Can't record with const input ptr, hence put
78
if
( jetContHandle.
put
( std::move(selected_jets_jetc) ) ==
nullptr
) {
79
ATH_MSG_ERROR
(
"Failed to record "
<<
m_input
.key() <<
" as const xAOD::JetContainer!"
);
80
return
StatusCode::FAILURE;
81
}
82
ATH_CHECK
(
m_decorDeps
.linkDecors (
m_input
,ctx) );
83
84
return
StatusCode::SUCCESS;
85
}
86
87
//**********************************************************************
88
#endif
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
JetViewAlg.h
JetViewAlg::m_input
SG::ReadHandleKey< xAOD::JetContainer > m_input
Definition
JetViewAlg.h:53
JetViewAlg::m_output
SG::WriteHandleKey< xAOD::JetContainer > m_output
Definition
JetViewAlg.h:54
JetViewAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition
JetViewAlg.cxx:16
JetViewAlg::selected
bool selected(const xAOD::Jet &) const
Method to select jets.
Definition
JetViewAlg.cxx:41
JetViewAlg::m_absetamax
Gaudi::Property< float > m_absetamax
Definition
JetViewAlg.h:51
JetViewAlg::execute
StatusCode execute(const EventContext &) const override
Definition
JetViewAlg.cxx:51
JetViewAlg::m_ptmin
Gaudi::Property< float > m_ptmin
Definition
JetViewAlg.h:50
JetViewAlg::m_decorDeps
SG::ShallowCopyDecorDeps< xAOD::JetContainer > m_decorDeps
Definition
JetViewAlg.h:58
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
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
Generated on
for ATLAS Offline Software by
1.17.0