ATLAS Offline Software
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 
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 
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 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CTTDecorCheckInTool.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CTTDecorCheckInTool::m_jetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
Definition: CTTDecorCheckInTool.h:51
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CTTDecorCheckInTool::m_classifiedTrackTagger
ToolHandle< Analysis::IClassifiedTrackTaggerTool > m_classifiedTrackTagger
Definition: CTTDecorCheckInTool.h:47
Athena_test::isEqual
bool isEqual(double x1, double x2, double thresh=1e-6)
Definition: FLOATassert.h:26
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CTTDecorCheckInTool::m_jetReadDecorKey
SG::ReadDecorHandleKey< xAOD::JetContainer > m_jetReadDecorKey
Definition: CTTDecorCheckInTool.h:55
CTTDecorCheckInTool::execute
virtual StatusCode execute() override
Definition: CTTDecorCheckInTool.cxx:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CTTDecorCheckInTool::m_particlesKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_particlesKey
Definition: CTTDecorCheckInTool.h:52
CTTDecorCheckInTool::initialize
virtual StatusCode initialize() override
Definition: CTTDecorCheckInTool.cxx:24
CTTDecorCheckInTool::m_jetCollection
std::string m_jetCollection
Definition: CTTDecorCheckInTool.h:48
FLOATassert.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
CTTDecorCheckInTool::CTTDecorCheckInTool
CTTDecorCheckInTool(const std::string &type, ISvcLocator *pSvcLocator)
Definition: CTTDecorCheckInTool.cxx:13