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

#include <MuonCandidateTrackBuilderTool.h>

Inheritance diagram for Muon::MuonCandidateTrackBuilderTool:
Collaboration diagram for Muon::MuonCandidateTrackBuilderTool:

Public Member Functions

 MuonCandidateTrackBuilderTool (const std::string &type, const std::string &name, const IInterface *parent)
 Default AlgTool functions.
virtual ~MuonCandidateTrackBuilderTool ()=default
virtual StatusCode initialize () override
virtual std::unique_ptr< Trk::TrackbuildCombinedTrack (const EventContext &ctx, const Trk::Track &idTrack, const MuonCandidate &candidate) const override
 IMuonCandidateTrackBuilderTool interface: buildCombinedTrack.
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 ()
 IAlgTool interface.

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

PublicToolHandle< MuonEDMPrinterToolm_printer {this, "MuonEDMPrinterTool", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
ServiceHandle< IMuonEDMHelperSvcm_edmHelperSvc
ToolHandle< Rec::ICombinedMuonTrackBuilderm_trackFitter
Gaudi::Property< bool > m_reOrderMeasurements {this, "ReOrderMeasurements", true}
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

Definition at line 76 of file MuonCandidateTrackBuilderTool.h.

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

◆ MuonCandidateTrackBuilderTool()

Muon::MuonCandidateTrackBuilderTool::MuonCandidateTrackBuilderTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Default AlgTool functions.

Definition at line 15 of file MuonCandidateTrackBuilderTool.cxx.

16 :
17 AthAlgTool(type, name, parent) {
18 declareInterface<IMuonCandidateTrackBuilderTool>(this);
19 }
AthAlgTool()
Default constructor:

◆ ~MuonCandidateTrackBuilderTool()

virtual Muon::MuonCandidateTrackBuilderTool::~MuonCandidateTrackBuilderTool ( )
virtualdefault

Member Function Documentation

◆ buildCombinedTrack()

std::unique_ptr< Trk::Track > Muon::MuonCandidateTrackBuilderTool::buildCombinedTrack ( const EventContext & ctx,
const Trk::Track & idTrack,
const MuonCandidate & candidate ) const
overridevirtual

IMuonCandidateTrackBuilderTool interface: buildCombinedTrack.

Implements Muon::IMuonCandidateTrackBuilderTool.

Definition at line 29 of file MuonCandidateTrackBuilderTool.cxx.

30 {
31 ATH_MSG_DEBUG("Building track from candidate with " << candidate.layerIntersections.size() << " layers ");
32 // copy and sort layerIntersections according to their distance to the IP
33 std::vector<MuonLayerIntersection> layerIntersections = candidate.layerIntersections;
34 std::stable_sort(layerIntersections.begin(), layerIntersections.end(),
35 [](const MuonLayerIntersection& lay1, const MuonLayerIntersection& lay2) {
36 auto getDistance = [](const MuonLayerIntersection& layerIntersection) {
37 if (layerIntersection.intersection.trackParameters.get() == nullptr) return 1e9;
38 return layerIntersection.intersection.trackParameters->position().mag();
39 };
40 return getDistance(lay1) < getDistance(lay2);
41 });
42
43 // loop over sorted layers and extract measurements
44 std::vector<const Trk::MeasurementBase*> measurements;
45 int intersec = 0;
46 bool isEndcap{false}, isBarrel{false}, isSmall{false}, isLarge{false};
47 for (const MuonLayerIntersection& layerIntersection : layerIntersections) {
48 intersec++;
49 ATH_MSG_VERBOSE(" layerIntersection " << intersec << " perp "
50 << layerIntersection.intersection.trackParameters->position().perp() << " z "
51 << layerIntersection.intersection.trackParameters->position().z() << " distance to IP "
52 << layerIntersection.intersection.trackParameters->position().mag());
53 ATH_MSG_VERBOSE(" segment surface center perp " << layerIntersection.segment->associatedSurface().center().perp() << " z "
54 << layerIntersection.segment->associatedSurface().center().z() << " nr of msts "
55 << layerIntersection.segment->containedMeasurements().size());
56 ATH_MSG_VERBOSE(m_printer->print(*(layerIntersection.segment)));
57
58 // Fix problem with segments where measurements are not ordered wrt IP
59
60 // first check whether it is a Barrel or Endcap segment
61
62 std::vector<const Trk::MeasurementBase*> containedMeasurements = layerIntersection.segment->containedMeasurements();
63 for (const Trk::MeasurementBase* mit : containedMeasurements) {
64 // get Identifier
65 Identifier id;
66 const Trk::RIO_OnTrack* rio = dynamic_cast<const Trk::RIO_OnTrack*>(mit);
67 if (rio)
68 id = rio->identify();
69 else {
70 const Trk::CompetingRIOsOnTrack* crio = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mit);
71 if (crio)
72 id = crio->rioOnTrack(0).identify();
73 else
74 continue;
75 }
76 // check if valid ID
77 if (!id.is_valid()) continue;
78 // check if muon
79 if (!m_idHelperSvc->isMuon(id)) continue;
80
81 if (m_idHelperSvc->isEndcap(id)) {
82 isEndcap = true;
83 } else {
84 isBarrel = true;
85 }
86 if (m_idHelperSvc->isTrigger(id)) continue;
87
88 if (m_idHelperSvc->isSmallChamber(id)) {
89 isSmall = true;
90 } else {
91 isLarge = true;
92 }
93 }
94
96 // reorder measurements using SortMeas (defined in header file)
97 std::stable_sort(containedMeasurements.begin(), containedMeasurements.end(),
98 SortMeas(&*m_edmHelperSvc, &*m_idHelperSvc, isEndcap));
99 }
100 // insert in measurements list
101 measurements.insert(measurements.end(), containedMeasurements.begin(), containedMeasurements.end());
102 }
103
104 // check for rare case in which 2 layers are large/small and one segment contains the other only with the opposite assignment of
105 // radius signs
106 if (candidate.layerIntersections.size() == 2 && isSmall && isLarge) {
107 if (m_idHelperSvc->stationIndex(m_edmHelperSvc->chamberId(*candidate.layerIntersections.at(0).segment)) ==
108 m_idHelperSvc->stationIndex(m_edmHelperSvc->chamberId(*candidate.layerIntersections.at(1).segment))) {
109 const Muon::MuonSegment* seg1 = candidate.layerIntersections.at(0).segment.get();
110 const Muon::MuonSegment* seg2 = candidate.layerIntersections.at(1).segment.get();
111 if (seg1->containedMeasurements().size() > seg2->containedMeasurements().size()) {
112 seg2 = candidate.layerIntersections.at(0).segment.get();
113 seg1 = candidate.layerIntersections.at(1).segment.get();
114 }
115 bool found = false;
116 for (const auto& meas1 : seg1->containedMeasurements()) {
117 found = false;
118 for (const auto& meas2 : seg2->containedMeasurements()) {
119 if (m_edmHelperSvc->getIdentifier(*meas1) == m_edmHelperSvc->getIdentifier(*meas2)) {
120 found = true;
121 break;
122 }
123 }
124 // if any hit isn't found we're off the hook
125 if (!found) break;
126 }
127 if (found) {
128 ATH_MSG_DEBUG("S/L overlap where one segment contains the other, don't use");
129 return std::unique_ptr<Trk::Track>();
130 }
131 }
132 }
133
134 // reorder in case of Small Large overlaps in Barrel or Endcap ONLY
135
136 bool reorderAllMeasurements = false;
137 if (isSmall && isLarge) reorderAllMeasurements = true;
138 if (isEndcap && isBarrel) reorderAllMeasurements = false;
139
140 if (m_reOrderMeasurements && reorderAllMeasurements) {
141 // reorder measurements using SortMeas (defined in header file)
142 ATH_MSG_VERBOSE(" reorder all measurements before " << std::endl << m_printer->print(measurements));
143 std::stable_sort(measurements.begin(), measurements.end(), SortMeas(&*m_edmHelperSvc, &*m_idHelperSvc, isEndcap));
144 }
145
146 ATH_MSG_VERBOSE("final measurement list: " << std::endl << m_printer->print(measurements));
147
148 ATH_MSG_DEBUG("Extracted hits from candidate: " << measurements.size());
149 std::unique_ptr<Trk::Track> refittedTrack{m_trackFitter->indetExtension(ctx, idTrack, measurements)};
150 if (refittedTrack) {
151 ATH_MSG_DEBUG("got Track: " << m_printer->print(*refittedTrack) << std::endl << m_printer->printStations(*refittedTrack));
152 }
153 return refittedTrack;
154 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
ServiceHandle< IMuonEDMHelperSvc > m_edmHelperSvc
PublicToolHandle< MuonEDMPrinterTool > m_printer
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ToolHandle< Rec::ICombinedMuonTrackBuilder > m_trackFitter
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Identifier identify() const
return the identifier -extends MeasurementBase
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
bool isBarrel(const ChIndex index)
Returns true if the chamber index points to a barrel chamber.
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ 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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ 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

