ATLAS Offline Software
Loading...
Searching...
No Matches
MuonLayerSegmentMatchingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11namespace Muon {
12
13 MuonLayerSegmentMatchingTool::MuonLayerSegmentMatchingTool(const std::string& type, const std::string& name, const IInterface* parent) :
14 AthAlgTool(type, name, parent) {
15 declareInterface<IMuonLayerSegmentMatchingTool>(this);
16 }
17
19 ATH_CHECK(m_printer.retrieve());
20 ATH_CHECK(m_extrapolator.retrieve());
21 ATH_CHECK(m_matchingTool.retrieve());
22 return StatusCode::SUCCESS;
23 }
24
26 const MuonSegment& segment) const {
27 if (msgLvl(MSG::VERBOSE)) {
28 std::shared_ptr<const Trk::TrackParameters> pars = intersection.trackParameters;
29 msg(MSG::VERBOSE) << " startPars: phi " << pars->position().phi() << " r " << pars->position().perp() << " z "
30 << pars->position().z() << " local " << pars->parameters()[Trk::locX] << " " << pars->parameters()[Trk::locY];
31 if (pars->covariance())
32 msg(MSG::VERBOSE) << " err " << Amg::error(*pars->covariance(), Trk::locX) << " "
33 << Amg::error(*pars->covariance(), Trk::locY);
34 msg(MSG::VERBOSE) << endmsg;
35 }
36
37 std::shared_ptr<Trk::TrackParameters> exPars(m_extrapolator->extrapolate(
38 ctx, *intersection.trackParameters, segment.associatedSurface(), Trk::anyDirection, false, Trk::muon));
39 if (!exPars) {
40 ATH_MSG_VERBOSE(" extrapolation failed ");
41 return false;
42 }
43
44 std::shared_ptr<Trk::AtaPlane> ataPlane = std::dynamic_pointer_cast<Trk::AtaPlane>(exPars);
45 if (!ataPlane) {
46 Trk::TrackParameters* p = exPars.get(); // avoid clang warning.
47 ATH_MSG_WARNING(" dynamic_cast<> failed "<<typeid(*p).name()<<std::endl<<segment.associatedSurface()<<std::endl<<std::endl<<(*intersection.trackParameters));
48 return false;
49 }
50 if (msgLvl(MSG::VERBOSE)) {
51 msg(MSG::VERBOSE) << " Segment r " << segment.globalPosition().perp() << " z " << segment.globalPosition().z() << " local "
52 << segment.localParameters()[Trk::locX] << " " << segment.localParameters()[Trk::locY] << " err "
53 << Amg::error(segment.localCovariance(), Trk::locX) << " " << Amg::error(segment.localCovariance(), Trk::locY)
54 << " extrapolation r " << ataPlane->position().perp() << " z " << ataPlane->position().z() << " local "
55 << ataPlane->parameters()[Trk::locX] << " " << ataPlane->parameters()[Trk::locY];
56 if (ataPlane->covariance())
57 msg(MSG::VERBOSE) << " err " << Amg::error(*ataPlane->covariance(), Trk::locX) << " "
58 << Amg::error(*ataPlane->covariance(), Trk::locY);
59 msg(MSG::VERBOSE) << endmsg;
60 }
61
62 MuonCombined::MuonSegmentInfo segmentInfo = m_matchingTool->muTagSegmentInfo(ctx, nullptr, segment, ataPlane);
63 if (!m_matchingTool->matchSegmentPosition(segmentInfo, true)) {
64 ATH_MSG_DEBUG(" position match failed ");
65 return false;
66 }
67 if (!m_matchingTool->matchSegmentDirection(segmentInfo, true)) {
68 ATH_MSG_DEBUG(" direction match failed ");
69 return false;
70 }
71 if (!m_matchingTool->matchDistance(segmentInfo)) {
72 ATH_MSG_DEBUG(" distance match failed ");
73 return false;
74 }
75 if (!m_matchingTool->matchCombinedPull(segmentInfo)) {
76 ATH_MSG_DEBUG(" combined pull match failed ");
77 return false;
78 }
79 return true;
80 }
81
83 const std::vector<std::shared_ptr<const Muon::MuonSegment> >& segments,
84 std::vector<std::shared_ptr<const Muon::MuonSegment> >& selectedSegments) const {
85 // loop over segments and match them to the intersection
86 for (const std::shared_ptr<const Muon::MuonSegment>& segment : segments) {
87 if (match(ctx, intersection, *segment)) { selectedSegments.push_back(segment); }
88 }
89 ATH_MSG_DEBUG("Selected segments: " << selectedSegments.size());
90 }
91
92} // namespace Muon
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
ToolHandle< Trk::IExtrapolator > m_extrapolator
void select(const EventContext &ctx, const MuonSystemExtension::Intersection &intersection, const std::vector< std::shared_ptr< const Muon::MuonSegment > > &segments, std::vector< std::shared_ptr< const Muon::MuonSegment > > &selectedSegments) const override
IMuonLayerSegmentMatchingTool interface: select.
MuonLayerSegmentMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
Default AlgTool functions.
ToolHandle< IMuTagMatchingTool > m_matchingTool
PublicToolHandle< MuonEDMPrinterTool > m_printer
Helper tool for debugging purposes.
bool match(const EventContext &ctx, const MuonSystemExtension::Intersection &intersection, const MuonSegment &segment) const override
match segment to intersection
This is the common class for 3D segments used in the muon spectrometer.
virtual const Amg::Vector3D & globalPosition() const override final
global position
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
@ anyDirection
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
ParametersBase< TrackParametersDim, Charged > TrackParameters