ATLAS Offline Software
TrkAmbiguitySolver.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 Trk::TrkAmbiguitySolver::TrkAmbiguitySolver(const std::string& name, ISvcLocator* pSvcLocator) :
10  AthReentrantAlgorithm (name, pSvcLocator) {}
11 
12 //--------------------------------------------------------------------------
14 = default;
15 
16 //-----------------------------------------------------------------------
19 {
20  ATH_CHECK(m_ambiTool.retrieve());
21 
22  ATH_CHECK(m_scoredTracksKey.initialize());
23  ATH_CHECK(m_resolvedTracksKey.initialize());
24  m_trackInCount=0;
25  m_trackOutCount=0;
26  return StatusCode::SUCCESS;
27 }
28 
29 //-------------------------------------------------------------------------
31 Trk::TrkAmbiguitySolver::execute(const EventContext& ctx) const
32 {
33  ATH_MSG_VERBOSE ("TrkAmbiguitySolver::execute()");
34  SG::ReadHandle<TracksScores> scoredTracksHandle(m_scoredTracksKey, ctx);
35  if ( !scoredTracksHandle.isValid() ) ATH_MSG_ERROR("Could not read scoredTracks.");
36  const int nInput = scoredTracksHandle->size();
37  m_trackInCount += nInput;
38 
39  std::unique_ptr<const TrackCollection> resolvedTracks;
40  resolvedTracks.reset(m_ambiTool->process(scoredTracksHandle.cptr())); //note: take ownership and delete
41  m_trackOutCount += resolvedTracks->size();
42 
43  SG::WriteHandle<TrackCollection> resolvedTracksHandle(m_resolvedTracksKey, ctx);
44  ATH_MSG_DEBUG ("Saving "<<resolvedTracks->size()<<" tracks of " << nInput);
45  if (!resolvedTracksHandle.put(std::move(resolvedTracks))) {
46  ATH_MSG_ERROR ("Can't record tracks as " << m_resolvedTracksKey.key());
47  return StatusCode::FAILURE;
48  }
49  return StatusCode::SUCCESS;
50 }
51 
52 //---------------------------------------------------------------------------
53 
56  if (m_ambiTool.isEnabled()) {
57  m_ambiTool->statistics();
58  }
59  ATH_MSG_DEBUG( "Finalizing with "<< m_trackInCount << " tracks input, and "<< m_trackOutCount<< " output");
60  return StatusCode::SUCCESS;
61 }
Trk::TrkAmbiguitySolver::~TrkAmbiguitySolver
~TrkAmbiguitySolver(void)
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trk::TrkAmbiguitySolver::initialize
StatusCode initialize(void) override
Definition: TrkAmbiguitySolver.cxx:18
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ITrackAmbiguityProcessorTool.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::TrkAmbiguitySolver::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TrkAmbiguitySolver.cxx:31
Trk::TrkAmbiguitySolver::TrkAmbiguitySolver
TrkAmbiguitySolver(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrkAmbiguitySolver.cxx:9
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrkAmbiguitySolver.h
Trk::TrkAmbiguitySolver::finalize
StatusCode finalize(void) override
Definition: TrkAmbiguitySolver.cxx:55
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ITrackAmbiguityScoreProcessorTool.h