◆ initialize()

StatusCode Muon::MuonCandidateTrackBuilderTool::initialize ( )
overridevirtual

Definition at line 21 of file MuonCandidateTrackBuilderTool.cxx.

21 {
22 ATH_CHECK(m_printer.retrieve());
23 ATH_CHECK(m_idHelperSvc.retrieve());
24 ATH_CHECK(m_edmHelperSvc.retrieve());
25 ATH_CHECK(m_trackFitter.retrieve());
26 return StatusCode::SUCCESS;
27 }
#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::IMuonCandidateTrackBuilderTool::interfaceID ( )
inlinestaticinherited

IAlgTool interface.

Definition at line 21 of file IMuonCandidateTrackBuilderTool.h.

21 {
22 static const InterfaceID IID_IMuonCandidateTrackBuilderTool("Muon::IMuonCandidateTrackBuilderTool", 1, 0);
23 return IID_IMuonCandidateTrackBuilderTool;
24 }

◆ 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.

◆ 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_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_edmHelperSvc

ServiceHandle<IMuonEDMHelperSvc> Muon::MuonCandidateTrackBuilderTool::m_edmHelperSvc
private
Initial value:
{this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface"}

Definition at line 90 of file MuonCandidateTrackBuilderTool.h.

90 {this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
91 "Handle to the service providing the IMuonEDMHelperSvc interface"};

◆ 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_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonCandidateTrackBuilderTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 89 of file MuonCandidateTrackBuilderTool.h.

89{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_printer

PublicToolHandle<MuonEDMPrinterTool> Muon::MuonCandidateTrackBuilderTool::m_printer {this, "MuonEDMPrinterTool", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}
private

Definition at line 88 of file MuonCandidateTrackBuilderTool.h.

88{this, "MuonEDMPrinterTool", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"};

◆ m_reOrderMeasurements

Gaudi::Property<bool> Muon::MuonCandidateTrackBuilderTool::m_reOrderMeasurements {this, "ReOrderMeasurements", true}
private

Definition at line 95 of file MuonCandidateTrackBuilderTool.h.

95{this, "ReOrderMeasurements", true};

◆ m_trackFitter

ToolHandle<Rec::ICombinedMuonTrackBuilder> Muon::MuonCandidateTrackBuilderTool::m_trackFitter
private
Initial value:
{this, "MuonTrackBuilder",
"Rec::CombinedMuonTrackBuilder/CombinedMuonTrackBuilder"}

Definition at line 92 of file MuonCandidateTrackBuilderTool.h.

92 {this, "MuonTrackBuilder",
93 "Rec::CombinedMuonTrackBuilder/CombinedMuonTrackBuilder"};

◆ 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: