15#include "Acts/Surfaces/PlaneSurface.hpp"
16#include "Acts/Definitions/Units.hpp"
21using namespace Acts::UnitLiterals;
26 return s.nPrecisionHits() +
s.nTrigEtaLayers() +
s.nPhiLayers() +
27 s.nPrecisionOutliers() +
s.nTriggerEtaOutliers() +
s.nTriggerPhiOutliers();
37 return StatusCode::SUCCESS;
40 std::vector<MsTrackSeed>& outSeeds)
const {
43 std::unordered_map<const xAOD::TruthParticle*, std::vector<const xAOD::MuonSegment*>> truthSeeds{};
47 if (truthPart && truthPart->
isMuon()) {
48 truthSeeds[truthPart].push_back(seg);
51 for (
auto& [truthPart, assocSegs] : truthSeeds) {
53 if (
a->chamberIndex() != b->chamberIndex()) {
54 return a->chamberIndex() < b->chamberIndex();
56 return countHits(*
a) > countHits(*b);
60 return a->chamberIndex() == b->chamberIndex();
62 assocSegs.erase(begin,end);
63 if (assocSegs.size() < 2) {
73 return StatusCode::SUCCESS;
76 Acts::Result<Acts::BoundTrackParameters>
80 const Acts::GeometryContext tgContext{
m_ctxProvider.getGeometryContext(ctx)};
89 ATH_MSG_WARNING(__func__<<
"() "<<__LINE__<<
" - No truth segment found");
90 return Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument));
94 const double distA = firstSurf.intersect(tgContext, truthSeg->
position(), truthSeg->
direction()).closest().pathLength();
95 const double distB = secondSurf.intersect(tgContext, truthSeg->
position(), truthSeg->
direction()).closest().pathLength();
96 ATH_MSG_VERBOSE(__func__<<
" "<<__LINE__<<
" - Detected segments in sector overlap "
98 <<
". Check whether they need to be swapped "<<distA<<
" vs. "<<distB);
105 ATH_MSG_WARNING(__func__<<
"() "<<__LINE__<<
" - No truth segment found");
106 return Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument));
110 ATH_MSG_WARNING(__func__<<
"() "<<__LINE__<<
" - No truth particle found");
111 return Acts::Result<Acts::BoundTrackParameters>::failure(std::make_error_code(std::errc::invalid_argument));
116 const Acts::Surface& sectorSurf{msSector->
surface()};
122 const auto& oldTrf = sectorSurf.localToGlobalTransform(tgContext);
124 const Amg::Vector3D locDir = oldTrf.inverse().linear() * segDir;
125 const double pathLength = std::abs((truthSeg->
position() - firstPos).dot(segDir)) + 10._cm;
130 auto shiftedSurf = Acts::Surface::makeShared<Acts::PlaneSurface>(newTrf);
135 Acts::BoundTrackParameters result{shiftedSurf, locPars,
136 Acts::BoundMatrix::Identity(),
137 Acts::ParticleHypothesis::muon()};
138 using namespace Acts::detail::LineHelper;
139 if (msgLvl(MSG::VERBOSE)) {
140 std::stringstream outStream{};
141 outStream<<
"Start parameters:\n"<<result<<
",\n"
142 <<result.referenceSurface().toString(tgContext)
143 <<
"absolute momentum: "
145 <<
", start point closure: "<<(result.position(tgContext) + pathLength * segDir - truthSeg->
position()).mag()
146 <<
", angle closure: "<<
Amg::angle(result.direction(), segDir) / 1._degree
147 <<
"\n\ndump measurements:\n";
159 const double dist{surf.intersect(tgContext, result.position(tgContext), segDir,
160 Acts::BoundaryTolerance::Infinite()).closest().pathLength()};
161 outStream<<
" *** "<<
m_detMgr->idHelperSvc()->toString(mMeas->identify())
162 <<
" @ "<<
Amg::toString(surf.localToGlobalTransform(tgContext) * mMeas->localMeasurementPos())
164 <<
", travelled distance: "<<dist<<std::endl;
167 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Created start parameters:\n"<<outStream.str());
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
Handle class for reading from StoreGate.
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the IdHelpeSvc.
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
const Acts::PlaneSurface & surface() const
Returns the associated surface.
virtual std::string toString(const Identifier &id) const =0
print all fields to string
Helper class to provide constant type-safe access to aux data.
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 ).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
bool isMuon() const
Whether the particle is a muon (or antimuon).
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
constexpr double energyToActs(const double athenaE)
Converts an energy scalar from Athena to Acts units.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Isometry3d Isometry3D
double angle(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
calculates the opening angle between two vectors
Amg::Isometry3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Eigen::Matrix< double, 3, 1 > Vector3D
Acts::BoundTrackParameters boundSegmentPars(const ActsTrk::GeometryContext &gctx, const MuonGMR4::MuonDetectorManager &detMgr, const xAOD::MuonSegment &segment, const Acts::ParticleHypothesis hypot=Acts::ParticleHypothesis::muon())
Returns the segment parameters as boundTrackParameters.
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
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.
const xAOD::UncalibratedMeasurement * firstMeasurement(const xAOD::MuonSegment &segment, const bool skipOutlier=true)
Retrieves the first measurement associated with the segment.
const xAOD::MuonSegment * getMatchedTruthSegment(const xAOD::MuonSegment &segment)
Returns the truth-matched segment.
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.
StIndex toStationIndex(ChIndex index)
convert ChIndex into StIndex
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonMeasurement_v1 MuonMeasurement
TruthParticle_v1 TruthParticle
Typedef to implementation.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.