ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::InDetPRD_AssociationToolGangedPixels Class Reference

Concrete Implementation of the IPRD_AssociationTool interface. More...

#include <InDetPRD_AssociationToolGangedPixels.h>

Inheritance diagram for InDet::InDetPRD_AssociationToolGangedPixels:
Collaboration diagram for InDet::InDetPRD_AssociationToolGangedPixels:

Public Types

typedef Trk::IPRD_AssociationTool::Maps Maps

Public Member Functions

 InDetPRD_AssociationToolGangedPixels (const std::string &, const std::string &, const IInterface *)
virtual ~InDetPRD_AssociationToolGangedPixels ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode addPRDs (const Trk::Track &track) override
 add the PRDs from this track to the store
virtual StatusCode addPRDs (Maps &maps, const Trk::Track &track) const override
 add the PRDs from this track to maps.
virtual StatusCode removePRDs (Maps &maps, const Trk::Track &track) const override
 remove the PRDs from this track from maps
virtual StatusCode removePRDs (const Trk::Track &track) override
 remove the PRDs from this track from the store
virtual bool isUsed (const Maps &maps, const Trk::PrepRawData &prd) const override final
 does this PRD belong to at least one track in maps?
virtual bool isUsed (const Trk::PrepRawData &prd) const override
 does this PRD belong to at least one track?
virtual bool isShared (const Maps &maps, const Trk::PrepRawData &prd) const override final
 does this PRD belong to more than one track in maps?
virtual bool isShared (const Trk::PrepRawData &prd) const override
 does this PRD belong to more than one track?
virtual std::vector< const Trk::PrepRawData * > getPrdsOnTrack (const Trk::Track &track) const override
 returns a vector of PRDs belonging to the passed track.
virtual std::vector< const Trk::PrepRawData * > getPrdsOnTrack (const Maps &maps, const Trk::Track &track) const override
virtual Trk::IPRD_AssociationTool::TrackSet findConnectedTracks (const Trk::Track &track) const override
 returns set of tracks which share PRD with this one
virtual IPRD_AssociationTool::TrackSet findConnectedTracks (const Maps &maps, const Trk::Track &track) const override
virtual Trk::IPRD_AssociationTool::PrepRawDataTrackMapRange onTracks (const Trk::PrepRawData &prd) const override
 get the Tracks associated with this Trk::PrepRawData.
virtual IPRD_AssociationTool::PrepRawDataTrackMapRange onTracks (const Maps &maps, const Trk::PrepRawData &prd) const override
virtual void reset () override
 resets the tool - should be called before using tool (and maybe afterwards to free up memory)

Private Attributes

Maps m_maps
SG::ReadHandleKey< PixelGangedClusterAmbiguities > m_pixelClusterAmbiguitiesMapName {this, "PixelClusterAmbiguitiesMapName", "PixelClusterAmbiguitiesMap"}
BooleanProperty m_addTRToutliers {this, "addTRToutliers", false}
 add TRT outliers in the addTrack method to avoid splits due to rejected extensions

Detailed Description

Concrete Implementation of the IPRD_AssociationTool interface.

Definition at line 20 of file InDetPRD_AssociationToolGangedPixels.h.

Member Typedef Documentation

◆ Maps

Constructor & Destructor Documentation

◆ InDetPRD_AssociationToolGangedPixels()

InDet::InDetPRD_AssociationToolGangedPixels::InDetPRD_AssociationToolGangedPixels ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 16 of file InDetPRD_AssociationToolGangedPixels.cxx.

16 :
17 base_class(t,n,p)
18{ }

◆ ~InDetPRD_AssociationToolGangedPixels()

InDet::InDetPRD_AssociationToolGangedPixels::~InDetPRD_AssociationToolGangedPixels ( )
virtualdefault

Member Function Documentation

◆ addPRDs() [1/2]

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::addPRDs ( const Trk::Track & track)
overridevirtual

add the PRDs from this track to the store

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

Definition at line 34 of file InDetPRD_AssociationToolGangedPixels.cxx.

35{
36 return addPRDs (m_maps, track);
37}
virtual StatusCode addPRDs(const Trk::Track &track) override
add the PRDs from this track to the store

◆ addPRDs() [2/2]

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::addPRDs ( Maps & maps,
const Trk::Track & track ) const
overridevirtual

add the PRDs from this track to maps.

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

Definition at line 39 of file InDetPRD_AssociationToolGangedPixels.cxx.

