ATLAS Offline Software
Loading...
Searching...
No Matches
CTTDecorCheckInTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
54
55 // Retrieve the track particles:
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
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 //==========================================================================
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(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(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
#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.