ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuonSegmentFittingTool Class Reference

Implementation of an IMuonSegmentFittingTool. More...

#include <MuonSegmentFittingTool.h>

Inheritance diagram for Muon::MuonSegmentFittingTool:
Collaboration diagram for Muon::MuonSegmentFittingTool:

Public Member Functions

 MuonSegmentFittingTool (const std::string &, const std::string &, const IInterface *)
virtual ~MuonSegmentFittingTool ()=default
virtual StatusCode initialize ()
Trk::Trackfit (const Amg::Vector3D &gpos, const Amg::Vector3D &gdir, const Trk::PlaneSurface &surf, const std::vector< const Trk::MeasurementBase * > &rioVec) const
 fit segment parameters + hits producing a track
Trk::Trackfit (const MuonSegment &segment) const
 fit segment parameters + hits producing a track
void updateSegmentParameters (const Trk::Track &track, const Trk::PlaneSurface &surf, Amg::Vector2D &segLocPos, Trk::LocalDirection &segLocDir, Amg::MatrixX &locerr) const
 update the parameters of the segment using the track information
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 access to tool interface

Public Attributes

Trk::MagneticFieldProperties m_magFieldProperties
ToolHandle< Trk::IPropagatorm_slPropagator
ToolHandle< Trk::ITrackFitterm_slTrackFitter
ToolHandle< Trk::ITrackFitterm_curvedTrackFitter
ToolHandle< Muon::IMuonTrackCleanerm_trackCleaner
bool m_updatePrecisionCoordinate

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonSegmentFittingTool()

Muon::MuonSegmentFittingTool::MuonSegmentFittingTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 26 of file MuonSegmentFittingTool.cxx.

26 :
28 declareInterface<IMuonSegmentFittingTool>(this);
29 declareProperty("UpdatePrecisionCoordinate", m_updatePrecisionCoordinate = false);
30 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Trk::MagneticFieldProperties m_magFieldProperties
@ NoField
Field is set to 0., 0., 0.,.

◆ ~MuonSegmentFittingTool()

virtual Muon::MuonSegmentFittingTool::~MuonSegmentFittingTool ( )
virtualdefault

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ fit() [1/2]

Trk::Track * Muon::MuonSegmentFittingTool::fit ( const Amg::Vector3D & gpos,
const Amg::Vector3D & gdir,
const Trk::PlaneSurface & surf,
const std::vector< const Trk::MeasurementBase * > & rioVec ) const
virtual

fit segment parameters + hits producing a track

Implements Muon::IMuonSegmentFittingTool.

Definition at line 44 of file MuonSegmentFittingTool.cxx.

