ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleJetTools
Root
JetParticleAssociation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// author: cpollard@cern.ch
6
7
#include "
ParticleJetTools/JetParticleAssociation.h
"
8
#include "
AsgDataHandles/WriteDecorHandle.h
"
9
#include "
AthContainers/ConstDataVector.h
"
10
11
JetParticleAssociation::JetParticleAssociation
(
const
std::string& name)
12
:
asg
::
AsgTool
(name) {
13
}
14
15
StatusCode
JetParticleAssociation::initialize
() {
16
17
ATH_MSG_DEBUG
(
"Initializing JetParticleAssociator"
);
18
m_decKey
=
m_jetContainerName
+
"."
+
m_decKey
.key();
19
20
ATH_CHECK
(
m_decKey
.initialize());
21
ATH_CHECK
(
m_particleKey
.initialize());
22
23
ATH_MSG_DEBUG
(
"Minimum pt threshold: "
<<
m_ptMinimum
);
24
if
(
m_ptMinimum
> 0.0) {
25
if
(!
m_passPtKey
.key().empty()) {
26
m_passPtKey
=
m_jetContainerName
+
"."
+
m_passPtKey
.key();
27
ATH_MSG_DEBUG
(
"Pass Key Decorator: "
<<
m_passPtKey
);
28
}
29
}
30
31
ATH_CHECK
(
m_passPtKey
.initialize(!
m_passPtKey
.key().empty()));
32
33
return
StatusCode::SUCCESS;
34
}
35
36
StatusCode
JetParticleAssociation::decorate
(
const
xAOD::JetContainer
& jets)
const
{
37
SG::WriteDecorHandle<xAOD::JetContainer, std::vector<ElementLink<xAOD::IParticleContainer>
> > decHandle(
m_decKey
);
38
39
const
std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >* matches;
40
41
SG::ReadHandle<xAOD::IParticleContainer>
parts(
m_particleKey
);
42
if
( !parts.isValid() ) {
43
ATH_MSG_WARNING
(
"Couldn't retrieve particles with key: "
<<
m_particleKey
.key() );
44
return
StatusCode::FAILURE;
45
}
46
47
ConstDataVector<xAOD::JetContainer>
viewJets(
SG::VIEW_ELEMENTS
);
48
std::vector<unsigned int> skipped;
49
for
(
unsigned
int
i = 0; i < jets.size(); i++) {
50
const
xAOD::Jet
*
jet
= jets.at(i);
51
if
(
jet
->pt() >
m_ptMinimum
) {
52
ATH_MSG_VERBOSE
(
"Adding jet, pt = "
<<
jet
->pt());
53
viewJets.
push_back
(
jet
);
54
}
else
{
55
ATH_MSG_VERBOSE
(
"Skipping jet, pt = "
<<
jet
->pt());
56
skipped.push_back(i);
57
}
58
}
59
60
matches =
match
(*viewJets.
asDataVector
(), *parts);
61
62
ATH_MSG_DEBUG
(
"About to decorate jets with"
<<
m_decKey
);
63
64
for
(
unsigned
int
iJet = 0; iJet < viewJets.size(); iJet++) {
65
decHandle(*(viewJets.
at
(iJet))) = (*matches)[iJet];
66
}
67
for
(
unsigned
int
iJet: skipped) {
68
decHandle(*jets.at(iJet)) = {};
69
}
70
71
if
(!
m_passPtKey
.empty()) {
72
SG::WriteDecorHandle<xAOD::JetContainer, char>
passHandle(
m_passPtKey
);
73
for
(
const
xAOD::Jet
*
jet
: viewJets) {
74
passHandle(*
jet
) = 1;
75
}
76
for
(
unsigned
int
iJet: skipped) {
77
passHandle(*jets.at(iJet)) = 0;
78
}
79
}
80
81
delete
matches;
82
83
return
StatusCode::SUCCESS;
84
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
JetParticleAssociation.h
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::at
ElementProxy at(size_type n)
Access an element, as an lvalue.
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
JetParticleAssociation::m_decKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decKey
Definition
JetParticleAssociation.h:43
JetParticleAssociation::decorate
virtual StatusCode decorate(const xAOD::JetContainer &jets) const override
Decorate a jet collection without otherwise modifying it.
Definition
JetParticleAssociation.cxx:36
JetParticleAssociation::m_particleKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_particleKey
Definition
JetParticleAssociation.h:42
JetParticleAssociation::m_jetContainerName
Gaudi::Property< std::string > m_jetContainerName
Definition
JetParticleAssociation.h:40
JetParticleAssociation::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JetParticleAssociation.cxx:15
JetParticleAssociation::m_ptMinimum
Gaudi::Property< float > m_ptMinimum
Definition
JetParticleAssociation.h:41
JetParticleAssociation::m_passPtKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_passPtKey
Definition
JetParticleAssociation.h:44
JetParticleAssociation::match
virtual const std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > * match(const xAOD::JetContainer &, const xAOD::IParticleContainer &) const =0
JetParticleAssociation::JetParticleAssociation
JetParticleAssociation(const std::string &name)
Definition
JetParticleAssociation.cxx:11
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
asg
Definition
DataHandleTestTool.h:28
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
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0