ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
src
TauSeedJetLabelCopyAlg.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
#include "
TauSeedJetLabelCopyAlg.h
"
6
7
#include "
StoreGate/ReadHandle.h
"
8
#include "
StoreGate/WriteDecorHandle.h
"
9
10
#include <algorithm>
11
#include <limits>
12
13
namespace
{
14
15
std::vector<std::size_t> sortedIndices(
const
std::vector<
ElementLink<xAOD::IParticleContainer>
>& links) {
16
std::vector<std::size_t>
indices
;
17
indices
.reserve(
links
.size());
18
for
(
const
ElementLink<xAOD::IParticleContainer>
& link : links)
indices
.push_back(
link
.index());
19
std::sort
(
indices
.begin(),
indices
.end());
20
return
indices
;
21
}
22
23
}
24
25
namespace
ParticleJetTools
{
26
27
TauSeedJetLabelCopyAlg::TauSeedJetLabelCopyAlg
(
const
std::string& name, ISvcLocator* loc)
28
:
AthReentrantAlgorithm
(name, loc) {}
29
30
StatusCode
TauSeedJetLabelCopyAlg::initialize
() {
31
ATH_CHECK
(
m_tauKey
.initialize());
32
ATH_CHECK
(
m_jetKey
.initialize());
33
34
const
std::string tauPrefix =
m_tauKey
.key() +
"."
;
35
for
(
const
std::string& name :
m_intNames
) {
36
m_intAccs
.emplace_back(name);
37
m_intDecorKeys
.emplace_back(tauPrefix + name);
38
}
39
for
(
const
std::string& name :
m_floatNames
) {
40
m_floatAccs
.emplace_back(name);
41
m_floatDecorKeys
.emplace_back(tauPrefix + name);
42
}
43
ATH_CHECK
(
m_intDecorKeys
.initialize());
44
ATH_CHECK
(
m_floatDecorKeys
.initialize());
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
TauSeedJetLabelCopyAlg::execute
(
const
EventContext& ctx)
const
{
49
SG::ReadHandle<xAOD::TauJetContainer>
taus
(
m_tauKey
, ctx);
50
SG::ReadHandle<xAOD::JetContainer>
seedJets(
m_jetKey
, ctx);
51
ATH_CHECK
(
taus
.isValid());
52
ATH_CHECK
(seedJets.
isValid
());
53
if
(!
m_matchConstituents
&& seedJets->size() !=
taus
->size()) {
54
ATH_MSG_ERROR
(
taus
->size() <<
" taus but "
<< seedJets->size() <<
" seed jets to match by index"
);
55
return
StatusCode::FAILURE;
56
}
57
58
std::vector<std::vector<std::size_t>> jetConstituents;
59
if
(
m_matchConstituents
) {
60
jetConstituents.reserve(seedJets->size());
61
for
(
const
xAOD::Jet
*
jet
: *seedJets) jetConstituents.push_back(sortedIndices(
jet
->constituentLinks()));
62
}
63
64
auto
intHandles =
m_intDecorKeys
.makeHandles(ctx);
65
auto
floatHandles =
m_floatDecorKeys
.makeHandles(ctx);
66
67
for
(std::size_t
index
= 0;
index
<
taus
->size(); ++
index
) {
68
const
xAOD::TauJet
* tau =
taus
->at(
index
);
69
const
xAOD::Jet
*
jet
=
nullptr
;
70
if
(
m_matchConstituents
) {
71
const
auto
match
= std::find(jetConstituents.begin(), jetConstituents.end(), sortedIndices(tau->clusterLinks()));
72
if
(
match
!= jetConstituents.end())
jet
= seedJets->at(
match
- jetConstituents.begin());
73
}
else
{
74
jet
= seedJets->at(
index
);
75
}
76
for
(std::size_t i = 0; i < intHandles.size(); ++i) {
77
intHandles.at(i)(*tau) =
jet
?
m_intAccs
.at(i)(*jet) : -1;
78
}
79
for
(std::size_t i = 0; i < floatHandles.size(); ++i) {
80
floatHandles.at(i)(*tau) =
jet
?
m_floatAccs
.at(i)(*jet) : std::numeric_limits<float>::quiet_NaN();
81
}
82
}
83
84
return
StatusCode::SUCCESS;
85
}
86
87
}
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:47
indices
std::vector< std::vector< int64_t > > indices
Definition
HyPERTopoReco.h:16
taus
static Double_t taus
Definition
LArPhysWaveHECTool.cxx:37
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
TauSeedJetLabelCopyAlg.h
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
ParticleJetTools::TauSeedJetLabelCopyAlg::m_intDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::TauJetContainer, int > m_intDecorKeys
Definition
TauSeedJetLabelCopyAlg.h:44
ParticleJetTools::TauSeedJetLabelCopyAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TauSeedJetLabelCopyAlg.cxx:48
ParticleJetTools::TauSeedJetLabelCopyAlg::m_tauKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauKey
Definition
TauSeedJetLabelCopyAlg.h:33
ParticleJetTools::TauSeedJetLabelCopyAlg::m_floatAccs
std::vector< SG::ConstAccessor< float > > m_floatAccs
Definition
TauSeedJetLabelCopyAlg.h:50
ParticleJetTools::TauSeedJetLabelCopyAlg::m_jetKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
Definition
TauSeedJetLabelCopyAlg.h:35
ParticleJetTools::TauSeedJetLabelCopyAlg::m_intAccs
std::vector< SG::ConstAccessor< int > > m_intAccs
Definition
TauSeedJetLabelCopyAlg.h:49
ParticleJetTools::TauSeedJetLabelCopyAlg::initialize
virtual StatusCode initialize() override
Definition
TauSeedJetLabelCopyAlg.cxx:30
ParticleJetTools::TauSeedJetLabelCopyAlg::TauSeedJetLabelCopyAlg
TauSeedJetLabelCopyAlg(const std::string &name, ISvcLocator *loc)
Definition
TauSeedJetLabelCopyAlg.cxx:27
ParticleJetTools::TauSeedJetLabelCopyAlg::m_floatNames
Gaudi::Property< std::vector< std::string > > m_floatNames
Definition
TauSeedJetLabelCopyAlg.h:41
ParticleJetTools::TauSeedJetLabelCopyAlg::m_matchConstituents
Gaudi::Property< bool > m_matchConstituents
Definition
TauSeedJetLabelCopyAlg.h:37
ParticleJetTools::TauSeedJetLabelCopyAlg::m_intNames
Gaudi::Property< std::vector< std::string > > m_intNames
Definition
TauSeedJetLabelCopyAlg.h:39
ParticleJetTools::TauSeedJetLabelCopyAlg::m_floatDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::TauJetContainer, float > m_floatDecorKeys
Definition
TauSeedJetLabelCopyAlg.h:46
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition
hcg.cxx:359
DMTest::links
links
Definition
CLinks_v1.cxx:22
ParticleJetTools
Definition
FatVertex.h:15
SG::link
pointer & link(pointer p) const
Return a reference to the link for an element.
index
Definition
index.py:1
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::TauJet
TauJet_v3 TauJet
Definition of the current "tau version".
Definition
TauJet.h:17
Generated on
for ATLAS Offline Software by
1.17.0