ATLAS Offline Software
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 
11 namespace Muon {
12 
13  MuonLayerSegmentMatchingTool::MuonLayerSegmentMatchingTool(const std::string& type, const std::string& name, const IInterface* 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);
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);
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
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
MuonCombined::MuonSegmentInfo
Definition: MuonSegmentInfo.h:23
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrackParameters.h
Trk::locX
@ locX
Definition: ParamDefs.h:43
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
Muon::MuonLayerSegmentMatchingTool::m_matchingTool
ToolHandle< IMuTagMatchingTool > m_matchingTool
Definition: MuonLayerSegmentMatchingTool.h:46
EventPrimitivesHelpers.h
Muon::MuonLayerSegmentMatchingTool::MuonLayerSegmentMatchingTool
MuonLayerSegmentMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
Default AlgTool functions.
Definition: MuonLayerSegmentMatchingTool.cxx:13
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
Muon::MuonLayerSegmentMatchingTool::select
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.
Definition: MuonLayerSegmentMatchingTool.cxx:82
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::MuonLayerSegmentMatchingTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: MuonLayerSegmentMatchingTool.h:44
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::muon
@ muon
Definition: ParticleHypothesis.h:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::MuonLayerSegmentMatchingTool::initialize
StatusCode initialize() override
Definition: MuonLayerSegmentMatchingTool.cxx:18
MuonLayerSegmentMatchingTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Muon::MuonLayerSegmentMatchingTool::match
bool match(const EventContext &ctx, const MuonSystemExtension::Intersection &intersection, const MuonSegment &segment) const override
match segment to intersection
Definition: MuonLayerSegmentMatchingTool.cxx:25
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
MuonSegment.h
Muon::MuonSystemExtension::Intersection
data per intersection
Definition: MuonSystemExtension.h:21
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonLayerSegmentMatchingTool::m_printer
PublicToolHandle< MuonEDMPrinterTool > m_printer
Helper tool for debugging purposes.
Definition: MuonLayerSegmentMatchingTool.h:42
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5