45 {
46 ATH_MSG_VERBOSE(" trying to fit segment ");
47 const EventContext& ctx = Gaudi::Hive::currentContext();
48 Amg::Vector3D gdir = gDir;
49
50 double gdirNorm = gdir.mag();
51 bool isCurvedSegment = (gdirNorm > 1.5);
52 if (isCurvedSegment) {
53 // re-normalize the gdir
54 gdir = Amg::Vector3D(gdir.x() / gdirNorm, gdir.y() / gdirNorm, gdir.z() / gdirNorm);
55 }
56
57 double charge = 0;
58 Trk::AtaPlane segPars(gpos, gdir, charge, surf);
59
60 // extrapolate segment parameters to first measurements
61 const Trk::MeasurementBase* firstMeas = rioVec.front();
62 std::unique_ptr<Trk::TrackParameters> exPars =
63 m_slPropagator->propagate(ctx, segPars, firstMeas->associatedSurface(), Trk::anyDirection, false, m_magFieldProperties);
64 if (!exPars) {
65 ATH_MSG_DEBUG(" Propagation failed!! ");
66 return nullptr;
67 }
68
69 // small shift towards the ip
70 double sign = exPars->position().dot(exPars->momentum()) > 0 ? 1. : -1.;
71 Amg::Vector3D perpos = exPars->position() - sign * exPars->momentum().unit();
72
73 // create start parameter
74 double phi = gdir.phi();
75 double theta = gdir.theta();
76 double qoverp = 0;
77 Trk::PerigeeSurface persurf(perpos);
78 Trk::Perigee startpar(0, 0, phi, theta, qoverp, persurf);
79
80 // copy measurements into new vector
81 std::vector<const Trk::MeasurementBase*> vec2;
82 vec2.reserve(rioVec.size());
83 std::copy(rioVec.begin(), rioVec.end(), std::back_inserter(vec2));
84
85 // fit
86 std::unique_ptr<Trk::Track> newtrack;
87 // use the full fitter if the segment is curved
88 if (isCurvedSegment) {
89 newtrack = m_curvedTrackFitter->fit(ctx, vec2, startpar, false, Trk::ParticleSwitcher::particle[0]);
90 }
91 // else use the straight line fitter
92 else {
93 newtrack = m_slTrackFitter->fit(ctx, vec2, startpar, false, Trk::nonInteracting);
94 }
95
96 if (!newtrack) {
97 ATH_MSG_VERBOSE(" fit failed ");
98 return nullptr;
99 }
100 constexpr double chi2Cut = 10.;
101 std::unique_ptr<Trk::Track> cleanTrack = m_trackCleaner->clean(*newtrack, ctx);
102 if (!cleanTrack && !isCurvedSegment && calcChi2(*newtrack) > chi2Cut) {
103 ATH_MSG_VERBOSE(" lost in cleaner ");
104 return nullptr;
105 }
106
107 if (cleanTrack && !(*cleanTrack->perigeeParameters() == *newtrack->perigeeParameters()) && !isCurvedSegment) {
108 // using release until the entire code can be migrated to use smart pointers
109 newtrack.swap(cleanTrack);
110 }
111
112 // reject fit if larger than cut
113 if (calcChi2(*newtrack) > chi2Cut) {
114 ATH_MSG_VERBOSE(" reduced chi2 to large " << calcChi2(*newtrack) << " cut " << chi2Cut);
115 return nullptr;
116 }
117
118 if (msgLvl(MSG::DEBUG)) {
119 const Trk::Perigee* pp = newtrack->perigeeParameters();
120 if (pp) {
121 ATH_MSG_DEBUG(" pos " << std::setprecision(5) << pp->position() << " phi " << pp->momentum().phi() << " theta "
122 << pp->momentum().theta() << " q*mom " << pp->momentum().mag() * pp->charge() << " pt "
123 << pp->momentum().perp());
124 } else {
125 ATH_MSG_DEBUG(" no perigee ");
126 }
127 }
128 return newtrack.release();
129 }
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
int sign(int a)
bool msgLvl(const MSG::Level lvl) const
ToolHandle< Muon::IMuonTrackCleaner > m_trackCleaner
ToolHandle< Trk::IPropagator > m_slPropagator
ToolHandle< Trk::ITrackFitter > m_curvedTrackFitter
ToolHandle< Trk::ITrackFitter > m_slTrackFitter
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
double charge() const
Returns the charge.
Eigen::Matrix< double, 3, 1 > Vector3D
std::vector< D3PDTest::MyVec2 > vec2
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
@ anyDirection
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane

◆ fit() [2/2]

Trk::Track * Muon::MuonSegmentFittingTool::fit ( const MuonSegment & segment) const
virtual

fit segment parameters + hits producing a track

Implements Muon::IMuonSegmentFittingTool.

Definition at line 40 of file MuonSegmentFittingTool.cxx.

40 {
41 return fit(segment.globalPosition(), segment.globalDirection(), segment.associatedSurface(), segment.containedMeasurements());
42 }
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
Trk::Track * fit(const Amg::Vector3D &gpos, const Amg::Vector3D &gdir, const Trk::PlaneSurface &surf, const std::vector< const Trk::MeasurementBase * > &rioVec) const
fit segment parameters + hits producing a track
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects

◆ initialize()

StatusCode Muon::MuonSegmentFittingTool::initialize ( )
virtual

Definition at line 32 of file MuonSegmentFittingTool.cxx.