41{
42 // test caching
43 TrackPrepRawDataMap::const_iterator itvec = maps.m_trackPrepRawDataMap.find(&track);
44 if (itvec!=maps.m_trackPrepRawDataMap.end())
45 {
46 ATH_MSG_ERROR("track already found in cache, should not happen");
47 return StatusCode::FAILURE;
48 }
49 // get all prds on 'track'
50 std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack( maps, track );
51
52 SG::ReadHandle<PixelGangedClusterAmbiguities> gangedAmbis (m_pixelClusterAmbiguitiesMapName);
53
54 // loop over PRD
55 for (const Trk::PrepRawData* prd : prds) {
56 maps.m_prepRawDataTrackMap.emplace(prd, &track);
57 // test ganged ambiguity
59 const PixelCluster* pixel = static_cast<const PixelCluster*> (prd);
60 if (pixel->gangedPixel()) {
61 ATH_MSG_DEBUG( "Found ganged pixel, search for mirror" );
62 std::pair<PixelGangedClusterAmbiguities::const_iterator,
63 PixelGangedClusterAmbiguities::const_iterator> ambi = gangedAmbis->equal_range(pixel);
64 for (; ambi.first != ambi.second ; ++(ambi.first) ) {
65 // add ambiguity as used by this track as well
66 ATH_MSG_DEBUG( "Found mirror pixel, add mirror to association map" );
67 maps.m_prepRawDataTrackMap.emplace(ambi.first->second, &track);
68 }
69 }
70 }
71 }
72
73 // cache this using maps.m_trackPrepRawDataMap
74 maps.m_trackPrepRawDataMap.emplace(&track, prds);
75
76 ATH_MSG_DEBUG("Added PRDs from Track at ("<<&track<<") - map now has size: \t"
77 <<maps.m_prepRawDataTrackMap.size());
78 return StatusCode::SUCCESS;
79}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
virtual std::vector< const Trk::PrepRawData * > getPrdsOnTrack(const Trk::Track &track) const override
returns a vector of PRDs belonging to the passed track.
SG::ReadHandleKey< PixelGangedClusterAmbiguities > m_pixelClusterAmbiguitiesMapName
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.

◆ finalize()

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::finalize ( )
overridevirtual

Definition at line 29 of file InDetPRD_AssociationToolGangedPixels.cxx.

30{
31 return StatusCode::SUCCESS;
32}

◆ findConnectedTracks() [1/2]

Trk::IPRD_AssociationTool::TrackSet InDet::InDetPRD_AssociationToolGangedPixels::findConnectedTracks ( const Maps & maps,
const Trk::Track & track ) const
overridevirtual

Definition at line 170 of file InDetPRD_AssociationToolGangedPixels.cxx.

172{
173 TrackSet connectedTracks;
174
175 SG::ReadHandle<PixelGangedClusterAmbiguities> gangedAmbis (m_pixelClusterAmbiguitiesMapName);
176
177 std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack(maps, track);
178 for (const Trk::PrepRawData* prd : prds) {
180 // add them into the list
181 for ( ; range.first!=range.second; ++(range.first) )
182 connectedTracks.insert((range.first)->second);
183
184 // test ganged ambiguity
185
186 if (prd->type(Trk::PrepRawDataType::PixelCluster)) {
187 const PixelCluster* pixel = static_cast<const PixelCluster*> (prd);
188 if (pixel->gangedPixel()) {
189 std::pair<PixelGangedClusterAmbiguities::const_iterator,
190 PixelGangedClusterAmbiguities::const_iterator> ambi = gangedAmbis->equal_range(pixel);
191 for (; ambi.first != ambi.second ; ++(ambi.first) ) {
192 range = onTracks( maps, *(ambi.first->second) );
193 // add them into the list
194 for ( ; range.first!=range.second; ++(range.first) )
195 connectedTracks.insert((range.first)->second);
196 }
197 }
198 }
199 }
200
201 // don't forget to remove the input track
202 connectedTracks.erase(&track);
203
204 ATH_MSG_VERBOSE("Added in connected tracks for track "<<&track
205 << "\tsize of list is "<<connectedTracks.size());
206
207 return connectedTracks;
208}
#define ATH_MSG_VERBOSE(x)
virtual Trk::IPRD_AssociationTool::PrepRawDataTrackMapRange onTracks(const Trk::PrepRawData &prd) const override
get the Tracks associated with this Trk::PrepRawData.
std::pair< ConstPRD_MapIt, ConstPRD_MapIt > PrepRawDataTrackMapRange
the first element is the beginning iterator of the range, the second is the end

