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

#include <MuonLayerAmbiguitySolverTool.h>

Inheritance diagram for Muon::MuonLayerAmbiguitySolverTool:
Collaboration diagram for Muon::MuonLayerAmbiguitySolverTool:

Public Member Functions

 MuonLayerAmbiguitySolverTool (const std::string &type, const std::string &name, const IInterface *parent)
 Default AlgTool functions.
virtual ~MuonLayerAmbiguitySolverTool ()=default
virtual StatusCode initialize () override
virtual void resolveOverlaps (const EventContext &ctx, const std::vector< Muon::MuonLayerRecoData > &allLayers, std::vector< MuonCandidate > &resolvedCandidates) const override
 IMuonLayerAmbiguitySolverTool interface: find.
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

void buildLayerVec (const EventContext &ctx, const std::vector< MuonLayerRecoData > &allLayers, std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec) const
bool getNextSeed (const std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec, std::set< const MuonSegment * > &usedSegments, std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder, MuonLayerIntersection &layerIntersection) const
bool extendCandidatesWithLayers (const EventContext &ctx, std::vector< MuonCandidate > &candidates, const std::vector< std::vector< MuonLayerIntersection > > &muonLayerRecoDataHashVec, const std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder) const
void resolveSmallLargeOverlaps (const EventContext &ctx, std::vector< MuonLayerIntersection > &existingLayerIntersections, std::vector< MuonLayerIntersection > &newLayerIntersections) const
bool match (const EventContext &ctx, const MuonCandidate &candidate, const MuonLayerIntersection &layerIntersection) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< IMuonSegmentSelectionToolm_segmentSelector
ToolHandle< IMuonSegmentMatchingToolm_segmentMatchingTool
ToolHandle< IMuonSegmentTrackBuilderm_muonTrackBuilder
PublicToolHandle< MuonEDMPrinterToolm_printer {this, "MuonEDMPrinterTool", "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}
Gaudi::Property< unsigned int > m_maxSeeds {this, "MaxSeeds", 30, "maximum number of seeds to be tried"}
Gaudi::Property< int > m_seedQualityThreshold {this, "SeedQualityThreshold", 2, "seed quality threshold"}
Gaudi::Property< int > m_minSegmentQuality {this, "MinimumSegmentQuality", 1, "minimum quality for a segment to be considered"}
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 24 of file MuonLayerAmbiguitySolverTool.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

◆ MuonLayerAmbiguitySolverTool()

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

Default AlgTool functions.

Definition at line 13 of file MuonLayerAmbiguitySolverTool.cxx.

13 :
14 AthAlgTool(type, name, parent) {
15 declareInterface<IMuonLayerAmbiguitySolverTool>(this);
16 }
AthAlgTool()
Default constructor:

◆ ~MuonLayerAmbiguitySolverTool()

virtual Muon::MuonLayerAmbiguitySolverTool::~MuonLayerAmbiguitySolverTool ( )
virtualdefault

Member Function Documentation

◆ buildLayerVec()

void Muon::MuonLayerAmbiguitySolverTool::buildLayerVec ( const EventContext & ctx,
const std::vector< MuonLayerRecoData > & allLayers,
std::vector< std::vector< MuonLayerIntersection > > & muonLayerDataHashVec ) const
private

Definition at line 166 of file MuonLayerAmbiguitySolverTool.cxx.

167 {
168 // clear and resize hash vector, initialize with null_ptr
169 muonLayerDataHashVec.clear();
170 muonLayerDataHashVec.resize(toInt(StIndex::StIndexMax));
171
172 // loop over layers
173 for (const MuonLayerRecoData& layer : allLayers) {
174 const MuonLayerSurface& layerSurface = layer.intersection.layerSurface;
175 MuonStationIndex::StIndex stIndex = MuonStationIndex::toStationIndex(layerSurface.regionIndex, layerSurface.layerIndex);
176
177 // create layer intersections
178 std::vector<MuonLayerIntersection> layerIntersections;
179 layerIntersections.reserve(layer.segments.size());
180 for (const std::shared_ptr<const MuonSegment>& segment : layer.segments) {
181 // get quality and skip bad ones
182 int quality = m_segmentSelector->quality(*segment);
183 if (quality < m_minSegmentQuality) continue;
184 layerIntersections.emplace_back(layer.intersection, segment, quality);
185 }
186
187 // if there are no segments yet in the layer, directly add them
188 if (muonLayerDataHashVec[toInt(stIndex)].empty()) {
189 muonLayerDataHashVec[toInt(stIndex)] = std::move(layerIntersections);
190 } else {
191 // there are already segment, try resolving small/large overlaps
192 resolveSmallLargeOverlaps(ctx, muonLayerDataHashVec[toInt(stIndex)], layerIntersections);
193 }
194
195 // finally sort the segments
196 std::ranges::stable_sort(muonLayerDataHashVec[toInt(stIndex)],
197 [](const Muon::MuonLayerIntersection& a, const Muon::MuonLayerIntersection& b) { return a.quality > b.quality; });
198 }
199
200 if (msgLvl(MSG::DEBUG)) {
201 msg(MSG::DEBUG) << " Done building segment vector ";
202 for (const auto& vec : muonLayerDataHashVec) {
203 for (const auto& entry : vec) { msg(MSG::DEBUG) << std::endl << " " << m_printer->print(*entry.segment); }
204 }
205 msg(MSG::DEBUG) << endmsg;
206 }
207 }
#define endmsg
std::vector< size_t > vec
static Double_t a
static const Attributes_t empty
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
void resolveSmallLargeOverlaps(const EventContext &ctx, std::vector< MuonLayerIntersection > &existingLayerIntersections, std::vector< MuonLayerIntersection > &newLayerIntersections) const
ToolHandle< IMuonSegmentSelectionTool > m_segmentSelector
PublicToolHandle< MuonEDMPrinterTool > m_printer
StIndex
enum to classify the different station layers in the muon spectrometer
StIndex toStationIndex(ChIndex index)
convert ChIndex into StIndex
constexpr int toInt(const EnumType enumVal)
@ layer
Definition HitInfo.h:79

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

◆ extendCandidatesWithLayers()

bool Muon::MuonLayerAmbiguitySolverTool::extendCandidatesWithLayers ( const EventContext & ctx,
std::vector< MuonCandidate > & candidates,
const std::vector< std::vector< MuonLayerIntersection > > & muonLayerRecoDataHashVec,
const std::vector< MuonStationIndex::StIndex > & inverseSeedLayerOrder ) const
private

replace the last intersection on the original candidate

Definition at line 76 of file MuonLayerAmbiguitySolverTool.cxx.

79 {
80 // break recursive call chain once we processed all layers
81 if (inverseSeedLayerOrder.empty()) return true;
82
83 ATH_MSG_VERBOSE("extendCandidates " << candidates.size() << " remaining layers " << inverseSeedLayerOrder.size());
84
85 // get data in current layer
86 MuonStationIndex::StIndex currentStIndex = inverseSeedLayerOrder.back();
87 const std::vector<MuonLayerIntersection>& layerIntersections = muonLayerDataHashVec[toInt(currentStIndex)];
88 if (!layerIntersections.empty()) {
89 // store new MuonCandidates
90 std::vector<MuonCandidate> newCandidates;
91
92 // loop over candidates
93 for (MuonCandidate& candidate : candidates) {
94 // if more than one segment is selected in the layer, create a new candidate
95 unsigned int selectedSegmentsInLayer = 0;
96 // loop over data in layer
97 for (const MuonLayerIntersection& layerIntersection : layerIntersections) {
98 // match segment to candidate. Segment pairs with the same identifier are
99 // excluded from the beginning
100 if (match(ctx, candidate, layerIntersection)) {
101 // if first add to existing candidate, else create a new candidate
102 if (selectedSegmentsInLayer == 0) {
103 candidate.layerIntersections.push_back(layerIntersection);
104 } else {
105 MuonCandidate newCandidate = candidate;
107 newCandidate.layerIntersections.back() = layerIntersection;
108 newCandidates.emplace_back(std::move(newCandidate));
109 }
110 ++selectedSegmentsInLayer;
111 }
112 }
113 }
114 // add new candidates to list
115 if (!newCandidates.empty()) {
116 ATH_MSG_VERBOSE("Found multiple solutions, add new candidates " << newCandidates.size());
117 candidates.insert(candidates.end(), std::make_move_iterator(newCandidates.begin()),
118 std::make_move_iterator(newCandidates.end()));
119 }
120 }
121
122 // remove the current layer and call extendCandidatesWithLayers for the next layer
123 std::vector<MuonStationIndex::StIndex> newInverseSeedLayerOrder = inverseSeedLayerOrder;
124 newInverseSeedLayerOrder.pop_back();
125 return extendCandidatesWithLayers(ctx, candidates, muonLayerDataHashVec, newInverseSeedLayerOrder);
126 }
#define ATH_MSG_VERBOSE(x)
bool match(const EventContext &ctx, const MuonCandidate &candidate, const MuonLayerIntersection &layerIntersection) const
bool extendCandidatesWithLayers(const EventContext &ctx, std::vector< MuonCandidate > &candidates, const std::vector< std::vector< MuonLayerIntersection > > &muonLayerRecoDataHashVec, const std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder) const

◆ 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

◆ getNextSeed()

bool Muon::MuonLayerAmbiguitySolverTool::getNextSeed ( const std::vector< std::vector< MuonLayerIntersection > > & muonLayerDataHashVec,
std::set< const MuonSegment * > & usedSegments,
std::vector< MuonStationIndex::StIndex > & inverseSeedLayerOrder,
MuonLayerIntersection & layerIntersection ) const
private

select segment

Definition at line 137 of file MuonLayerAmbiguitySolverTool.cxx.

140 {
141 ATH_MSG_VERBOSE("getNextSeed, remaining layers " << inverseSeedLayerOrder.size());
142 // loop over the inverse seed layers
143 std::vector<MuonStationIndex::StIndex>::const_reverse_iterator rit = inverseSeedLayerOrder.rbegin();
144 std::vector<MuonStationIndex::StIndex>::const_reverse_iterator rit_end = inverseSeedLayerOrder.rend();
145 for (; rit != rit_end; ++rit) {
146 // loop over segments and find the next 'good' one that was not used yet
147 for (const MuonLayerIntersection& muonLayerIntersection : muonLayerDataHashVec[toInt(*rit)]) {
149 if (muonLayerIntersection.quality < m_seedQualityThreshold) continue;
150 // only consider once
151 const MuonSegment* segment = muonLayerIntersection.segment.get();
152 if (usedSegments.count(segment)) continue;
153 usedSegments.insert(segment);
154
155 // return result
156 layerIntersection = muonLayerIntersection;
157 ATH_MSG_VERBOSE("Selected seed " << m_printer->print(*segment));
158 return true;
159 }
160 // if we get here, we processed all the possible seeds in the layer so we can remove it from the list
161 inverseSeedLayerOrder.pop_back();
162 }
163 return false;
164 }
MuonSegment_v1 MuonSegment
Reference the current persistent version:

◆ initialize()

StatusCode Muon::MuonLayerAmbiguitySolverTool::initialize ( )
overridevirtual

Definition at line 18 of file MuonLayerAmbiguitySolverTool.cxx.

18 {
19 ATH_CHECK(m_segmentSelector.retrieve());
21 ATH_CHECK(m_muonTrackBuilder.retrieve());
22 ATH_CHECK(m_printer.retrieve());
23
24 return StatusCode::SUCCESS;
25 }
#define ATH_CHECK
Evaluate an expression and check for errors.
ToolHandle< IMuonSegmentTrackBuilder > m_muonTrackBuilder
ToolHandle< IMuonSegmentMatchingTool > m_segmentMatchingTool

◆ 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::IMuonLayerAmbiguitySolverTool::interfaceID ( )
inlinestaticinherited

IAlgTool interface.

Definition at line 22 of file IMuonLayerAmbiguitySolverTool.h.

22 {
23 static const InterfaceID IID_IMuonLayerAmbiguitySolverTool("Muon::IMuonLayerAmbiguitySolverTool", 1, 0);
24 return IID_IMuonLayerAmbiguitySolverTool;
25 }

◆ match()

bool Muon::MuonLayerAmbiguitySolverTool::match ( const EventContext & ctx,
const MuonCandidate & candidate,
const MuonLayerIntersection & layerIntersection ) const
private

Definition at line 128 of file MuonLayerAmbiguitySolverTool.cxx.

129 {
130 // loop over layers and match each segment to the new one, if any fails, fail the combination
131 for (const Muon::MuonLayerIntersection& layer : candidate.layerIntersections) {
132 if (!m_segmentMatchingTool->match(ctx, *layer.segment, *layerIntersection.segment)) return false;
133 }
134 return true;
135 }

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

◆ resolveOverlaps()

void Muon::MuonLayerAmbiguitySolverTool::resolveOverlaps ( const EventContext & ctx,
const std::vector< Muon::MuonLayerRecoData > & allLayers,
std::vector< MuonCandidate > & resolvedCandidates ) const
overridevirtual

IMuonLayerAmbiguitySolverTool interface: find.

Implements Muon::IMuonLayerAmbiguitySolverTool.

Definition at line 27 of file MuonLayerAmbiguitySolverTool.cxx.

28 {
29 // re-organise data to allow hash based access, resolve small large overlaps
30 std::vector<std::vector<MuonLayerIntersection> > muonLayerDataHashVec;
31 buildLayerVec(ctx, allLayers, muonLayerDataHashVec);
32
33 // build candidate by selecting seeds and extending them
34 unsigned int nseeds = 0; // counter for number of seeds up to now
35 std::set<const MuonSegment*> usedSegments; // keep track of the segments already used
36 std::vector<StIndex> inverseSeedLayerOrder = {StIndex::BO, StIndex::BI, StIndex::BM,
37 StIndex::EO, StIndex::EE, StIndex::EI, StIndex::EM};
38 while (nseeds < m_maxSeeds) {
39 // first get a seed
40 MuonLayerIntersection layerIntersection;
41 if (!getNextSeed(muonLayerDataHashVec, usedSegments, inverseSeedLayerOrder, layerIntersection)) {
42 ATH_MSG_VERBOSE("No more seeds, total used seeds " << nseeds);
43 break;
44 }
45
46 // create first candidate from seed and extend it
47 std::vector<MuonLayerIntersection> layerIntersections = {layerIntersection};
48 std::vector<MuonCandidate> candidates = {MuonCandidate(std::move(layerIntersections))};
49 if (extendCandidatesWithLayers(ctx, candidates, muonLayerDataHashVec, inverseSeedLayerOrder)) {
50 // add candidates to output list
51 ATH_MSG_DEBUG(" Completed seed extension " << candidates.size());
52 if (msgLvl(MSG::VERBOSE)) {
53 for (const auto& candidate : candidates) {
54 msg(MSG::VERBOSE) << " Candidate with layers " << candidate.layerIntersections.size();
55 for (const auto& entry : candidate.layerIntersections) {
56 msg(MSG::VERBOSE) << std::endl << " " << m_printer->print(*entry.segment);
57 }
58 }
59 msg(MSG::VERBOSE) << endmsg;
60 }
61
62 // add all segments on the candidates to the exlusion list
63 for (const auto& candidate : candidates) {
64 for (const auto& layer : candidate.layerIntersections) { usedSegments.insert(layer.segment.get()); }
65 }
66 resolvedCandidates.insert(resolvedCandidates.end(), std::make_move_iterator(candidates.begin()),
67 std::make_move_iterator(candidates.end()));
68 }
69 ++nseeds;
70 }
71
72 ATH_MSG_DEBUG("Completed ambiguity solving using " << nseeds << " seeds, resulting in " << resolvedCandidates.size()
73 << " track candidates ");
74 }
#define ATH_MSG_DEBUG(x)
Gaudi::Property< unsigned int > m_maxSeeds
void buildLayerVec(const EventContext &ctx, const std::vector< MuonLayerRecoData > &allLayers, std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec) const
bool getNextSeed(const std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec, std::set< const MuonSegment * > &usedSegments, std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder, MuonLayerIntersection &layerIntersection) const

◆ resolveSmallLargeOverlaps()

void Muon::MuonLayerAmbiguitySolverTool::resolveSmallLargeOverlaps ( const EventContext & ctx,
std::vector< MuonLayerIntersection > & existingLayerIntersections,
std::vector< MuonLayerIntersection > & newLayerIntersections ) const
private

Definition at line 209 of file MuonLayerAmbiguitySolverTool.cxx.

211 {
212 ATH_MSG_VERBOSE(" resolveSmallLargeOverlaps: existing " << existingLayerIntersections.size() << " new "
213 << newLayerIntersections.size());
214
215 // keep track of segments that have been merged
216 std::set<const MuonSegment*> combinedSegments;
217 std::vector<MuonLayerIntersection> combinedIntersections;
218
219 // loop over all permutations
220 for (const MuonLayerIntersection& layerIntersection1 : existingLayerIntersections) {
221 // get quality and skip bad ones
222 if (layerIntersection1.quality < m_minSegmentQuality) continue;
223 for (const MuonLayerIntersection& layerIntersection2 : newLayerIntersections) {
224 // get quality and skip bad ones
225 if (layerIntersection2.quality < m_minSegmentQuality) continue;
226
227 // require at least one of the segments to be above seeding threshold
228 if (layerIntersection1.quality < m_seedQualityThreshold && layerIntersection2.quality < m_seedQualityThreshold) continue;
229
230 // match segments
231 if (!m_segmentMatchingTool->match(ctx, *layerIntersection1.segment, *layerIntersection2.segment)) continue;
232
233 // build new segment
234 static const IMuonSegmentTrackBuilder::PrepVec emptyVec{};
235 std::shared_ptr<const MuonSegment> newseg{
236 m_muonTrackBuilder->combineToSegment(ctx, *layerIntersection1.segment, *layerIntersection2.segment, emptyVec)};
237 if (!newseg) {
238 ATH_MSG_DEBUG(" Fit of combination of segments failed ");
239 continue;
240 }
241
242 // check fit quality
243 const Trk::FitQuality* fq = newseg->fitQuality();
244 if (!fq || fq->numberDoF() == 0) {
245 ATH_MSG_WARNING(" No fit quality, dropping segment ");
246 continue;
247 }
248 if (fq->chiSquared() / fq->numberDoF() > 2.5) {
249 ATH_MSG_DEBUG("Bad fit quality, dropping segment " << fq->chiSquared() / fq->numberDoF());
250 continue;
251 }
252
253 // check that quality of the combined segment is not worse that the original ones
254 int qualitynew = m_segmentSelector->quality(*newseg);
255 if (qualitynew < layerIntersection1.quality || qualitynew < layerIntersection2.quality) {
256 ATH_MSG_DEBUG("Quality got worse after combination: new " << qualitynew << " q1 " << layerIntersection1.quality
257 << " q2 " << layerIntersection2.quality);
258 continue;
259 }
260
261 // select intersection closest to the IP and create new MuonLayerIntersection
262 // get line from combined segment to the IP
263 Amg::Vector3D direction = newseg->globalPosition().unit();
264 // lambda to project the intersection positions on the line, treats the case where pointer is null
265 auto getDistance = [](const MuonLayerIntersection& layerIntersection, const Amg::Vector3D& direction) {
266 if (!layerIntersection.intersection.trackParameters) return 1e9;
267 return layerIntersection.intersection.trackParameters->position().dot(direction);
268 };
269 double dist1 = getDistance(layerIntersection1, direction);
270 double dist2 = getDistance(layerIntersection2, direction);
271 if (dist1 < dist2)
272 combinedIntersections.emplace_back(layerIntersection1.intersection, newseg, qualitynew);
273 else
274 combinedIntersections.emplace_back(layerIntersection2.intersection, newseg, qualitynew);
275
276 ATH_MSG_DEBUG(" Combined segments " << std::endl
277 << " first " << m_printer->print(*layerIntersection1.segment) << std::endl
278 << " second " << m_printer->print(*layerIntersection2.segment) << std::endl
279 << " combined " << m_printer->print(*newseg));
280
281 // add segments to exclusion list
282 combinedSegments.insert(layerIntersection1.segment.get());
283 combinedSegments.insert(layerIntersection2.segment.get());
284 }
285 }
286
287 // lambda to loop over the input intersections and add them to the new list
288 auto insert_intersection = [&combinedSegments](const Muon::MuonLayerIntersection& inter_sect) {
289 return !combinedSegments.count(inter_sect.segment.get());
290 };
291 // do the insertion and swap the new vector with the existingLayerIntersections
292 combinedIntersections.reserve(existingLayerIntersections.size() + newLayerIntersections.size());
293 std::copy_if(std::make_move_iterator(existingLayerIntersections.begin()), std::make_move_iterator(existingLayerIntersections.end()),
294 std::back_inserter(combinedIntersections), insert_intersection);
295 std::copy_if(std::make_move_iterator(newLayerIntersections.begin()), std::make_move_iterator(newLayerIntersections.end()),
296 std::back_inserter(combinedIntersections), insert_intersection);
297 existingLayerIntersections = std::move(combinedIntersections);
298 }
#define ATH_MSG_WARNING(x)
std::vector< const Trk::PrepRawData * > PrepVec
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
Eigen::Matrix< double, 3, 1 > Vector3D
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)

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

