ATLAS Offline Software
Loading...
Searching...
No Matches
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>
7
9//
10//-------------------------------------------------
11
12//Constructor--------------------------------------------------------------
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---------------------------------------------------------------
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 {
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
50{
51 ATH_MSG_DEBUG( "Executing..." );
52
53 const EventContext& ctx = Gaudi::Hive::currentContext();
54
56
57 // Retrieve the track particles:
59 if ( !trackTES.isValid() ) {
60 ATH_MSG_WARNING( "No TrackParticle container found in TDS" );
61 return StatusCode::SUCCESS;
62 }
63 ATH_MSG_DEBUG( "TrackParticleContainer successfully retrieved" );
64
66 if ( !pvTES.isValid() ) {
67 ATH_MSG_WARNING( "No Primary Vertices container found in TDS" );
68 return StatusCode::SUCCESS;
69 }
70 ATH_MSG_DEBUG( "Primary Vertices container successfully retrieved" );
71 const xAOD::Vertex *primVertex=*(pvTES->begin());
72
73 //==========================================================================
75 if ( !jetTES.isValid() ) {
76 ATH_MSG_WARNING( "No AntiKt4EMPflow jet container found in TDS" );
77 return StatusCode::SUCCESS;
78 }
79 ATH_MSG_DEBUG( "AntiKt4EMPflow jet container successfully retrieved" );
80
81 //save all TrackParticles in an std::vector (needed as input to the CTT tool)
82 std::vector<const xAOD::TrackParticle*> trkparticles(0);
83 for(const auto trkPart : *trackTES){
84 trkparticles.emplace_back(trkPart);
85 }
86
87 //first decorate all jets with the CTT method
88 m_classifiedTrackTagger->decorateJets(ctx, trkparticles, *primVertex, *jetTES);
89
90 for(const auto curjet : *jetTES){
91 ATH_MSG_DEBUG( " Jet pt: " << curjet->pt()<<" eta: "<<curjet->eta()<<" phi: "<< curjet->phi() );
92 float CTTScore = m_classifiedTrackTagger->bJetWgts(ctx, trkparticles, *primVertex, curjet->p4());
93 ATH_MSG_DEBUG ("Retrieved CTT score from CTT tool: " << CTTScore);
94 ATH_MSG_DEBUG("CTT score of decorated xAOD::Jet : " << jetReadDecorHandle(*curjet));
95 assert(Athena_test::isEqual(CTTScore,jetReadDecorHandle(*curjet)));
96 }
97
98 return StatusCode::SUCCESS;
99}
100
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< Analysis::IClassifiedTrackTaggerTool > m_classifiedTrackTagger
virtual StatusCode execute() override
SG::ReadDecorHandleKey< xAOD::JetContainer > m_jetReadDecorKey
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
CTTDecorCheckInTool(const std::string &type, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_particlesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_verticesKey
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition FLOATassert.h:26
Vertex_v1 Vertex
Define the latest version of the vertex class.