◆ findConnectedTracks() [2/2]

Trk::IPRD_AssociationTool::TrackSet InDet::InDetPRD_AssociationToolGangedPixels::findConnectedTracks ( const Trk::Track & track) const
overridevirtual

returns set of tracks which share PRD with this one

Parameters
trackthis Track must be known to this tool.
Returns
a set of tracks which share PRD/hits with the passed 'track'

Definition at line 164 of file InDetPRD_AssociationToolGangedPixels.cxx.

165{
166 return findConnectedTracks (m_maps, track);
167}
virtual Trk::IPRD_AssociationTool::TrackSet findConnectedTracks(const Trk::Track &track) const override
returns set of tracks which share PRD with this one

◆ getPrdsOnTrack() [1/2]

std::vector< const Trk::PrepRawData * > InDet::InDetPRD_AssociationToolGangedPixels::getPrdsOnTrack ( const Maps & maps,
const Trk::Track & track ) const
overridevirtual

Definition at line 219 of file InDetPRD_AssociationToolGangedPixels.cxx.

221{
222 using PRDs_t = std::vector<const Trk::PrepRawData *>;
223
224 // test caching
225 TrackPrepRawDataMap::const_iterator itvec = maps.m_trackPrepRawDataMap.find(&track);
226 if (itvec!=maps.m_trackPrepRawDataMap.end())
227 {
228 ATH_MSG_VERBOSE("found track in cache, return cached PRD vector for track");
229 return itvec->second;
230 }
231
232 if (track.measurementsOnTrack()==nullptr) {
233 ATH_MSG_WARNING("Track has no RoTs");
234 return {}; // return vector optimization
235 }
236
237
238 // output vector
239 PRDs_t vec;
240 // size it
241 vec.reserve(track.measurementsOnTrack()->size());
242
243 // get the PRDs for the measuremenst on track
244 DataVector<const Trk::MeasurementBase>::const_iterator it = track.measurementsOnTrack()->begin();
245 DataVector<const Trk::MeasurementBase>::const_iterator itEnd = track.measurementsOnTrack()->end();
246 for (;it!=itEnd;++it){
247 const auto *const pThisMeasurement(*it);
248 if (pThisMeasurement->type(Trk::MeasurementBaseType::RIO_OnTrack)){
249 const Trk::RIO_OnTrack* rot = static_cast<const Trk::RIO_OnTrack*>(pThisMeasurement);
250 vec.push_back(rot->prepRawData());
251 }
252 }
253 ATH_MSG_DEBUG(" Getting "<<vec.size()<<" PRDs from track at:"<<&track);
254 // new mode, we add the outliers in the TRT
255 if (m_addTRToutliers) {
256 // get the PRDs for the measuremenst on track
257 for (const Trk::MeasurementBase* meas : *track.outliersOnTrack()){
258 // get the ROT, make sure it is not a pseudo measurment
260 const Trk::RIO_OnTrack* rot = static_cast<const Trk::RIO_OnTrack*>(meas);
261 // check if outlier is TRT ?
263 // add to the list, it is TRT
264 vec.push_back(rot->prepRawData());
265 }
266 }
267 }
268 ATH_MSG_DEBUG(" Getting "<<vec.size()<<" PRDs including TRT outlier from track at:"<<&track);
269 }
270
271 return vec;
272}
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
BooleanProperty m_addTRToutliers
add TRT outliers in the addTrack method to avoid splits due to rejected extensions
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
virtual bool rioType(RIO_OnTrackType::Type type) const =0
Method checking the Rio On Track type.

◆ getPrdsOnTrack() [2/2]

std::vector< const Trk::PrepRawData * > InDet::InDetPRD_AssociationToolGangedPixels::getPrdsOnTrack ( const Trk::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).

Definition at line 212 of file InDetPRD_AssociationToolGangedPixels.cxx.

213{
214 return getPrdsOnTrack (m_maps, track);
215}

◆ initialize()

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::initialize ( )
overridevirtual

Definition at line 23 of file InDetPRD_AssociationToolGangedPixels.cxx.

24{
26 return StatusCode::SUCCESS;
27}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ isShared() [1/2]

bool InDet::InDetPRD_AssociationToolGangedPixels::isShared ( const Maps & maps,
const Trk::PrepRawData & prd ) const
inlinefinaloverridevirtual

does this PRD belong to more than one track in maps?

