ATLAS Offline Software
Loading...
Searching...
No Matches
TrackingHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
12
13namespace{
15 using PrdLinkVec_t = std::vector<PrdLink_t>;
16 static const SG::ConstAccessor<PrdLinkVec_t> acc_prdLinks{"prdLinks"};
17 static const SG::ConstAccessor<std::vector<char>> acc_prdState{"prdState"};
18}
19
20namespace MuonR4{
21
22 std::string printID(const xAOD::MuonSegment& seg) {
23 using namespace Muon::MuonStationIndex;
24 return std::format("{:}{:}{:}{:}", chName(seg.chamberIndex()),
25 std::abs(seg.etaIndex()),
26 seg.etaIndex() > 0 ? 'A' : 'C',
27 seg.sector());
28 }
31 static const SG::ConstAccessor<SegLink_t> acc{"parentSegment"};
32 if (acc.isAvailable(seg)){
33 const SegLink_t& link{acc(seg)};
34 if (link.isValid()){
35 return *link;
36 }
37 }
38 return nullptr;
39 }
40
41 std::size_t nMeasurements(const xAOD::MuonSegment& segment) {
42 return acc_prdLinks.isAvailable(segment) ? acc_prdLinks(segment).size() : 0;
43 }
45 const std::size_t n) {
46 if (!acc_prdLinks.isAvailable(segment)) {
47 return nullptr;
48 }
49 assert(n < nMeasurements(segment));
50 const PrdLink_t& link{acc_prdLinks(segment)[n]};
51 return link.isValid() ? *link : nullptr;
52 }
54 const std::size_t n) {
55 if(!acc_prdState.isAvailable(segment)) {
56 return false;
57 }
58 assert (n < acc_prdState(segment).size());
59 return acc_prdState(segment)[n] != Acts::toUnderlying(CalibratedSpacePoint::State::Valid);
60 }
61 std::vector<const xAOD::UncalibratedMeasurement*> collectMeasurements(const xAOD::MuonSegment& segment,
62 bool skipOutlier) {
63 std::vector<const xAOD::UncalibratedMeasurement*> out{};
64 const PrdLinkVec_t& links{acc_prdLinks(segment)};
65 out.reserve(links.size());
66 for (std::size_t l = 0 ; l < links.size(); ++l) {
67 const PrdLink_t& link{links[l]};
68 if (!skipOutlier || !isOutlierMeasurement(segment, l)) {
69 out.push_back(*link);
70 }
71 }
72 return out;
73 }
74 Acts::GeometryIdentifier volumeId(const Acts::Surface& surface) {
75 return surface.geometryId().withSensitive(0).withBoundary(0);
76 }
77
79 const bool skipOutlier) {
80 const std::size_t n = nMeasurements(segment);
81 for (std::size_t i = 0; i < n ; ++i) {
82 if (!skipOutlier || !isOutlierMeasurement(segment, i)) {
83 return getMeasurement(segment, i);
84 }
85 }
86 return nullptr;
87 }
88
89 Amg::Vector3D atFirstSurface(const Acts::GeometryContext& gctx,
90 const xAOD::MuonSegment& segment,
91 const bool skipOutlier) {
92 const xAOD::UncalibratedMeasurement* meas{firstMeasurement(segment, skipOutlier)};
93 assert(meas != nullptr);
94 const Acts::Surface& surface = xAOD::muonSurface(meas);
95
96 const Acts::MultiIntersection isect = surface.intersect(gctx,
97 segment.position(),
98 segment.direction(),
99 Acts::BoundaryTolerance::Infinite());
100 return isect.at(0).position();
101 }
102
104 const xAOD::IParticle* b) const {
105
106 if (const float dPt = a->pt() - b->pt();
107 std::abs(dPt) > std::numeric_limits<float>::epsilon()) {
108 return dPt < 0.;
109 }
110 if (const float dEta = a->eta() - b->eta();
111 std::abs(dEta) > std::numeric_limits<float>::epsilon()) {
112 return dEta < 0.;
113 }
114 const float dPhi = xAOD::P4Helpers::deltaPhi(a, b);
115 return dPhi < 0.;
116 }
117}
static Double_t a
size_t size() const
Number of registered mappings.
Placeholder for what will later be the muon segment EDM representation.
Helper class to provide constant type-safe access to aux data.
Class providing the definition of the 4-vector interface.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
std::vector< PrdLink_t > PrdLinkVec_t
Abrivation of a collection of Prd links.
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
const xAOD::UncalibratedMeasurement * getMeasurement(const xAOD::MuonSegment &segment, const std::size_t n)
Returns the n-th uncalibrated measurement.
std::size_t nMeasurements(const xAOD::MuonSegment &segment)
Returns the number of associated Uncalibrated measurements.
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const xAOD::MuonSegment &segment, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
Acts::GeometryIdentifier volumeId(const Acts::Surface &surface)
Returns the identifier of the volume in which the surface is embedded.
bool isOutlierMeasurement(const xAOD::MuonSegment &segment, const std::size_t n)
Returns whether the n-the uncalibrated measurement is an outlier.
const xAOD::UncalibratedMeasurement * firstMeasurement(const xAOD::MuonSegment &segment, const bool skipOutlier=true)
Retrieves the first measurement associated with the segment.
ElementLink< MuonR4::SegmentContainer > SegLink_t
Abrivation of the link to the reco segment container.
Amg::Vector3D atFirstSurface(const Acts::GeometryContext &gctx, const xAOD::MuonSegment &segment, const bool skipOutlier=true)
Expresses the segment position on the surface of the first measurement.
ElementLink< PrdCont_t > PrdLink_t
Abrivation to call the link to an element inside an uncalibrated measurement container.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
const std::string & chName(ChIndex index)
convert ChIndex into a string
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
bool operator()(const xAOD::IParticle *a, const xAOD::IParticle *b) const