ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Trk::PRDtoTrackMapTool Class Referencefinal

Concrete Implementation of the IPRD_AssociationTool interface. More...

#include <PRDtoTrackMapTool.h>

Inheritance diagram for Trk::PRDtoTrackMapTool:
Collaboration diagram for Trk::PRDtoTrackMapTool:

Classes

class  PRDtoTrackMap
 

Public Member Functions

 PRDtoTrackMapTool (const std::string &, const std::string &, const IInterface *)
 
virtual ~PRDtoTrackMapTool ()=default
 
virtual StatusCode initialize () override
 
virtual std::unique_ptr< Trk::PRDtoTrackMapcreatePRDtoTrackMap () const override
 
virtual std::unique_ptr< Trk::PRDtoTrackMapreduceToStorableMap (std::unique_ptr< Trk::PRDtoTrackMap > &&obj_in) const override
 
StatusCode addPRDs (Trk::PRDtoTrackMap &virt_prd_to_track_map, const Trk::Track &track) const override
 add the PRDs from this track to the store More...
 
virtual std::vector< const PrepRawData * > getPrdsOnTrack (Trk::PRDtoTrackMap &virt_prd_to_track_map, const Track &track) const override
 returns a vector of PRDs belonging to the passed track. More...
 
virtual IPRDtoTrackMapTool::TrackSet findConnectedTracks (Trk::PRDtoTrackMap &virt_prd_to_track_map, const Track &track) const override
 

Protected Member Functions

void ensureType (Trk::PRDtoTrackMap &virt_prd_to_track_map) const
 

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 

Detailed Description

Concrete Implementation of the IPRD_AssociationTool interface.

Definition at line 24 of file PRDtoTrackMapTool.h.

Constructor & Destructor Documentation

◆ PRDtoTrackMapTool()

Trk::PRDtoTrackMapTool::PRDtoTrackMapTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 16 of file PRDtoTrackMapTool.cxx.

19  : base_class(t,n,p)
20 {
21 }

◆ ~PRDtoTrackMapTool()

virtual Trk::PRDtoTrackMapTool::~PRDtoTrackMapTool ( )
virtualdefault

Member Function Documentation

◆ addPRDs()

StatusCode Trk::PRDtoTrackMapTool::addPRDs ( Trk::PRDtoTrackMap virt_prd_to_track_map,
const Trk::Track track 
) const
override

add the PRDs from this track to the store

Parameters
trackall PRDs from 'track' will be added to PRDtoTrackMapTool's internal store.

Definition at line 47 of file PRDtoTrackMapTool.cxx.

48 {
49  ensureType(virt_prd_to_track_map);
50  PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
51 
52  // test caching
53  PRDtoTrackMap::TrackPrepRawDataMap::const_iterator itvec = prd_to_track_map.m_trackPrepRawDataMap.find(&track);
54  if (itvec!=prd_to_track_map.m_trackPrepRawDataMap.end())
55  {
56  ATH_MSG_ERROR ("track already found in cache, should not happen");
57  return StatusCode::FAILURE;
58  }
59  // add all prds on track to map
60  std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack(prd_to_track_map, track );
61  for(const Trk::PrepRawData*a_prd : prds) {
62  if (prd_to_track_map.m_prepRawDataTrackMap.insert(std::make_pair(a_prd, &track) ) == prd_to_track_map.m_prepRawDataTrackMap.end()) {
63  ATH_MSG_ERROR ("failed to associate track to prd.");
64  }
65  }
66 
67  // cache this using m_trackPrepRawDataMap
68  prd_to_track_map.m_trackPrepRawDataMap.insert( std::make_pair(&track, std::move(prds)) );
69 
70  ATH_MSG_DEBUG ("Added PRDs from Track at ("<<&track<<") - map now has size: \t"<<
71  prd_to_track_map.m_prepRawDataTrackMap.size());
72  return StatusCode::SUCCESS;
73 }

◆ createPRDtoTrackMap()

std::unique_ptr< Trk::PRDtoTrackMap > Trk::PRDtoTrackMapTool::createPRDtoTrackMap ( ) const
overridevirtual

Definition at line 28 of file PRDtoTrackMapTool.cxx.

