Execute method.
113{
115 std::unique_ptr<Trk::PRDtoTrackMap> prd_to_track_map(
m_assoTool->createPRDtoTrackMap());
116
118 if (!tracks.isValid()) {
120 return StatusCode::FAILURE;
121 }
122
123
125 if (!siHits.isValid()) {
127 return StatusCode::FAILURE;
128 }
129
130
132 if (!sdoCollection.isValid()) {
134 return StatusCode::FAILURE;
135 }
136
137
138 SG::ReadHandle<TrackTruthCollection> truthMap(
m_truthMapName, ctx);
139 if (!truthMap.isValid()) {
141 return StatusCode::FAILURE;
142 }
143
144
145 std::vector<std::unique_ptr<Trk::Track> > newtracks;
146
147
150
151
153 double od0(0);
154 double oz0(0);
155 double ophi0(0);
156 double otheta(0);
157 double oqOverP(0);
158 if (!origPerigee){
160 }
161 else if (
msgLvl(MSG::DEBUG)) {
162 od0 = origPerigee->parameters()[
Trk::d0];
163 oz0 = origPerigee->parameters()[
Trk::z0];
164 ophi0 = origPerigee->parameters()[
Trk::phi0];
165 otheta = origPerigee->parameters()[
Trk::theta];
167 ATH_MSG_DEBUG (
"Original parameters " << od0 <<
" " << oz0 <<
" " << ophi0 <<
" " << otheta <<
" " << oqOverP);
168 }
169
170
171 float minProb(0);
172
173
174 ElementLink<TrackCollection> tracklink;
175 tracklink.
setElement(
const_cast<Trk::Track*
>(*itr));
177 const ElementLink<TrackCollection> tracklink2=tracklink;
178
179 TrackTruthCollection::const_iterator
found = truthMap->find(tracklink2);
180 if ( found == truthMap->end() ) { continue; }
181 if ( !
found->second.particleLink().isValid() ) {
continue; }
182 if (
found->second.probability() < minProb ) {
continue; }
185
186
187 std::vector<const Trk::MeasurementBase*> measurementSet;
188 std::vector<const Trk::MeasurementBase*> trash;
189
190 ATH_MSG_DEBUG (
"Loop over measurementsOnTrack " << (*itr)->measurementsOnTrack()->size() );
191 for (const auto *measurement : *((*itr)->measurementsOnTrack())) {
193
194
195 const Trk::RIO_OnTrack* rio = dynamic_cast <const Trk::RIO_OnTrack*>( measurement );
196 if (rio == nullptr) {
197 ATH_MSG_WARNING(
"Cannot get RIO_OnTrack from measurement. Hit will NOT be included in track fit.");
198 continue;
199 }
200
201
202 const Identifier& surfaceID = (rio->
identify()) ;
204 measurementSet.push_back( measurement );
205 continue;
206 }
207
208
209 const InDet::PixelCluster* pix =
dynamic_cast<const InDet::PixelCluster*
>(rio->
prepRawData());
210 if (pix == nullptr) {
212 continue;
213 }
214
216 const InDetDD::SiDetectorDesign* design =
static_cast<const InDetDD::SiDetectorDesign*
>(&element->
design());
217
218 Identifier clusterId = pix->
identify();
220 int layer_disk =
m_pixelID->layer_disk(clusterId);
221
222
223
225
226
227
228
229
230
231
232 double maxEnergyDeposit(-1);
233 SiHit maxEDepSiHit;
234
235 if ( !hasSDOMatch ) {
237
240 if( matchedSiHits.empty() ) {
241 if( !
m_rejNoiseHits ) { measurementSet.push_back( measurement ); }
242 continue;
243 }
245 for( const auto& siHit : matchedSiHits ) {
246 if (siHit.energyLoss() > maxEnergyDeposit) {
247 maxEnergyDeposit = siHit.energyLoss();
248 maxEDepSiHit = siHit;
249 }
250 }
251 } else {
252 measurementSet.push_back( measurement );
253 continue;
254 }
255 } else {
256
258 if( matchedSiHits.empty() ) {
260 continue;
261 }
262 ATH_MSG_DEBUG (
"N SiHit matching cluster: " << matchedSiHits.size());
263
264
265
266 for( const auto& siHit : matchedSiHits ) {
267 if (siHit.energyLoss() > maxEnergyDeposit) {
268 maxEnergyDeposit = siHit.energyLoss();
269 maxEDepSiHit = siHit;
270 }
271 }
272 }
273
274
275
278
279
280
281
282
283
284 HepGeom::Point3D<double> smearedPosition =
smearTruthPosition( averagePosition, bec, layer_disk, design );
286
289
290 Trk::LocalParameters locpar = element->
hitLocalToLocal(smearedPosition.z(), smearedPosition.y());
292
295
296 InDet::SiWidth pixWidth = pix->
width();
298
299
300
301 if(bec!=0) layer_disk++;
302 if(pixWidth.
phiR()>0) {
306 } else {
308 }
309
314 } else {
316 }
317
319
320 InDet::PixelClusterOnTrack* pcot = new InDet::PixelClusterOnTrack(pix,std::move(locpar),std::move(cov),iH,globPos,
322 false);
323
324 if(pcot) {
325 measurementSet.push_back( pcot);
326 trash.push_back(pcot);
327 } else {
329 }
330
331 }
332
333
334
335 ATH_MSG_DEBUG (
"Fit new tracks with measurementSet : " << measurementSet.size());
336 std::unique_ptr<Trk::Track> newtrack;
337 try {
339 measurementSet,
340 *origPerigee,
343 }
344 catch(const std::exception& e) {
345 ATH_MSG_ERROR (
"Refit Logic Error. No new track. Message: " <<
e.what());
346 newtrack = nullptr;
347 }
348
350
353 else {
354
356 const Trk::Perigee* aMeasPer = newtrack->perigeeParameters();
357 if (aMeasPer==nullptr){
359 } else {
360 double d0 = aMeasPer->parameters()[
Trk::d0];
361 double z0 = aMeasPer->parameters()[
Trk::z0];
366 << (od0-
d0)/od0 <<
" "
367 << (oz0-
z0)/oz0 <<
" "
368 << (ophi0-
phi0)/ophi0 <<
" "
369 << (otheta-
theta)/otheta <<
" "
370 << (oqOverP-
qOverP)/oqOverP );
371 }
372 }
373 }
374
375 if (newtrack) { newtracks.push_back(std::move(newtrack)); }
377
378 }
379
381
382
383 for(const std::unique_ptr<Trk::Track> &new_track : newtracks ) {
385 }
386
388
389 std::unique_ptr<TrackCollection> new_track_collection = std::make_unique<TrackCollection>();
390 new_track_collection->reserve(newtracks.size());
391 for(std::unique_ptr<Trk::Track> &new_track : newtracks ) {
393 new_track_collection->push_back(std::move(new_track));
394 }
395
398
399 ATH_MSG_INFO (
"ReFitTrackWithTruth::execute() completed");
400 return StatusCode::SUCCESS;
401}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
bool setElement(ElementType element)
Set link to point to an Element (slowest).
bool setStorableObject(BaseConstReference data, bool replace=false)
Set link storable to data object pointed by data (slower).
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
Amg::Vector2D hitLocalToLocal(double xEta, double xPhi) const
Simulation/Hit local frame to reconstruction local frame.
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
const InDet::SiWidth & width() const
return width class reference
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
HepGeom::Point3D< double > localStartPosition() const
HepGeom::Point3D< double > localEndPosition() const
double get(ParamDefs par) const
Retrieve specified parameter (const version).
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
Identifier identify() const
return the identifier -extends MeasurementBase
Gaudi::Property< bool > m_rejNoiseHits
SG::ReadHandleKey< InDetSimDataCollection > m_SDOContainerName
Trk::RunOutlierRemoval m_runOutlier
double getEtaPosErrorFactor(int layer) const
static bool IsClusterFromTruth(const InDet::PixelCluster *pixClus, const int uniqueIdToMatch, const InDetSimDataCollection &sdoCollection)
Gaudi::Property< bool > m_fixWrongHits
SG::ReadHandleKey< TrackTruthCollection > m_truthMapName
const PixelID * m_pixelID
Pixel ID.
std::vector< SiHit > matchSiHitsToCluster(const int uniqueIdToMatch, const InDet::PixelCluster *pixClus, SG::ReadHandle< AtlasHitsVector< SiHit > > &siHitCollection) const
Trk::ParticleHypothesis m_ParticleHypothesis
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
the track summary tool
SG::ReadHandleKey< SiHitCollection > m_siHitCollectionName
SG::ReadHandleKey< TrackCollection > m_inputTrackColName
const AtlasDetectorID * m_idHelper
Detector ID helper.
ToolHandle< Trk::IPRDtoTrackMapTool > m_assoTool
Tool to create and populate PRD to track.
double getEtaPosResolution(int layer) const
Gaudi::Property< bool > m_saveWrongHits
double getPhiPosResolution(int layer) const
SG::WriteHandleKey< TrackCollection > m_outputTrackCollectionName
double getPhiPosErrorFactor(int layer) const
HepGeom::Point3D< double > smearTruthPosition(const HepGeom::Point3D< double > &orig, const int bec, const int layer_disk, const InDetDD::SiDetectorDesign *design) const
ToolHandle< Trk::ITrackFitter > m_ITrackFitter
the refit tool
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ loc2
generic first and second local coordinate
ParametersBase< TrackParametersDim, Charged > TrackParameters