ATLAS Offline Software
Loading...
Searching...
No Matches
CorePixelSpacePointFormationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "Acts/SpacePointFormation/PixelSpacePointBuilder.hpp"
8#include "Acts/Surfaces/Surface.hpp"
9
11
12#include <algorithm>
13
14namespace ActsTrk {
15
23
24 StatusCode
26 const Acts::GeometryContext& gctx,
27 const xAOD::PixelCluster& cluster,
29 const InDetDD::SiDetectorElement& /*element*/) const
30 {
31 const xAOD::DetectorIDHashType idHash = cluster.identifierHash();
32 // The accessor is a call into libxAODInDetMeasurement, and the space point
33 // is filled with the same position the variances are computed from.
34 const auto globalPosition = cluster.globalPosition();
35 const Acts::SquareMatrix2 localCov = cluster.localCovariance<2>().cast<double>();
36
37 // Clusters come grouped by module: look up the surface only when the module changes.
38 auto lookupReferenceFrame = [this, &gctx, &cluster, idHash](Acts::RotationMatrix3& rot) -> StatusCode {
39 const Acts::Surface* surface = m_surfaceAccessor.get(&cluster);
40 if (surface == nullptr) {
41 ATH_MSG_FATAL("No ACTS surface for pixel cluster with identifier hash " << idHash);
42 return StatusCode::FAILURE;
43 }
44 // Position and direction are unused by plane and disc surfaces
45 rot = surface->referenceFrame(gctx, Acts::Vector3::Zero(), Acts::Vector3::Zero());
46 return StatusCode::SUCCESS;
47 };
48
49 // Returned in the order (z, r)
50 Acts::Vector2 variance;
52 SurfaceCache& cache = *m_surfaceCache.get(ctx);
53 if (cache.idHash != idHash or cache.evt != ctx.evt()) {
54 // Key updated only on success, so a failed look-up leaves no stale frame.
55 ATH_CHECK( lookupReferenceFrame(cache.rotLocalToGlobal) );
56 cache.idHash = idHash;
57 cache.evt = ctx.evt();
58 }
59 variance = Acts::PixelSpacePointBuilder::computeVarianceZR(cache.rotLocalToGlobal,
60 globalPosition.cast<double>(), localCov);
61 } else {
62 Acts::RotationMatrix3 rotLocalToGlobal;
63 ATH_CHECK( lookupReferenceFrame(rotLocalToGlobal) );
64 variance = Acts::PixelSpacePointBuilder::computeVarianceZR(rotLocalToGlobal,
65 globalPosition.cast<double>(), localCov);
66 }
67
68 float cov_z = static_cast<float>(variance[0]);
69 float cov_r = static_cast<float>(variance[1]);
70
71 if (m_useMaxVariance) {
72 cov_z = std::min(cov_z, m_maxVarianceZ.value());
73 cov_r = std::min(cov_r, m_maxVarianceR.value());
74 }
75
76 sp.setSpacePoint(idHash,
77 globalPosition,
78 cov_r,
79 cov_z,
80 std::vector< const xAOD::UncalibratedMeasurement* >({&cluster}));
81
82 return StatusCode::SUCCESS;
83 }
84}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x,...)
static Double_t sp
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
virtual StatusCode producePixelSpacePoint(const EventContext &ctx, const Acts::GeometryContext &gctx, const xAOD::PixelCluster &cluster, xAOD::SpacePoint &sp, const InDetDD::SiDetectorElement &element) const override
Gaudi::Property< bool > m_useMaxVariance
Cap the covariance terms, as PixelSpacePointFormationTool does.
ActsTrk::detail::xAODUncalibMeasSurfAcc m_surfaceAccessor
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
Class to hold geometrical description of a silicon detector element.
ConstVectorMap< 3 > globalPosition() const
Returns the global position of the pixel cluster.
ConstMatrixMap< N > localCovariance() const
Returns the local covariance of the measurement.
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash).
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
unsigned int DetectorIDHashType
@ detector ID element hash
Reference frame of the last module seen, keyed on the identifier hash and stamped with the event so a...