28  {
29  return std::make_unique<Trk::PRDtoTrackMapTool::PRDtoTrackMap>();
30 }

◆ ensureType()

void Trk::PRDtoTrackMapTool::ensureType ( Trk::PRDtoTrackMap virt_prd_to_track_map) const
protected

Definition at line 36 of file PRDtoTrackMapTool.cxx.

37 {
38  if (virt_prd_to_track_map.getType() != typeid(PRDtoTrackMapTool::PRDtoTrackMap)) {
39  ATH_MSG_FATAL( "Type mismap between tool and map. Expecting " << typeid(PRDtoTrackMap).name()
40  << " but got " << virt_prd_to_track_map.getType().name()
41  << " . The tool can only handle a map created by the same tool. ");
42  throw std::logic_error("Type mismap between tool and map");
43  }
44  assert( dynamic_cast<PRDtoTrackMap *>(&virt_prd_to_track_map) != nullptr );
45 }

◆ findConnectedTracks()

Trk::PRDtoTrackMapTool::TrackSet Trk::PRDtoTrackMapTool::findConnectedTracks ( Trk::PRDtoTrackMap virt_prd_to_track_map,
const Track track 
) const
overridevirtual

Definition at line 77 of file PRDtoTrackMapTool.cxx.

78 {
79  ensureType(virt_prd_to_track_map);
80  PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
81 
82  TrackSet connectedTracks;
83 
84  std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack(prd_to_track_map, track);
85  for (const Trk::PrepRawData* a_prd : prds )
86  {
87  PRDtoTrackMap::PrepRawDataTrackMapRange range = prd_to_track_map.onTracks(*a_prd);
88 
89  // TODO use remove_copy_if instead.
90  for ( ; range.first!=range.second; ++(range.first) )
91  {
92  const Track* conTrack = (range.first)->second;
93  // don't copy this track!
94  if (conTrack!=&track) {
95  // this does actually not allow for double entries
96  connectedTracks.insert(conTrack);
97  ATH_MSG_VERBOSE ("Track "<<&track<<" \tshares PRD "<<a_prd<<" \twith track:"<<conTrack);
98  }
99  }
100  ATH_MSG_VERBOSE ("Added in connected tracks for PRD:"<<a_prd<<
101  "\tsize of list now:"<<connectedTracks.size());
102  }
103 
104  return connectedTracks;
105 }

◆ getPrdsOnTrack()

std::vector< const Trk::PrepRawData * > Trk::PRDtoTrackMapTool::getPrdsOnTrack ( Trk::PRDtoTrackMap virt_prd_to_track_map,
const Track track 
) const
overridevirtual

returns a vector of PRDs belonging to the passed track.

It's basically for the convenience of users and is created purely from the passed track. i.e. there is no caching if you do it multiple times on the same track, you're being inefficient!!

Parameters
trackthis Track will be iterated through and all PrepRawData added to a vector
Returns
vector of PrepRawData* belonging to 'track'. The PrepRawData should NOT be deleted
  • they belong to the Track (and thus the event).

Accept only non muon hits or muon precision hits

Definition at line 109 of file PRDtoTrackMapTool.cxx.

