ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
JetTagTools
src
CTTDecorCheckInTool.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 <cassert>
6
#include "
TestTools/FLOATassert.h
"
7
8
#include "
JetTagTools/CTTDecorCheckInTool.h
"
9
//
10
//-------------------------------------------------
11
12
//Constructor--------------------------------------------------------------
13
CTTDecorCheckInTool::CTTDecorCheckInTool
(
const
std::string& name,
14
ISvcLocator* pSvcLocator):
15
AthAlgorithm
( name, pSvcLocator ),
16
m_classifiedTrackTagger
(
"Analysis::ClassifiedTrackTaggerTool"
,this),
17
m_jetCollection
(
"AntiKt4EMPFlowJets"
)
18
{
19
declareProperty
(
"ClassifiedTrackTaggerTool"
,
m_classifiedTrackTagger
);
20
declareProperty
(
"JetCollection"
,
m_jetCollection
);
21
}
22
23
//Initialize---------------------------------------------------------------
24
StatusCode
CTTDecorCheckInTool::initialize
(){
25
26
ATH_CHECK
(
m_particlesKey
.initialize() );
27
ATH_CHECK
(
m_verticesKey
.initialize() );
28
ATH_CHECK
(
m_jetsKey
.initialize() );
29
30
if
(
m_jetCollection
.empty()){
31
ATH_MSG_FATAL
(
"No JetCollection specified! "
);
32
}
else
{
33
m_jetReadDecorKey
=
m_jetCollection
+
".CTTScore"
;
34
ATH_CHECK
(
m_jetReadDecorKey
.initialize());
35
}
36
37
//-------
38
//check that the ClassifiedTrackTaggerTool can be accessed
39
if
(
m_classifiedTrackTagger
.retrieve().isFailure()) {
40
ATH_MSG_DEBUG
(
"Could not find Analysis::ClassifiedTrackTaggerTool"
);
41
return
StatusCode::SUCCESS;
42
}
else
{
43
ATH_MSG_DEBUG
(
"Analysis::ClassifiedTrackTaggerTool found"
);
44
}
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode
CTTDecorCheckInTool::execute
(
const
EventContext& ctx)
50
{
51
ATH_MSG_DEBUG
(
"Executing..."
);
52
53
SG::ReadDecorHandle< xAOD::JetContainer, float >
jetReadDecorHandle (
m_jetReadDecorKey
, ctx);
54
55
// Retrieve the track particles:
56
SG::ReadHandle<xAOD::TrackParticleContainer>
trackTES(
m_particlesKey
, ctx);
57
if
( !trackTES.
isValid
() ) {
58
ATH_MSG_WARNING
(
"No TrackParticle container found in TDS"
);
59
return
StatusCode::SUCCESS;
60
}
61
ATH_MSG_DEBUG
(
"TrackParticleContainer successfully retrieved"
);
62
63
SG::ReadHandle<xAOD::VertexContainer>
pvTES(
m_verticesKey
, ctx);
64
if
( !pvTES.
isValid
() ) {
65
ATH_MSG_WARNING
(
"No Primary Vertices container found in TDS"
);
66
return
StatusCode::SUCCESS;
67
}
68
ATH_MSG_DEBUG
(
"Primary Vertices container successfully retrieved"
);
69
const
xAOD::Vertex
*primVertex=*(pvTES->begin());
70
71
//==========================================================================
72
SG::ReadHandle<xAOD::JetContainer>
jetTES(
m_jetsKey
, ctx);
73
if
( !jetTES.
isValid
() ) {
74
ATH_MSG_WARNING
(
"No AntiKt4EMPflow jet container found in TDS"
);
75
return
StatusCode::SUCCESS;
76
}
77
ATH_MSG_DEBUG
(
"AntiKt4EMPflow jet container successfully retrieved"
);
78
79
//save all TrackParticles in an std::vector (needed as input to the CTT tool)
80
std::vector<const xAOD::TrackParticle*> trkparticles(0);
81
for
(
const
auto
trkPart : *trackTES){
82
trkparticles.emplace_back(trkPart);
83
}
84
85
//first decorate all jets with the CTT method
86
m_classifiedTrackTagger
->decorateJets(ctx, trkparticles, *primVertex, *jetTES);
87
88
for
(
const
auto
curjet : *jetTES){
89
ATH_MSG_DEBUG
(
" Jet pt: "
<< curjet->pt()<<
" eta: "
<<curjet->eta()<<
" phi: "
<< curjet->phi() );
90
float
CTTScore =
m_classifiedTrackTagger
->bJetWgts(ctx, trkparticles, *primVertex, curjet->p4());
91
ATH_MSG_DEBUG
(
"Retrieved CTT score from CTT tool: "
<< CTTScore);
92
ATH_MSG_DEBUG
(
"CTT score of decorated xAOD::Jet : "
<< jetReadDecorHandle(*curjet));
93
assert(
Athena_test::isEqual
(CTTScore,jetReadDecorHandle(*curjet)));
94
}
95
96
return
StatusCode::SUCCESS;
97
}
98
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CTTDecorCheckInTool.h
FLOATassert.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
CTTDecorCheckInTool::m_classifiedTrackTagger
ToolHandle< Analysis::IClassifiedTrackTaggerTool > m_classifiedTrackTagger
Definition
CTTDecorCheckInTool.h:47
CTTDecorCheckInTool::m_jetReadDecorKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_jetReadDecorKey
Definition
CTTDecorCheckInTool.h:55
CTTDecorCheckInTool::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
CTTDecorCheckInTool.cxx:49
CTTDecorCheckInTool::initialize
virtual StatusCode initialize() override
Definition
CTTDecorCheckInTool.cxx:24
CTTDecorCheckInTool::m_jetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
Definition
CTTDecorCheckInTool.h:51
CTTDecorCheckInTool::m_jetCollection
std::string m_jetCollection
Definition
CTTDecorCheckInTool.h:48
CTTDecorCheckInTool::CTTDecorCheckInTool
CTTDecorCheckInTool(const std::string &type, ISvcLocator *pSvcLocator)
Definition
CTTDecorCheckInTool.cxx:13
CTTDecorCheckInTool::m_particlesKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_particlesKey
Definition
CTTDecorCheckInTool.h:52
CTTDecorCheckInTool::m_verticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_verticesKey
Definition
CTTDecorCheckInTool.h:53
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Athena_test::isEqual
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition
FLOATassert.h:26
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Generated on
for ATLAS Offline Software by
1.17.0