32 {
33 ATH_CHECK(m_slPropagator.retrieve());
34 ATH_CHECK(m_slTrackFitter.retrieve());
36 ATH_CHECK(m_trackCleaner.retrieve());
37 return StatusCode::SUCCESS;
38 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Muon::IMuonSegmentFittingTool::interfaceID ( )
inlinestaticinherited

access to tool interface

Definition at line 47 of file IMuonSegmentFittingTool.h.

static const InterfaceID IID_IMuonSegmentFittingTool("Muon::IMuonSegmentFittingTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateSegmentParameters()

void Muon::MuonSegmentFittingTool::updateSegmentParameters ( const Trk::Track & track,
const Trk::PlaneSurface & surf,
Amg::Vector2D & segLocPos,
Trk::LocalDirection & segLocDir,
Amg::MatrixX & locerr ) const
virtual

update the parameters of the segment using the track information

Implements Muon::IMuonSegmentFittingTool.

Definition at line 131 of file MuonSegmentFittingTool.cxx.

132 {
133 ATH_MSG_DEBUG(" old segment parameters: pos (" << segLocPos[Trk::locX] << "," << segLocPos[Trk::locY] << ") dir ("
134 << segLocDir.angleXZ() << "," << segLocDir.angleYZ() << ") ");
135
136 const EventContext& ctx = Gaudi::Hive::currentContext();
137 const Trk::Perigee* pp = track.perigeeParameters();
138 if (!pp) {
139 ATH_MSG_WARNING(" track without perigee ");
140 return;
141 }
142
143 std::unique_ptr<Trk::TrackParameters> exPars =
144 m_slPropagator->propagate(ctx, *pp, surf, Trk::anyDirection, false, m_magFieldProperties);
145 if (!exPars) {
146 ATH_MSG_WARNING(" extrapolation failed, this should not happen ");
147 return;
148 }
149
150 Amg::Vector2D lpos{0., 0.};
151 surf.globalToLocal(exPars->position(), exPars->position(), lpos);
152 Trk::LocalDirection ldir;
153 surf.globalToLocalDirection(exPars->momentum().unit(), ldir);
154 ATH_MSG_DEBUG(" new segment parameters: pos (" << lpos[Trk::locX] << "," << lpos[Trk::locY] << ") dir (" << ldir.angleXZ() << ","
155 << ldir.angleYZ() << ") ");
156
157 segLocPos[Trk::locX] = lpos[Trk::locX];
158 if (m_updatePrecisionCoordinate) segLocPos[Trk::locY] = lpos[Trk::locY];
159 segLocDir = Trk::LocalDirection(ldir.angleXZ(), m_updatePrecisionCoordinate ? ldir.angleYZ() : segLocDir.angleYZ());
160
161 if (exPars->covariance()) locerr = *exPars->covariance();
162 }
#define ATH_MSG_WARNING(x)
double angleXZ() const
access method for angle of local XZ projection
double angleYZ() const
access method for angle of local YZ projection
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
void globalToLocalDirection(const Amg::Vector3D &glodir, Trk::LocalDirection &locdir) const
This method transforms the global direction to a local direction wrt the plane.
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_curvedTrackFitter

ToolHandle<Trk::ITrackFitter> Muon::MuonSegmentFittingTool::m_curvedTrackFitter
Initial value:
{
this,
"CurvedFitter",
"Trk::GlobalChi2Fitter/MCTBFitter",
}

Definition at line 69 of file MuonSegmentFittingTool.h.

69 {
70 this,
71 "CurvedFitter",
72 "Trk::GlobalChi2Fitter/MCTBFitter",
73 }; //<! fitter, curved tracks

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_magFieldProperties

Trk::MagneticFieldProperties Muon::MuonSegmentFittingTool::m_magFieldProperties

Definition at line 57 of file MuonSegmentFittingTool.h.

◆ m_slPropagator

ToolHandle<Trk::IPropagator> Muon::MuonSegmentFittingTool::m_slPropagator
Initial value:
{
this,
"SLPropagator",
"Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
}

Definition at line 59 of file MuonSegmentFittingTool.h.

59 {
60 this,
61 "SLPropagator",
62 "Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
63 }; //<! propagator, always use straightline

◆ m_slTrackFitter

ToolHandle<Trk::ITrackFitter> Muon::MuonSegmentFittingTool::m_slTrackFitter
Initial value:
{
this,
"SLFitter",
"Trk::GlobalChi2Fitter/MCTBSLFitter",
}

Definition at line 64 of file MuonSegmentFittingTool.h.

64 {
65 this,
66 "SLFitter",
67 "Trk::GlobalChi2Fitter/MCTBSLFitter",
68 }; //<! fitter, always use straightline

◆ m_trackCleaner

ToolHandle<Muon::IMuonTrackCleaner> Muon::MuonSegmentFittingTool::m_trackCleaner
Initial value:
{
this,
"TrackCleaner",
"Muon::MuonTrackCleaner/MuonTrackCleaner",
}

Definition at line 74 of file MuonSegmentFittingTool.h.

74 {
75 this,
76 "TrackCleaner",
77 "Muon::MuonTrackCleaner/MuonTrackCleaner",
78 };

◆ m_updatePrecisionCoordinate

bool Muon::MuonSegmentFittingTool::m_updatePrecisionCoordinate

Definition at line 80 of file MuonSegmentFittingTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: