ATLAS Offline Software
TrkAmbiguityScore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  m_originTracksKey{""},
11  m_scoredTracksKey("Tracks"),
12  m_scoreTool("",this)
13 {
14  declareProperty("TrackInput" , m_originTracksKey);
15  declareProperty("TrackOutput" , m_scoredTracksKey);
16  declareProperty("AmbiguityScoreProcessor", m_scoreTool);
17 }
18 
19 //--------------------------------------------------------------------------
21 = default;
22 
23 //-----------------------------------------------------------------------
26  ATH_MSG_VERBOSE( "TrkAmbiguityScore::initialize(). " );
27  ATH_CHECK(m_scoreTool.retrieve( DisableTool{m_scoreTool.empty()} ));
28  ATH_CHECK(m_scoredTracksKey.initialize());
29  ATH_CHECK(m_originTracksKey.initialize());
30  return StatusCode::SUCCESS;
31 }
32 
33 //-------------------------------------------------------------------------
35 Trk::TrkAmbiguityScore::execute(const EventContext& ctx) const{
36  std::vector<SG::ReadHandle<TrackCollection>> handles = m_originTracksKey.makeHandles(ctx);
37  ATH_MSG_DEBUG(handles.size() << " handles are requested");
38  if (handles.size() > 1){
39  ATH_MSG_WARNING("More than one collection has been requested. Only the first collection is taken");
40  }
41  auto & theTrackCollectionHandle = handles.at(0);
42  if (not theTrackCollectionHandle.isValid()){
43  ATH_MSG_FATAL( "Could not retrieve tracks from "<< theTrackCollectionHandle.key() );
44  return StatusCode::FAILURE;
45  }
46  const auto & theTrackCollection = *theTrackCollectionHandle;
47  std::unique_ptr<TracksScores> scoredTracks(new TracksScores);
48  if (m_scoreTool.isEnabled()){
49  m_scoreTool->process(theTrackCollection, scoredTracks.get());
50  } else {
51  scoredTracks->reserve(theTrackCollection.size());
52  for(const Track* trk: theTrackCollection ){
53  scoredTracks->push_back( std::pair<const Track*, float>(trk, 0));//TODO: logpT
54  }
55  }
56 
57  SG::WriteHandle<TracksScores> scoredTracksHandle(m_scoredTracksKey, ctx);
58  ATH_CHECK(scoredTracksHandle.record(std::move(scoredTracks)));
59  return StatusCode::SUCCESS;
60 }
61 
62 //---------------------------------------------------------------------------
63 
64 
67 {
68  if (m_scoreTool.isEnabled()) {
69  m_scoreTool->statistics();
70  }
71  return StatusCode::SUCCESS;
72 }
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:35
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::TrkAmbiguityScore::finalize
StatusCode finalize(void) override
Definition: TrkAmbiguityScore.cxx:66
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:221
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:25
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
Trk::TrkAmbiguityScore::~TrkAmbiguityScore
~TrkAmbiguityScore(void)
ITrackAmbiguityScoreProcessorTool.h