ATLAS Offline Software
TrkAmbiguityScore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 Trk::TrkAmbiguityScore::TrkAmbiguityScore(const std::string& name, ISvcLocator* pSvcLocator) :
9  AthReentrantAlgorithm (name, pSvcLocator) {}
10 
11 //--------------------------------------------------------------------------
13 = default;
14 
15 //-----------------------------------------------------------------------
18  ATH_MSG_VERBOSE( "TrkAmbiguityScore::initialize(). " );
19  ATH_CHECK(m_scoreTool.retrieve( DisableTool{m_scoreTool.empty()} ));
20  ATH_CHECK(m_scoredTracksKey.initialize());
21  ATH_CHECK(m_originTracksKey.initialize());
22  return StatusCode::SUCCESS;
23 }
24 
25 //-------------------------------------------------------------------------
27 Trk::TrkAmbiguityScore::execute(const EventContext& ctx) const{
28  std::vector<SG::ReadHandle<TrackCollection>> handles = m_originTracksKey.makeHandles(ctx);
29  ATH_MSG_DEBUG(handles.size() << " handles are requested");
30  if (handles.size() > 1){
31  ATH_MSG_WARNING("More than one collection has been requested. Only the first collection is taken");
32  }
33  auto & theTrackCollectionHandle = handles.at(0);
34  if (not theTrackCollectionHandle.isValid()){
35  ATH_MSG_FATAL( "Could not retrieve tracks from "<< theTrackCollectionHandle.key() );
36  return StatusCode::FAILURE;
37  }
38  const auto & theTrackCollection = *theTrackCollectionHandle;
39  std::unique_ptr<TracksScores> scoredTracks(new TracksScores);
40  if (m_scoreTool.isEnabled()){
41  m_scoreTool->process(theTrackCollection, scoredTracks.get());
42  } else {
43  scoredTracks->reserve(theTrackCollection.size());
44  for(const Track* trk: theTrackCollection ){
45  scoredTracks->push_back( std::pair<const Track*, float>(trk, 0));//TODO: logpT
46  }
47  }
48 
49  SG::WriteHandle<TracksScores> scoredTracksHandle(m_scoredTracksKey, ctx);
50  ATH_CHECK(scoredTracksHandle.record(std::move(scoredTracks)));
51  return StatusCode::SUCCESS;
52 }
53 
54 //---------------------------------------------------------------------------
55 
56 
59 {
60  if (m_scoreTool.isEnabled()) {
61  m_scoreTool->statistics();
62  }
63  return StatusCode::SUCCESS;
64 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::TrkAmbiguityScore::TrkAmbiguityScore
TrkAmbiguityScore(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrkAmbiguityScore.cxx:8
Trk::TrkAmbiguityScore::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TrkAmbiguityScore.cxx:27
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::TrkAmbiguityScore::finalize
StatusCode finalize(void) override
Definition: TrkAmbiguityScore.cxx:58
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::TracksScores
std::vector< std::pair< const Track *, float > > TracksScores
Definition: ITrackAmbiguityProcessorTool.h:18
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrkAmbiguityScore.h
Trk::TrkAmbiguityScore::initialize
StatusCode initialize(void) override
Definition: TrkAmbiguityScore.cxx:17
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
Trk::TrkAmbiguityScore::~TrkAmbiguityScore
~TrkAmbiguityScore(void)
ITrackAmbiguityScoreProcessorTool.h