ATLAS Offline Software
Loading...
Searching...
No Matches
MsTrackSeed.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include "Acts/Utilities/MathHelpers.hpp"
11
12#include <format>
13
14
15
16namespace MuonR4 {
17
18 std::ostream& operator<<(std::ostream& ostr, const MuonR4::MsTrackSeed& seed) {
19 ostr<<"MS Track seed @"<<Amg::toString(seed.position())<<", sector: "<<seed.sector() << ", location: "<< Acts::toUnderlying(seed.location())<< std::endl;
20 using namespace Muon::MuonStationIndex;
21 for (const xAOD::MuonSegment* seg : seed.segments()) {
22 ostr<<" **** "<< printID(*seg)
23 <<", theta: "<<(seg->direction().theta() /Gaudi::Units::degree)
24 <<", phi: "<<(seg->direction().phi() /Gaudi::Units::degree)
25 <<", R: "<<Acts::fastHypot(seg->x(), seg->y())
26 <<", Z: "<<seg->z()<<" "<<(seg->position().theta() / Gaudi::Units::degree)
27 // <<", "<<SegmentFit::toString(SegmentFit::localSegmentPars(*seg))
28 <<", chi2: "<<(seg->chiSquared() / std::max(seg->numberDoF(), 1.f))
29 <<", nPrec: "<<seg->nPrecisionHits()
30 <<", nPhi: "<<seg->nPhiLayers()
31 <<", nTrigEta: "<<seg->nTrigEtaLayers();
32
33 const xAOD::MuonSegment* truthSeg{getMatchedTruthSegment(*seg)};
34 if(truthSeg){
35 ostr << " truth theta " << (truthSeg->direction().theta() / Gaudi::Units::degree)
36 << " truth phi " << (truthSeg->direction().phi() / Gaudi::Units::degree);
37 }
38
39 ostr <<std::endl;
40 }
41 return ostr;
42 }
43 std::string MsTrackSeed::toString(const Location loc) {
44 switch (loc) {
45 using enum Location;
46 case Undefined: return "Undefined";
47 case Barrel: return "Barrel";
48 case Endcap: return "Endcap";
49 }
50 return "";
51 }
55 std::vector<const SpacePointBucket*> MsTrackSeed::buckets() const {
56 std::vector<const SpacePointBucket*> returnMe{};
57 for (const Segment* seg : detailedSegments()){
58 returnMe.push_back(seg->parent()->parentBucket());
59 }
60 return returnMe;
61 }
62
63 const std::vector<const xAOD::MuonSegment*>& MsTrackSeed::segments() const { return m_segments; }
64 std::vector<const Segment*> MsTrackSeed::detailedSegments() const {
65 std::vector<const Segment*> segs{};
66 segs.reserve(segments().size());
67 for (const xAOD::MuonSegment* trfMe : segments()) {
68 if(const Segment* seg = detailedSegment(*trfMe); seg != nullptr){
69 segs.push_back(seg);
70 }
71 }
72 return segs;
73 }
75 const xAOD::MuonSegment* updated) {
76 std::vector<const xAOD::MuonSegment*>::iterator itr =
77 std::ranges::find(m_segments, exist);
78 if (itr == m_segments.end()){
79 THROW_EXCEPTION("The exisiting segment could not be found");
80 }
81 (*itr) = updated;
82 }
84 const float r2 = Acts::hypotSquare(seg->x(), seg->y(), seg->z());
85 auto insert_itr = std::ranges::find_if(m_segments,
86 [&r2](const xAOD::MuonSegment* added){
87 return r2 < Acts::hypotSquare(added->x(), added->y(), added->z());
88 });
89 m_segments.insert(insert_itr, seg);
90 }
91 const Amg::Vector3D& MsTrackSeed::position() const { return m_pos; }
92 void MsTrackSeed::setPosition(Amg::Vector3D&& pos) { m_pos = std::move(pos); }
93
94}
95
Scalar phi() const
phi method
Scalar theta() const
theta method
@ Undefined
size_t size() const
Number of registered mappings.
ExpandedSector m_sector
Definition MsTrackSeed.h:67
const Amg::Vector3D & position() const
Returns the seed's position.
void addSegment(const xAOD::MuonSegment *seg)
Append a segment to the seed.
Location m_loc
Location variable.
Definition MsTrackSeed.h:66
MsTrackSeed(const Location loc, const ExpandedSector sector)
Constructor with location defintion.
std::vector< const Segment * > detailedSegments() const
Returns the list of detailed segments.
std::vector< const SpacePointBucket * > buckets() const
Returns the list of associated buckets.
Location location() const
Returns the location of the seed.
Location
Enum defining whether the seed is made in the endcap / barrel.
Definition MsTrackSeed.h:25
ExpandedSector sector() const
Returns the seed's sector.
Definition MsTrackSeed.h:63
Amg::Vector3D m_pos
Definition MsTrackSeed.h:68
static std::string toString(const Location loc)
std::vector< const xAOD::MuonSegment * > m_segments
Definition MsTrackSeed.h:69
const std::vector< const xAOD::MuonSegment * > & segments() const
Returns the vector of associated segments.
void replaceSegment(const xAOD::MuonSegment *exist, const xAOD::MuonSegment *updated)
Replaces an already added segment in the seed with a better suited one.
void setPosition(Amg::Vector3D &&pos)
set the seed's position
Placeholder for what will later be the muon segment EDM representation.
float y() const
Returns the x position.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
float z() const
Returns the y position.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
std::ostream & operator<<(std::ostream &ostr, const MuonR4::MsTrackSeed &seed)
const xAOD::MuonSegment * getMatchedTruthSegment(const xAOD::MuonSegment &segment)
Returns the truth-matched segment.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10