Parameters
prdthe PrepRawData in question
Returns
true if 'prd' exists on more than one track (of course PRD_AssociationTool can only give information about tracks it knows about i.e. that were added to maps with addPRDs()

Definition at line 131 of file InDetPRD_AssociationToolGangedPixels.h.

133{
134 return (maps.m_prepRawDataTrackMap.count(&prd)>1);
135}

◆ isShared() [2/2]

bool InDet::InDetPRD_AssociationToolGangedPixels::isShared ( const Trk::PrepRawData & prd) const
inlineoverridevirtual

does this PRD belong to more than one track?

Parameters
prdthe PrepRawData in question
Returns
true if 'prd' exists on more than one track (of course PRD_AssociationTool can only give information about tracks it knows about i.e. that were added with addPRDs()

Definition at line 138 of file InDetPRD_AssociationToolGangedPixels.h.

139{
140 return isShared (m_maps, prd);
141}
virtual bool isShared(const Maps &maps, const Trk::PrepRawData &prd) const override final
does this PRD belong to more than one track in maps?

◆ isUsed() [1/2]

bool InDet::InDetPRD_AssociationToolGangedPixels::isUsed ( const Maps & maps,
const Trk::PrepRawData & prd ) const
inlinefinaloverridevirtual

does this PRD belong to at least one track in maps?

Parameters
prdthe PrepRawData in question
Returns
true if 'prd' exists in at least one track (of course PRD_AssociationTool can only give information about tracks it knows about i.e. that were added to maps with addPRDs()

Definition at line 118 of file InDetPRD_AssociationToolGangedPixels.h.

120{
121 return (maps.m_prepRawDataTrackMap.count(&prd)>0);
122}

◆ isUsed() [2/2]

bool InDet::InDetPRD_AssociationToolGangedPixels::isUsed ( const Trk::PrepRawData & prd) const
inlineoverridevirtual

does this PRD belong to at least one track?

Parameters
prdthe PrepRawData in question
Returns
true if 'prd' exists in at least one track (of course PRD_AssociationTool can only give information about tracks it knows about i.e. that were added with addPRDs()

Definition at line 125 of file InDetPRD_AssociationToolGangedPixels.h.

126{
127 return isUsed (m_maps, prd);
128}
virtual bool isUsed(const Maps &maps, const Trk::PrepRawData &prd) const override final
does this PRD belong to at least one track in maps?

◆ onTracks() [1/2]

Trk::IPRD_AssociationTool::PrepRawDataTrackMapRange InDet::InDetPRD_AssociationToolGangedPixels::onTracks ( const Maps & maps,
const Trk::PrepRawData & prd ) const
overridevirtual

Definition at line 281 of file InDetPRD_AssociationToolGangedPixels.cxx.

283{
284 return maps.m_prepRawDataTrackMap.equal_range(&prd);
285}

◆ onTracks() [2/2]

Trk::IPRD_AssociationTool::PrepRawDataTrackMapRange InDet::InDetPRD_AssociationToolGangedPixels::onTracks ( const Trk::PrepRawData & prd) const
overridevirtual

get the Tracks associated with this Trk::PrepRawData.

IMPORTANT: Please use the typedefs IPRD_AssociationTool::PrepRawDataRange and IPRD_AssociationTool::ConstPRD_MapIt (defined in the interface) to access the tracks, as the way the data is stored internally may change.

Definition at line 275 of file InDetPRD_AssociationToolGangedPixels.cxx.

276{
277 return onTracks (m_maps, prd);
278}

◆ removePRDs() [1/2]

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::removePRDs ( const Trk::Track & track)
overridevirtual

remove the PRDs from this track from the store

Parameters
trackall PRDs from 'track' will be removed from the PRD_AssociationTool's internal store.

Definition at line 81 of file InDetPRD_AssociationToolGangedPixels.cxx.

82{
83 return removePRDs (m_maps, track);
84}
virtual StatusCode removePRDs(Maps &maps, const Trk::Track &track) const override
remove the PRDs from this track from maps

◆ removePRDs() [2/2]

StatusCode InDet::InDetPRD_AssociationToolGangedPixels::removePRDs ( Maps & maps,
const Trk::Track & track ) const
overridevirtual

remove the PRDs from this track from maps

Parameters
trackall PRDs from 'track' will be removed from maps

Definition at line 86 of file InDetPRD_AssociationToolGangedPixels.cxx.

88{
89 // This is NOT pretty code!
90 // At the moment I'm brute-forcing, but maybe I need a second map, containing <Track*, iterator>
91 // The problem is that I think filling such a map is also time-consuming.
92 // Since removes happen much less frequently than add, then the slow bit should be here.
93 // EJWM
94
95 // save for debugging purposes
96 int oldSize = maps.m_prepRawDataTrackMap.size();//used in debug output at end.
97
98 // test caching
99 TrackPrepRawDataMap::iterator itvec = maps.m_trackPrepRawDataMap.find(&track);
100 if (itvec==maps.m_trackPrepRawDataMap.end())
101 {
102 ATH_MSG_ERROR("Track not found in cache, this should not happen");
103 return StatusCode::FAILURE;
104 }
105
106 SG::ReadHandle<PixelGangedClusterAmbiguities> gangedAmbis (m_pixelClusterAmbiguitiesMapName);
107
108 // get all prds on 'track'
109 std::vector< const Trk::PrepRawData* > prds = itvec->second;
110 for (const Trk::PrepRawData* prd : prds)
111 {
112 // now get all map elements (i.e. Tracks) that contain this PRD
114 range = maps.m_prepRawDataTrackMap.equal_range(prd);
115 // get iterators for range
116 ConstPRD_MapIt mapIt = range.first;
117 ConstPRD_MapIt mapItEnd = range.second;
118 // simple for loop instead of fancier remove_if above
119 for ( ;mapIt!=mapItEnd; ++mapIt) {
120 if ( mapIt->second==&track ) {
121 maps.m_prepRawDataTrackMap.erase( mapIt );
122 break;//should only ever be one Track
123 }
124 }
125
126 // test ganged ambiguity
127
128 if (prd->type(Trk::PrepRawDataType::PixelCluster)) {
129 const PixelCluster* pixel = static_cast<const PixelCluster*> (prd);
130 if (pixel->gangedPixel()) {
131 std::pair<PixelGangedClusterAmbiguities::const_iterator,
132 PixelGangedClusterAmbiguities::const_iterator> ambi = gangedAmbis->equal_range(pixel);
133 for (; ambi.first != ambi.second ; ++(ambi.first) ) {
134 // add ambiguity as used by this track as well
135 ATH_MSG_DEBUG("Found ganged pixel, remove also mirror from association map");
136
137 range = maps.m_prepRawDataTrackMap.equal_range(ambi.first->second);
138 // get iterators for range
139 mapIt = range.first;
140 mapItEnd = range.second;
141 // simple for loop instead of fancier remove_if above
142 for ( ;mapIt!=mapItEnd; ++mapIt) {
143 if ( mapIt->second==&track ) {
144 maps.m_prepRawDataTrackMap.erase( mapIt );
145 break;//should only ever be one Track
146 }
147 }
148 }
149 }
150 }
151
152 }
153
154 // remove cached PRD vector
155 maps.m_trackPrepRawDataMap.erase( itvec );
156
157 ATH_MSG_DEBUG("Removed PRDs from track ("
158 <<&track<<") \t- map has changed size from \t"
159 <<oldSize <<" \tto "<<maps.m_prepRawDataTrackMap.size());
160 return StatusCode::SUCCESS;
161}

◆ reset()

void InDet::InDetPRD_AssociationToolGangedPixels::reset ( )
overridevirtual

resets the tool - should be called before using tool (and maybe afterwards to free up memory)

Definition at line 287 of file InDetPRD_AssociationToolGangedPixels.cxx.

288{
289 m_maps.m_prepRawDataTrackMap.clear();
290 m_maps.m_trackPrepRawDataMap.clear();
291}

Member Data Documentation

◆ m_addTRToutliers

BooleanProperty InDet::InDetPRD_AssociationToolGangedPixels::m_addTRToutliers {this, "addTRToutliers", false}
private

add TRT outliers in the addTrack method to avoid splits due to rejected extensions

Definition at line 113 of file InDetPRD_AssociationToolGangedPixels.h.

113{this, "addTRToutliers", false};

◆ m_maps

Maps InDet::InDetPRD_AssociationToolGangedPixels::m_maps
private

Definition at line 108 of file InDetPRD_AssociationToolGangedPixels.h.

◆ m_pixelClusterAmbiguitiesMapName

SG::ReadHandleKey<PixelGangedClusterAmbiguities> InDet::InDetPRD_AssociationToolGangedPixels::m_pixelClusterAmbiguitiesMapName {this, "PixelClusterAmbiguitiesMapName", "PixelClusterAmbiguitiesMap"}
private

Definition at line 110 of file InDetPRD_AssociationToolGangedPixels.h.

110{this, "PixelClusterAmbiguitiesMapName", "PixelClusterAmbiguitiesMap"};

The documentation for this class was generated from the following files: