ATLAS Offline Software
Loading...
Searching...
No Matches
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
9Trk::TrkAmbiguitySolver::TrkAmbiguitySolver(const std::string& name, ISvcLocator* pSvcLocator) :
10 AthReentrantAlgorithm (name, pSvcLocator) {}
11
12//--------------------------------------------------------------------------
14= default;
15
16//-----------------------------------------------------------------------
17StatusCode
19{
20 ATH_CHECK(m_ambiTool.retrieve());
21
22 ATH_CHECK(m_scoredTracksKey.initialize());
23 ATH_CHECK(m_resolvedTracksKey.initialize());
26 return StatusCode::SUCCESS;
27}
28
29//-------------------------------------------------------------------------
30StatusCode
31Trk::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
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
54StatusCode
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
StatusCode finalize(void) override
SG::ReadHandleKey< TracksScores > m_scoredTracksKey
<where to find tracks (set in jobOptions and can be multiple collections
SG::WriteHandleKey< TrackCollection > m_resolvedTracksKey
TrkAmbiguitySolver(const std::string &name, ISvcLocator *pSvcLocator)
std::atomic< long int > m_trackOutCount
Number of tracks passing Ambi solving.
StatusCode execute(const EventContext &ctx) const override
std::atomic< long int > m_trackInCount
Number of tracks input.
ToolHandle< ITrackAmbiguityProcessorTool > m_ambiTool
StatusCode initialize(void) override