ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
JetTagDerivationUtils
src
JetLinkMatcherAlg.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
#include "
JetLinkMatcherAlg.h
"
6
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
7
#include "
xAODJet/JetContainer.h
"
8
#include <vector>
9
#include <memory>
10
11
namespace
ftag
{
12
13
JetLinkMatcherAlg::JetLinkMatcherAlg
(
const
std::string& name,
14
ISvcLocator* pSvcLocator):
15
AthReentrantAlgorithm
(name, pSvcLocator)
16
{
17
declareProperty
(
"floatsToCopy"
,
m_floats
.toCopy);
18
declareProperty
(
"doublesToCopy"
,
m_doubles
.toCopy);
19
declareProperty
(
"intsToCopy"
,
m_ints
.toCopy);
20
declareProperty
(
"uintsToCopy"
,
m_uints
.toCopy);
21
declareProperty
(
"ulongsToCopy"
,
m_ulongs
.toCopy);
22
declareProperty
(
"charsToCopy"
,
m_chars
.toCopy);
23
declareProperty
(
"charVectorsToCopy"
,
m_charVectors
.toCopy);
24
declareProperty
(
"iparticlesToCopy"
,
m_iparticles
.toCopy);
25
declareProperty
(
"trackLinksToCopy"
,
m_trackLinks
.toCopy);
26
}
27
28
StatusCode
JetLinkMatcherAlg::initialize
() {
29
std::vector<std::string> sources;
30
for
(
const
auto
& key:
m_sourceJets
) {
31
sources.emplace_back(key.key());
32
}
33
std::string target =
m_targetJet
.key();
34
ATH_CHECK
(
m_floats
.initialize(
this
, sources, target));
35
ATH_CHECK
(
m_doubles
.initialize(
this
, sources, target));
36
ATH_CHECK
(
m_ints
.initialize(
this
, sources, target));
37
ATH_CHECK
(
m_uints
.initialize(
this
, sources, target));
38
ATH_CHECK
(
m_ulongs
.initialize(
this
, sources, target));
39
ATH_CHECK
(
m_chars
.initialize(
this
, sources, target));
40
ATH_CHECK
(
m_charVectors
.initialize(
this
, sources, target));
41
ATH_CHECK
(
m_iparticles
.initialize(
this
, sources, target));
42
ATH_CHECK
(
m_trackLinks
.initialize(
this
, sources, target));
43
ATH_CHECK
(
m_targetJet
.initialize());
44
ATH_CHECK
(
m_sourceJets
.initialize());
45
ATH_CHECK
(
m_link
.initialize());
46
if
(!
m_matchDecorator
.empty()) {
47
ATH_CHECK
(
m_matchDecorator
.initialize());
48
}
49
return
StatusCode::SUCCESS;
50
}
51
52
StatusCode
JetLinkMatcherAlg::execute
(
const
EventContext& cxt)
const
{
53
SG::ReadHandle<JC>
targetJetGet(
m_targetJet
, cxt);
54
SG::ReadDecorHandle<JC, ElementLink<JC>
> link(
m_link
, cxt);
55
std::optional<SG::WriteDecorHandle<JC,char>> matchDecorator;
56
if
(!
m_matchDecorator
.empty()) {
57
matchDecorator.emplace(
m_matchDecorator
, cxt);
58
}
59
std::vector<MatchedPair<JC>> matches;
60
for
(
const
xAOD::Jet
* target: *targetJetGet) {
61
const
ElementLink<JC>
& sourceLink = link(*target);
62
const
xAOD::Jet
* source = sourceLink.
isValid
() ?
63
*sourceLink :
nullptr
;
64
if
(!matchDecorator && !source) {
65
throw
std::runtime_error(
"invalid link to source"
);
66
}
67
if
(source) {
68
if
(matchDecorator) matchDecorator.value()(*target) = 1;
69
matches.push_back({source, target});
70
}
else
{
71
matchDecorator.value()(*target) = 0;
72
matches.push_back({
nullptr
, target});
73
}
74
}
75
m_floats
.copy(matches, cxt);
76
m_doubles
.copy(matches, cxt);
77
m_ints
.copy(matches, cxt);
78
m_uints
.copy(matches, cxt);
79
m_ulongs
.copy(matches, cxt);
80
m_chars
.copy(matches, cxt);
81
m_charVectors
.copy(matches, cxt);
82
m_iparticles
.copy(matches, cxt);
83
m_trackLinks
.copy(matches, cxt);
84
85
return
StatusCode::SUCCESS;
86
}
87
StatusCode
JetLinkMatcherAlg::finalize
() {
88
return
StatusCode::SUCCESS;
89
}
90
91
}
// end namespace ftag
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AthMsgStreamMacros.h
JetContainer.h
JetLinkMatcherAlg.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::isValid
bool isValid() const
Check if the element can be found.
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
ftag::JetLinkMatcherAlg::m_sourceJets
SG::ReadHandleKeyArray< JC > m_sourceJets
Definition
JetLinkMatcherAlg.h:43
ftag::JetLinkMatcherAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition
JetLinkMatcherAlg.cxx:52
ftag::JetLinkMatcherAlg::m_ints
VariableMule< int, JC > m_ints
Definition
JetLinkMatcherAlg.h:33
ftag::JetLinkMatcherAlg::initialize
virtual StatusCode initialize() override
Definition
JetLinkMatcherAlg.cxx:28
ftag::JetLinkMatcherAlg::m_doubles
VariableMule< double, JC > m_doubles
Definition
JetLinkMatcherAlg.h:32
ftag::JetLinkMatcherAlg::m_floats
VariableMule< float, JC > m_floats
Definition
JetLinkMatcherAlg.h:31
ftag::JetLinkMatcherAlg::m_link
SG::ReadDecorHandleKey< JC > m_link
Definition
JetLinkMatcherAlg.h:46
ftag::JetLinkMatcherAlg::m_chars
VariableMule< char, JC > m_chars
Definition
JetLinkMatcherAlg.h:36
ftag::JetLinkMatcherAlg::m_matchDecorator
SG::WriteDecorHandleKey< JC > m_matchDecorator
Definition
JetLinkMatcherAlg.h:49
ftag::JetLinkMatcherAlg::m_trackLinks
VariableMule< TPLV, JC > m_trackLinks
Definition
JetLinkMatcherAlg.h:39
ftag::JetLinkMatcherAlg::m_targetJet
SG::ReadHandleKey< JC > m_targetJet
Definition
JetLinkMatcherAlg.h:40
ftag::JetLinkMatcherAlg::m_uints
VariableMule< uint, JC > m_uints
Definition
JetLinkMatcherAlg.h:34
ftag::JetLinkMatcherAlg::m_ulongs
VariableMule< ulong, JC > m_ulongs
Definition
JetLinkMatcherAlg.h:35
ftag::JetLinkMatcherAlg::finalize
virtual StatusCode finalize() override
Definition
JetLinkMatcherAlg.cxx:87
ftag::JetLinkMatcherAlg::m_charVectors
VariableMule< std::vector< char >, JC > m_charVectors
Definition
JetLinkMatcherAlg.h:37
ftag::JetLinkMatcherAlg::m_iparticles
VariableMule< IPLV, JC > m_iparticles
Definition
JetLinkMatcherAlg.h:38
ftag::JetLinkMatcherAlg::JetLinkMatcherAlg
JetLinkMatcherAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
JetLinkMatcherAlg.cxx:13
ftag
Definition
FlowSelectorAlg.cxx:16
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