9#include "Acts/Utilities/VectorHelpers.hpp"
14 return angle / Gaudi::Units::deg;
18 std::ostringstream oss;
20 const double P {
muon.pt() * std::cosh(
muon.eta())};
21 const double momUncertainty {std::sqrt(
getQOverPCov(muon)*std::pow(
P,4))};
23 <<
", Pt: "<<
muon.pt()/Gaudi::Units::GeV<<
" GeV, Charge: "<<
muon.charge()
24 <<
", P: "<<
P/ Gaudi::Units::GeV<<
" += "<<momUncertainty/Gaudi::Units::GeV
31using namespace Acts::UnitLiterals;
32using namespace Muon::MuonStationIndex;
39 return StatusCode::SUCCESS;
53 auto firstSeg = inSegments->
stdcont().begin();
54 const auto lastSeg = inSegments->
stdcont().end();
55 while(firstSeg != lastSeg) {
59 const auto nextToLastSeg {std::find_if(firstSeg, lastSeg,
63 const std::span<const xAOD::MuonSegment* const> muonSegments {firstSeg, nextToLastSeg};
67 firstSeg = nextToLastSeg;
69 ATH_MSG_DEBUG(__func__<<
"() No muon candidate could be built from pattern " << *pattern);
73 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segLinks{};
75 segLinks.emplace_back(*inSegments, seg->index());
81 return StatusCode::SUCCESS;
86 std::span<const xAOD::MuonSegment* const> segments,
90 << segments.size()<<
" segments for pattern " << std::endl << pattern);
92 if (segments.size() < 2) {
93 ATH_MSG_DEBUG(__func__<<
"() Not enough muon segments to construct a candidate - abort.");
98 const std::vector<StIndex> stations {pattern.getStations()};
99 const unsigned nBarrelStations = std::ranges::count_if(stations,
104 MsTrackSeed trackSeed {nBarrelStations * 2u >= stations.size() ?
Barrel : Endcap,
105 pattern.expSector()};
111 Acts::Result<Acts::BoundTrackParameters> seedPars {
114 if (!seedPars.ok()) {
115 ATH_MSG_DEBUG(__func__<<
"() Failed to estimate seed parameters for track seed: " << trackSeed);
120 newMuon->
setAuthor(xAOD::Muon::Author::MuidSA);
121 newMuon->
setMuonType(xAOD::Muon::MuonType::MuonStandAlone);
125 Acts::VectorHelpers::eta(*seedPars),seedPars->phi());
128 std::optional<Acts::BoundMatrix> cov {seedPars->covariance()};
130 if (!cov || (*cov)(Acts::eBoundQOverP, Acts::eBoundQOverP) < Acts::s_epsilon) {
131 ATH_MSG_WARNING(__func__<<
"() No covariance matrix available for seed parameters of track seed: " << trackSeed);
137 qOverPCov = (*cov)(Acts::eBoundQOverP, Acts::eBoundQOverP) * conversionFactor;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
void print(char *figname, TCanvas *c1)
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
constexpr float inDeg(const float rad)
const PtrVector & stdcont() const
Return the underlying std::vector of the container.
Data class to represent an eta maximum in hough space.
void addSegment(const xAOD::MuonSegment *seg)
Append a segment to the seed.
Location
Enum defining whether the seed is made in the endcap / barrel.
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_qOverPCovKey
Muon decoration of the Q/P covariance.
xAOD::Muon * buildMuonCandidate(const EventContext &ctx, const GlobalPattern &pattern, std::span< const xAOD::MuonSegment *const > segments, MuonDataShip &outMuonData) const
Given the muon segments, it builds the standalone muon candidate, estimating the momentum and filling...
ToolHandle< ITrackSeedingTool > m_seedingTool
The track seeding tool to construct the seed candidates and to estimate the initial parameters.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_inSegments
Read handle key for the input segments.
virtual StatusCode initialize() override
SG::WriteHandleKey< xAOD::MuonContainer > m_outMuons
Write handle key for the output muon candidates.
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode record(const SG::WriteHandleKey< Cont_t > &key, const EventContext &ctx)
Record the container to store gate using the passed write handle key.
void setAuthor(const Author auth)
set author
void setMuonType(MuonType type)
void setMuonSegmentLinks(const std::vector< ElementLink< MuonSegmentContainer > > &segments)
Set the vector of ElementLinks to the MuonSegments used to create this Muon.
void setP4(double pt, double eta, double phi)
Set method for IParticle values.
void setCharge(float charge)
Set the charge (must be the same as primaryTrackParticle() ).
constexpr double energyToAthena(const double actsE)
Converts an energy scalar from Acts to Athena units.
const GlobalPattern * getParentPattern(const xAOD::MuonSegment &segment)
Retrieve the parent global pattern of the segment.
double getQOverPCov(const xAOD::Muon &muon)
Retrieve the Q/P covariance of the muon.
This header ties the generic definitions in this package.
std::string print(const cont_t &container)
Print a space point container to string.
StIndex
enum to classify the different station layers in the muon spectrometer
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Muon_v1 Muon
Reference the current persistent version:
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Data ship containing the muon container and the covariance decorator.
MuonCont_t muonContainer
The muon container.
xAOD::ContainerDecorator< xAOD::MuonContainer, float > dec_qOverPCov
The Q/P covariance decorator.