ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPRDtoTrackMapToolGangedPixels.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "TrkTrack/Track.h"
12#include "Identifier/Identifier.h"
15
16#include <memory>
17
18#include <vector>
20 const std::string& n,
21 const IInterface* p)
22 : base_class(t,n,p)
23{ }
24
26= default;
27
29{
30 bool has_ambi_map = m_pixelClusterAmbiguitiesMapName.initialize(!m_pixelClusterAmbiguitiesMapName.key().empty()).isSuccess();
31 if (!has_ambi_map && !m_pixelClusterAmbiguitiesMapName.key().empty()) {
32 ATH_MSG_WARNING("Could not retrieve "<< m_pixelClusterAmbiguitiesMapName.key() << " this is ok if pixel is off");
33 // @TODO introduce more robust method e.g. dummy tool if pixel is off ?
34 }
35
36 return StatusCode::SUCCESS;
37}
38
40{
41 return StatusCode::SUCCESS;
42}
43
44std::unique_ptr<Trk::PRDtoTrackMap> InDet::InDetPRDtoTrackMapToolGangedPixels::createPRDtoTrackMap() const {
45 std::unique_ptr<PRDtoTrackMap> prd_to_track_map( new PRDtoTrackMap(m_pixelClusterAmbiguitiesMapName ) );
46
48 << ", number of entries for this event:"
49 << (prd_to_track_map->m_gangedAmbis.isValid() ? prd_to_track_map->m_gangedAmbis->size() : -1) );
50 return std::unique_ptr<Trk::PRDtoTrackMap>(prd_to_track_map.release());
51}
52
53std::unique_ptr<Trk::PRDtoTrackMap> InDet::InDetPRDtoTrackMapToolGangedPixels::reduceToStorableMap(std::unique_ptr<Trk::PRDtoTrackMap> &&obj_in) const {
54 if (obj_in->getType()!=typeid(Trk::PRDtoTrackMap)) {
55 return std::move(obj_in);
56 }
57 if (obj_in->getType()!=typeid(InDet::InDetPRDtoTrackMapToolGangedPixels)) {
58 ATH_MSG_FATAL( "Type mismap between tool and map. Expecting " << typeid(InDet::InDetPRDtoTrackMapToolGangedPixels).name()
59 << " but got " << obj_in->getType().name()
60 << " . The tool can only handle a map created by the same tool. ");
61 }
62 Trk::PRDtoTrackMap *the_obj=static_cast<PRDtoTrackMap *>(obj_in.get());
63 return std::make_unique<Trk::PRDtoTrackMap>(std::move(*the_obj));
64}
65
66
68{
69 if (virt_prd_to_track_map.getType() != typeid(InDetPRDtoTrackMapToolGangedPixels::PRDtoTrackMap)) {
70 ATH_MSG_FATAL( "Type mismap between tool and map. Expecting " << typeid(InDetPRDtoTrackMapToolGangedPixels).name()
71 << " but got " << virt_prd_to_track_map.getType().name()
72 << " . The tool can only handle a map created by the same tool. ");
73 throw std::logic_error("Type mismap between tool and map");
74 }
75 assert( dynamic_cast<InDetPRDtoTrackMapToolGangedPixels::PRDtoTrackMap *>(&virt_prd_to_track_map) != nullptr );
76}
77
78
79StatusCode InDet::InDetPRDtoTrackMapToolGangedPixels::addPRDs(Trk::PRDtoTrackMap &virt_prd_to_track_map, const Trk::Track& track ) const
80{
81 ensureType(virt_prd_to_track_map);
82 PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
83 // test caching
84 Trk::PRDtoTrackMap::TrackPrepRawDataMap::const_iterator itvec = prd_to_track_map.m_trackPrepRawDataMap.find(&track);
85 if (itvec!=prd_to_track_map.m_trackPrepRawDataMap.end())
86 {
87 ATH_MSG_ERROR("track already found in cache, should not happen");
88 return StatusCode::FAILURE;
89 }
90 // get all prds on 'track'
91 std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack(prd_to_track_map, track );
92 // loop over PRD
93 for (const Trk::PrepRawData* prd : prds) {
94 prd_to_track_map.m_prepRawDataTrackMap.insert(std::make_pair(prd, &track) );
95 // test ganged ambiguity
97 const PixelCluster* pixel = static_cast<const PixelCluster*> (prd);
98 if (pixel->gangedPixel()) {
99 ATH_MSG_DEBUG( "Found ganged pixel, search for mirror" );
100 std::pair<PixelGangedClusterAmbiguities::const_iterator,
101 PixelGangedClusterAmbiguities::const_iterator> ambi = prd_to_track_map.m_gangedAmbis->equal_range(pixel);
102 for (; ambi.first != ambi.second ; ++(ambi.first) ) {
103 // add ambiguity as used by this track as well
104 if (msgLvl(MSG::DEBUG)) msg() << "Found mirror pixel, add mirror to association map" << endmsg;
105 prd_to_track_map.m_prepRawDataTrackMap.insert(std::make_pair(ambi.first->second, &track) );
106 }
107 }
108 }
109 }
110
111 // cache this using m_trackPrepRawDataMap
112 prd_to_track_map.m_trackPrepRawDataMap.insert( std::make_pair(&track, prds) );
113
114 ATH_MSG_DEBUG("Added PRDs from Track at ("<<&track<<") - map now has size: \t"
115 <<prd_to_track_map.m_prepRawDataTrackMap.size() );
116 return StatusCode::SUCCESS;
117}
118
119
122 const Trk::Track& track ) const
123{
124 ensureType(virt_prd_to_track_map);
125 PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
126
127 TrackSet connectedTracks;
128
129 std::vector< const Trk::PrepRawData* > prds = getPrdsOnTrack(virt_prd_to_track_map, track);
130 for (const Trk::PrepRawData* prd : prds) {
131 Trk::PRDtoTrackMap::ConstPrepRawDataTrackMapRange range = prd_to_track_map.onTracks(*prd);
132 // add them into the list
133 for ( ; range.first!=range.second; ++(range.first) )
134 connectedTracks.insert((range.first)->second);
135
136 // test ganged ambiguity
137
138 if (prd->type(Trk::PrepRawDataType::PixelCluster)) {
139 const PixelCluster* pixel = static_cast<const PixelCluster*> (prd);
140 if (pixel->gangedPixel()) {
141 std::pair<PixelGangedClusterAmbiguities::const_iterator,
142 PixelGangedClusterAmbiguities::const_iterator> ambi = prd_to_track_map.m_gangedAmbis->equal_range(pixel);
143 for (; ambi.first != ambi.second ; ++(ambi.first) ) {
144 range = prd_to_track_map.onTracks( *(ambi.first->second) );
145 // add them into the list
146 for ( ; range.first!=range.second; ++(range.first) )
147 connectedTracks.insert((range.first)->second);
148 }
149 }
150 }
151 }
152
153 // don't forget to remove the input track
154 connectedTracks.erase(&track);
155
156 ATH_MSG_VERBOSE("Added in connected tracks for track "<<&track
157 << "\tsize of list is "<<connectedTracks.size());
158
159 return connectedTracks;
160}
161
162
163std::vector< const Trk::PrepRawData* >
165 const Trk::Track& track) const
166{
167 ensureType(virt_prd_to_track_map);
168 PRDtoTrackMap &prd_to_track_map = static_cast<PRDtoTrackMap&>(virt_prd_to_track_map);
169 using PRDs_t = std::vector<const Trk::PrepRawData *>;
170
171 // test caching
172 Trk::PRDtoTrackMap::TrackPrepRawDataMap::const_iterator itvec = prd_to_track_map.m_trackPrepRawDataMap.find(&track);
173 if (itvec!=prd_to_track_map.m_trackPrepRawDataMap.end())
174 {
175 ATH_MSG_VERBOSE("found track in cache, return cached PRD vector for track");
176 return itvec->second;
177 }
178
179 if (track.measurementsOnTrack()==nullptr) {
180 ATH_MSG_WARNING("Track has no RoTs");
181 return {}; // return vector optimization
182 }
183
184 // FIXME can I do this without copying the vector?
185 /* transform(
186 track.measurementsOnTrack()->begin(),
187 track.measurementsOnTrack()->end() ,
188 back_inserter(vec),
189 bind2nd(CreatePRD_VectorFromTrack(), &track) );*/
190
191 // output vector
192 PRDs_t vec;
193 // size it
194 vec.reserve(track.measurementsOnTrack()->size());
195
196 // get the PRDs for the measurements on track
197 DataVector<const Trk::MeasurementBase>::const_iterator it = track.measurementsOnTrack()->begin();
198 DataVector<const Trk::MeasurementBase>::const_iterator itEnd = track.measurementsOnTrack()->end();
199 for (;it!=itEnd;++it)
200 {
201 const auto *const meas{*it};
203 const Trk::RIO_OnTrack* rot = static_cast<const Trk::RIO_OnTrack*>(meas);
204 if(rot->prepRawData()) vec.push_back(rot->prepRawData());
205 }
206 }
207 ATH_MSG_DEBUG(" Getting "<<vec.size()<<" PRDs from track at:"<<&track);
208 // new mode, we add the outliers in the TRT
209 if (m_addTRToutliers) {
210 // get the PRDs for the measurements on track
211 for (const Trk::MeasurementBase* meas : *track.outliersOnTrack()){
212 // get the ROT, make sure it is not a pseudo measurement
214 const Trk::RIO_OnTrack* rot = static_cast<const Trk::RIO_OnTrack*>(meas);
215 // check if outlier is TRT ?
217 // add to the list, it is TRT
218 if(rot->prepRawData()) vec.push_back(rot->prepRawData());
219 }
220 }
221 }
222 ATH_MSG_DEBUG(" Getting "<<vec.size()<<" PRDs including TRT outlier from track at:"<<&track);
223 }
224
225 return vec;
226}
227
234
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
std::vector< size_t > vec
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
Concrete Implementation of the IPRD_AssociationTool interface.
virtual std::unique_ptr< Trk::PRDtoTrackMap > reduceToStorableMap(std::unique_ptr< Trk::PRDtoTrackMap > &&obj_in) const override
virtual std::unique_ptr< Trk::PRDtoTrackMap > createPRDtoTrackMap() const override
BooleanProperty m_addTRToutliers
add TRT outliers in the addTrack method to avoid splits due to rejected extensions
virtual std::vector< const Trk::PrepRawData * > getPrdsOnTrack(Trk::PRDtoTrackMap &virt_prd_to_track_map, const Trk::Track &track) const override
returns a vector of PRDs belonging to the passed track.
SG::ReadHandleKey< PixelGangedClusterAmbiguities > m_pixelClusterAmbiguitiesMapName
virtual StatusCode addPRDs(Trk::PRDtoTrackMap &virt_prd_to_track_map, const Trk::Track &track) const override
add the PRDs from this track to the store
InDetPRDtoTrackMapToolGangedPixels(const std::string &, const std::string &, const IInterface *)
void ensureType(Trk::PRDtoTrackMap &virt_prd_to_track_map) const
virtual Trk::IPRDtoTrackMapTool::TrackSet findConnectedTracks(Trk::PRDtoTrackMap &virt_prd_to_track_map, const Trk::Track &track) const override
returns set of tracks which share PRD with this one
Property holding a SG store/key/clid from which a ReadHandle is made.
std::set< const Track * > TrackSet
This class is the pure abstract base class for all fittable tracking measurements.
PRDtoTrackMap()=default
PrepRawDataTrackMapRange onTracks(const PrepRawData &prd)
get the Tracks associated with this PrepRawData.
std::pair< PrepRawDataTrackMap::const_iterator, PrepRawDataTrackMap::const_iterator > ConstPrepRawDataTrackMapRange
TrackPrepRawDataMap m_trackPrepRawDataMap
holds the PRDs associated with each Track (i.e.
PrepRawDataTrackMap m_prepRawDataTrackMap
holds the tracks associated with each PRD (i.e.
virtual const std::type_info & getType() const
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
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.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
MsgStream & msg
Definition testRead.cxx:32