ATLAS Offline Software
PRD_AssociationTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRK_PRD_ASSOCIATIONTOOL_H
6 #define TRK_PRD_ASSOCIATIONTOOL_H
7 
10 #include "GaudiKernel/ServiceHandle.h"
11 
15 #include <set>
16 #include <map>
17 
18 namespace Trk {
19 
20  class Track;
21  class PrepRawData;
22 
24  class PRD_AssociationTool final
25  : public extends<AthAlgTool, IPRD_AssociationTool> {
26 
27  public:
28  PRD_AssociationTool(const std::string&,const std::string&,const IInterface*);
29  virtual ~PRD_AssociationTool()=default;
30  virtual StatusCode initialize() override;
31 
34  virtual StatusCode addPRDs(const Track& track) override;
35 
38  virtual StatusCode addPRDs(Maps& maps, const Track& track) const override;
39 
42  virtual StatusCode removePRDs(Maps& maps, const Track& track) const override;
43 
47  virtual StatusCode removePRDs(const Track& track) override;
48 
53  virtual bool isUsed(const Maps& maps, const PrepRawData& prd) const override final;
54 
59  virtual bool isUsed(const PrepRawData& prd) const override final;
60 
65  virtual bool isShared(const Maps& maps, const PrepRawData& prd) const override final;
66 
71  virtual bool isShared(const PrepRawData& prd) const override final;
72 
81  virtual std::vector< const PrepRawData* > getPrdsOnTrack(const Track& track) const override;
82 
83  // getPrdsOnTrack with state passed explicitly.
84  virtual std::vector< const PrepRawData* > getPrdsOnTrack(const Maps& maps,
85  const Track& track) const override;
86 
90  virtual IPRD_AssociationTool::TrackSet findConnectedTracks( const Track& track) const override;
91 
92  // findConnectedTracks with state passed explicitly.
93  virtual IPRD_AssociationTool::TrackSet findConnectedTracks( const Maps& maps, const Track& track) const override;
94 
99  virtual IPRD_AssociationTool::PrepRawDataTrackMapRange onTracks(const PrepRawData& prd) const override;
100 
101  // onTracks with explicit state
103  const PrepRawData& prd) const override;
104 
107  virtual void reset() override;
108 
109  private:
110  // Holds the associations.
111  Maps m_maps;
113 
114  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
115  };
116 
117 inline bool Trk::PRD_AssociationTool::isUsed(const Maps& maps,
118  const PrepRawData& prd) const
119 {
120  return (maps.m_prepRawDataTrackMap.count(&prd)>0);
121 }
122 
123 inline bool Trk::PRD_AssociationTool::isUsed(const PrepRawData& prd) const
124 {
125  if (!m_prdToTrackMap.key().empty()) {return SG::ReadHandle<Trk::PRDtoTrackMap>(m_prdToTrackMap)->isUsed(prd);}
126  return isUsed (m_maps, prd);
127 }
128 
129 inline bool Trk::PRD_AssociationTool::isShared(const Maps& maps,
130  const PrepRawData& prd) const
131 {
132  return (maps.m_prepRawDataTrackMap.count(&prd)>1);
133 }
134 
135 inline bool Trk::PRD_AssociationTool::isShared(const PrepRawData& prd) const
136 {
137  if (!m_prdToTrackMap.key().empty()) {return SG::ReadHandle<Trk::PRDtoTrackMap>(m_prdToTrackMap)->isShared(prd);}
138  return isShared (m_maps, prd);
139 }
140 
141 }
142 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
PRDtoTrackMap.h
Trk::PRD_AssociationTool::onTracks
virtual IPRD_AssociationTool::PrepRawDataTrackMapRange onTracks(const PrepRawData &prd) const override
get the Tracks associated with this Trk::PrepRawData.
Definition: PRD_AssociationTool.cxx:215
Trk::PRD_AssociationTool::m_prdToTrackMap
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
Definition: PRD_AssociationTool.h:112
SG::ReadHandle< Trk::PRDtoTrackMap >
Trk::PRD_AssociationTool::isUsed
virtual bool isUsed(const Maps &maps, const PrepRawData &prd) const override final
does this PRD belong to at least one track in maps?
Definition: PRD_AssociationTool.h:117
Trk::PRD_AssociationTool::getPrdsOnTrack
virtual std::vector< const PrepRawData * > getPrdsOnTrack(const Track &track) const override
returns a vector of PRDs belonging to the passed track.
Definition: PRD_AssociationTool.cxx:157
SG::ReadHandleKey< Trk::PRDtoTrackMap >
Trk::PRD_AssociationTool::isShared
virtual bool isShared(const Maps &maps, const PrepRawData &prd) const override final
does this PRD belong to more than one track in maps?
Definition: PRD_AssociationTool.h:129
Trk::PRD_AssociationTool::m_maps
Maps m_maps
Definition: PRD_AssociationTool.h:111
Trk::PRD_AssociationTool::initialize
virtual StatusCode initialize() override
Definition: PRD_AssociationTool.cxx:24
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthAlgTool.h
Trk::IPRD_AssociationTool::PrepRawDataTrackMapRange
std::pair< ConstPRD_MapIt, ConstPRD_MapIt > PrepRawDataTrackMapRange
the first element is the beginning iterator of the range, the second is the end
Definition: IPRD_AssociationTool.h:48
Trk::PRD_AssociationTool::addPRDs
virtual StatusCode addPRDs(const Track &track) override
add the PRDs from this track to the store
Definition: PRD_AssociationTool.cxx:33
Trk::PRD_AssociationTool::findConnectedTracks
virtual IPRD_AssociationTool::TrackSet findConnectedTracks(const Track &track) const override
returns set of tracks which share PRD with this one
Definition: PRD_AssociationTool.cxx:120
Trk::PRDtoTrackMap::isUsed
bool isUsed(const PrepRawData &prd) const
does this PRD belong to at least one track?
Trk::PRD_AssociationTool::removePRDs
virtual StatusCode removePRDs(Maps &maps, const Track &track) const override
remove the PRDs from this track from maps
Definition: PRD_AssociationTool.cxx:68
IPRD_AssociationTool.h
Trk::PRD_AssociationTool::reset
virtual void reset() override
resets the tool - should be called before using tool (and maybe afterwards to free up memory)
Definition: PRD_AssociationTool.cxx:228
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::PRD_AssociationTool::~PRD_AssociationTool
virtual ~PRD_AssociationTool()=default
Trk::IPRD_AssociationTool::TrackSet
std::set< const Track * > TrackSet
Definition: IPRD_AssociationTool.h:52
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
Trk::PRD_AssociationTool
Concrete Implementation of the IPRD_AssociationTool interface.
Definition: PRD_AssociationTool.h:25
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Trk::PRD_AssociationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: PRD_AssociationTool.h:114
Trk::PRD_AssociationTool::PRD_AssociationTool
PRD_AssociationTool(const std::string &, const std::string &, const IInterface *)
Definition: PRD_AssociationTool.cxx:16
Trk::PRDtoTrackMap::isShared
bool isShared(const PrepRawData &prd) const
does this PRD belong to more than one track?
IMuonIdHelperSvc.h
ServiceHandle< Muon::IMuonIdHelperSvc >