Gaudi::Property<unsigned int> Muon::MuonLayerAmbiguitySolverTool::m_maxSeeds {this, "MaxSeeds", 30, "maximum number of seeds to be tried"}
private

Definition at line 60 of file MuonLayerAmbiguitySolverTool.h.

60{this, "MaxSeeds", 30, "maximum number of seeds to be tried"};

◆ m_minSegmentQuality

Gaudi::Property<int> Muon::MuonLayerAmbiguitySolverTool::m_minSegmentQuality {this, "MinimumSegmentQuality", 1, "minimum quality for a segment to be considered"}
private

Definition at line 62 of file MuonLayerAmbiguitySolverTool.h.

62{this, "MinimumSegmentQuality", 1, "minimum quality for a segment to be considered"};

◆ m_muonTrackBuilder

ToolHandle<IMuonSegmentTrackBuilder> Muon::MuonLayerAmbiguitySolverTool::m_muonTrackBuilder
private
Initial value:
{this, "MuonSegmentTrackBuilder",
"Muon::MooTrackBuilder/MooMuonTrackBuilder"}

Definition at line 56 of file MuonLayerAmbiguitySolverTool.h.

56 {this, "MuonSegmentTrackBuilder",
57 "Muon::MooTrackBuilder/MooMuonTrackBuilder"};

