ATLAS Offline Software
Loading...
Searching...
No Matches
InDetTrackPRD_Association.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9// Constructor
11
13(const std::string& name,ISvcLocator* pSvcLocator)
14 : AthReentrantAlgorithm(name, pSvcLocator)
15{}
16
18{
19
20
21 ATH_CHECK(m_tracksName.initialize());
22 ATH_CHECK(m_assoMapName.initialize());
23 ATH_CHECK(m_assoTool.retrieve());
24
25 return StatusCode::SUCCESS;
26}
27
28StatusCode InDet::InDetTrackPRD_Association::execute(const EventContext& ctx) const
29{
30 // Associate tracks with PRDs
31 //
32 std::unique_ptr<Trk::PRDtoTrackMap> prd_to_track_map(m_assoTool->createPRDtoTrackMap());
33
35 SG::ReadHandle<TrackCollection> tracks(collKey,ctx);
36 if (!tracks.isValid()) return StatusCode::FAILURE;
37
38 unsigned tracksPRD=0;
39 unsigned tracksPRDn=0;
40
41 for (const Trk::Track* t : *tracks) {
42 if((m_assoTool->addPRDs(*prd_to_track_map,*t)).isFailure()){
43 ++tracksPRDn;
44 }
45 else{
46 ++tracksPRD;
47 }
48 }
49 ATH_MSG_DEBUG("Collection " << collKey.key() << ": tracks with PRD "<< tracksPRD
50 << ", without PRD " << tracksPRDn);
51 }
53 if (write_handle.record( m_assoTool->reduceToStorableMap(std::move(prd_to_track_map))).isFailure()) {
54 ATH_MSG_FATAL("Failed to add PRD to track association map.");
55 }
56 return StatusCode::SUCCESS;
57}
58
59StatusCode InDet::InDetTrackPRD_Association::finalize() {return StatusCode::SUCCESS;}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode execute(const EventContext &ctx) const override
InDetTrackPRD_Association(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ReadHandleKeyArray< TrackCollection > m_tracksName
Name of track collections.
SG::WriteHandleKey< Trk::PRDtoTrackMap > m_assoMapName
the key given to the newly created association map
ToolHandle< Trk::IPRDtoTrackMapTool > m_assoTool
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.