ATLAS Offline Software
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());
23  ATH_CHECK(m_assoTool.retrieve());
24 
25  return StatusCode::SUCCESS;
26 }
27 
29 {
30  // Associate tracks with PRDs
31  //
32  std::unique_ptr<Trk::PRDtoTrackMap> prd_to_track_map(m_assoTool->createPRDtoTrackMap());
33 
34  for (const SG::ReadHandleKey<TrackCollection>& collKey : m_tracksName) {
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 
PRDtoTrackMap.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDet::InDetTrackPRD_Association::initialize
virtual StatusCode initialize() override
Definition: InDetTrackPRD_Association.cxx:17
InDet::InDetTrackPRD_Association::m_assoMapName
SG::WriteHandleKey< Trk::PRDtoTrackMap > m_assoMapName
the key given to the newly created association map
Definition: InDetTrackPRD_Association.h:60
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
InDet::InDetTrackPRD_Association::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: InDetTrackPRD_Association.cxx:28
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::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::InDetTrackPRD_Association::finalize
virtual StatusCode finalize() override
Definition: InDetTrackPRD_Association.cxx:59
InDet::InDetTrackPRD_Association::m_tracksName
SG::ReadHandleKeyArray< TrackCollection > m_tracksName
Name of track collections.
Definition: InDetTrackPRD_Association.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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.
InDetTrackPRD_Association.h
InDet::InDetTrackPRD_Association::InDetTrackPRD_Association
InDetTrackPRD_Association(const std::string &name, ISvcLocator *pSvcLocator)
Definition: InDetTrackPRD_Association.cxx:13
InDet::InDetTrackPRD_Association::m_assoTool
ToolHandle< Trk::IPRDtoTrackMapTool > m_assoTool
Definition: InDetTrackPRD_Association.h:56