◆ m_printer

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

Definition at line 58 of file MuonLayerAmbiguitySolverTool.h.

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

◆ m_seedQualityThreshold

Gaudi::Property<int> Muon::MuonLayerAmbiguitySolverTool::m_seedQualityThreshold {this, "SeedQualityThreshold", 2, "seed quality threshold"}
private

Definition at line 61 of file MuonLayerAmbiguitySolverTool.h.

61{this, "SeedQualityThreshold", 2, "seed quality threshold"};

◆ m_segmentMatchingTool

ToolHandle<IMuonSegmentMatchingTool> Muon::MuonLayerAmbiguitySolverTool::m_segmentMatchingTool
private
Initial value:
{this, "MuonSegmentMatchingTool",
"Muon::MuonSegmentMatchingTool/MuonSegmentMatchingToolTight"}

Definition at line 54 of file MuonLayerAmbiguitySolverTool.h.

54 {this, "MuonSegmentMatchingTool",
55 "Muon::MuonSegmentMatchingTool/MuonSegmentMatchingToolTight"};

◆ m_segmentSelector

ToolHandle<IMuonSegmentSelectionTool> Muon::MuonLayerAmbiguitySolverTool::m_segmentSelector
private
Initial value:
{this, "MuonSegmentSelectionTool",
"Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"}

Definition at line 52 of file MuonLayerAmbiguitySolverTool.h.

52 {this, "MuonSegmentSelectionTool",
53 "Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"};

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