111 {
112  using PRDs_t = std::vector<const Trk::PrepRawData *>;
113 
114  ensureType(virt_prd_to_track_map);
115  PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
116 
117  // test caching
118  PRDtoTrackMap::TrackPrepRawDataMap::const_iterator itvec = prd_to_track_map.m_trackPrepRawDataMap.find(&track);
119  if (itvec!=prd_to_track_map.m_trackPrepRawDataMap.end())
120  {
121  ATH_MSG_VERBOSE ("found track in cache, return cached PRD vector for track");
122  return itvec->second;
123  }
124 
125  if (!track.measurementsOnTrack()) {
126  ATH_MSG_WARNING ("Track has no RoTs");
127  return {};
128  }
129 
130  // FIXME can I do this without copying the vector?
131  /* transform(
132  track.measurementsOnTrack()->begin(),
133  track.measurementsOnTrack()->end() ,
134  back_inserter(vec),
135  bind2nd(CreatePRD_VectorFromTrack(), &track) );*/
136 
137  PRDs_t vec;
138  vec.reserve(track.measurementsOnTrack()->size());
139 
140  auto add_prd = [&vec, this] (const Trk::RIO_OnTrack* rot) {
141  if (!rot) return;
142  const PrepRawData* prd = rot->prepRawData();
143  if (!prd) return;
144  const Identifier rot_id = prd->identify();
146  if ( m_idHelperSvc->isMuon(rot_id) && !m_idHelperSvc->isMdt(rot_id) && !m_idHelperSvc->isMM(rot_id) && !m_idHelperSvc->issTgc(rot_id) &&
147  (!m_idHelperSvc->isCsc(rot_id) || m_idHelperSvc->measuresPhi(rot_id)) ) return;
148  vec.push_back(prd);
149  };
150  for (const MeasurementBase* meas : *track.measurementsOnTrack()) {
151  const Trk::RIO_OnTrack* rot = nullptr;
152  if (meas->type(Trk::MeasurementBaseType::RIO_OnTrack)) {
153  rot = static_cast<const RIO_OnTrack*>(meas);
154  }
155  if (rot) {
156  add_prd(rot);
157  continue;
158  }
159  const Trk::CompetingRIOsOnTrack* competingROT = nullptr;
161  competingROT = static_cast<const Trk::CompetingRIOsOnTrack*>(meas);
162  }
163  if (!competingROT) { continue;}
164  const unsigned int numROTs = competingROT->numberOfContainedROTs();
165  for( unsigned int i=0;i<numROTs;++i ){
166  const Trk::RIO_OnTrack* rot = &competingROT->rioOnTrack(i);
167  add_prd(rot);
168  }
169  }
170  ATH_MSG_DEBUG (" Getting "<<vec.size()<<" PRDs from track at:"<<&track);
171 
172  return vec;
173 }

◆ initialize()

StatusCode Trk::PRDtoTrackMapTool::initialize ( )
overridevirtual

Definition at line 23 of file PRDtoTrackMapTool.cxx.

23  {
24  ATH_CHECK(m_idHelperSvc.retrieve());
25  return StatusCode::SUCCESS;
26 }

◆ reduceToStorableMap()

std::unique_ptr< Trk::PRDtoTrackMap > Trk::PRDtoTrackMapTool::reduceToStorableMap ( std::unique_ptr< Trk::PRDtoTrackMap > &&  obj_in) const
overridevirtual

Definition at line 32 of file PRDtoTrackMapTool.cxx.

32  {
33  return std::move(obj_in);
34 }

Member Data Documentation

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Trk::PRDtoTrackMapTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 63 of file PRDtoTrackMapTool.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::PRDtoTrackMap::PrepRawDataTrackMapRange
std::pair< PrepRawDataTrackMap::iterator, PrepRawDataTrackMap::iterator > PrepRawDataTrackMapRange
Definition: PRDtoTrackMap.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CP::TrackSet
std::set< TrackPtr > TrackSet
Definition: PhysicsAnalysis/AnalysisCommon/IsolationSelection/IsolationSelection/Defs.h:72
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::PRDtoTrackMapTool::ensureType
void ensureType(Trk::PRDtoTrackMap &virt_prd_to_track_map) const
Definition: PRDtoTrackMapTool.cxx:36
Trk::CompetingRIOsOnTrack::numberOfContainedROTs
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::MeasurementBaseType::CompetingRIOsOnTrack
@ CompetingRIOsOnTrack
Definition: MeasurementBase.h:50
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::PRDtoTrackMap::getType
virtual const std::type_info & getType() const
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::PRDtoTrackMapTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: PRDtoTrackMapTool.h:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Trk::MeasurementBaseType::RIO_OnTrack
@ RIO_OnTrack
Definition: MeasurementBase.h:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Trk::PRDtoTrackMapTool::getPrdsOnTrack
virtual std::vector< const PrepRawData * > getPrdsOnTrack(Trk::PRDtoTrackMap &virt_prd_to_track_map, const Track &track) const override
returns a vector of PRDs belonging to the passed track.
Definition: PRDtoTrackMapTool.cxx:109
Identifier
Definition: IdentifierFieldParser.cxx:14