ATLAS Offline Software
Loading...
Searching...
No Matches
TrackingHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
7
8namespace{
10 using PrdLinkVec_t = std::vector<PrdLink_t>;
11 static const SG::ConstAccessor<PrdLinkVec_t> acc_prdLinks{"prdLinks"};
12 static const SG::ConstAccessor<std::vector<char>> acc_prdState{"prdState"};
13}
14
15namespace MuonR4{
16
17 std::string printID(const xAOD::MuonSegment& seg) {
18 using namespace Muon::MuonStationIndex;
19 return std::format("{:}{:}{:}{:}", chName(seg.chamberIndex()),
20 std::abs(seg.etaIndex()),
21 seg.etaIndex() > 0 ? 'A' : 'C',
22 seg.sector());
23 }
26 static const SG::ConstAccessor<SegLink_t> acc{"parentSegment"};
27 if (acc.isAvailable(seg)){
28 const SegLink_t& link{acc(seg)};
29 if (link.isValid()){
30 return *link;
31 }
32 }
33 return nullptr;
34 }
35
36 std::size_t nMeasurements(const xAOD::MuonSegment& segment) {
37 return acc_prdLinks.isAvailable(segment) ? acc_prdLinks(segment).size() : 0;
38 }
40 const std::size_t n) {
41 if (!acc_prdLinks.isAvailable(segment)) {
42 return nullptr;
43 }
44 assert(n < nMeasurements(segment));
45 const PrdLink_t& link{acc_prdLinks(segment)[n]};
46 return link.isValid() ? *link : nullptr;
47 }
49 const std::size_t n) {
50 if(!acc_prdState.isAvailable(segment)) {
51 return false;
52 }
53 assert (n < acc_prdState(segment).size());
54 return acc_prdState(segment)[n] != Acts::toUnderlying(CalibratedSpacePoint::State::Valid);
55 }
56 std::vector<const xAOD::UncalibratedMeasurement*> collectMeasurements(const xAOD::MuonSegment& segment,
57 bool skipOutlier) {
58 std::vector<const xAOD::UncalibratedMeasurement*> out{};
59 const PrdLinkVec_t& links{acc_prdLinks(segment)};
60 out.reserve(links.size());
61 for (std::size_t l = 0 ; l < links.size(); ++l) {
62 const PrdLink_t& link{links[l]};
63 if (!skipOutlier || !isOutlierMeasurement(segment, l)) {
64 out.push_back(*link);
65 }
66 }
67 return out;
68 }
69}
Placeholder for what will later be the muon segment EDM representation.
Helper class to provide constant type-safe access to aux data.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
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.
bool isOutlierMeasurement(const xAOD::MuonSegment &segment, const std::size_t n)
Returns whether the n-the uncalibrated measurement is an outlier.
ElementLink< MuonR4::SegmentContainer > SegLink_t
Abrivation of the link to the reco segment container.
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
MuonSegment_v1 MuonSegment
Reference the current persistent version:
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.