ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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. More...
 
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. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 IAlgTool interface. More...
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

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> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

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) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
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  :
15  declareInterface<IMuonLayerAmbiguitySolverTool>(this);
16  }

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

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

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

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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  }

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

95 { return m_detStore; }

◆ evtStore() [1/2]

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.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

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

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

◆ initialize()

StatusCode Muon::MuonLayerAmbiguitySolverTool::initialize ( )
overridevirtual

Definition at line 18 of file MuonLayerAmbiguitySolverTool.cxx.

18  {
19  ATH_CHECK(m_segmentSelector.retrieve());
20  ATH_CHECK(m_segmentMatchingTool.retrieve());
21  ATH_CHECK(m_muonTrackBuilder.retrieve());
22  ATH_CHECK(m_printer.retrieve());
23 
24  return StatusCode::SUCCESS;
25  }

◆ 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()

static 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() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

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

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ 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();
383  PBASE::renounce (h);
384  }

◆ 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  {
365  handlesArray.renounce();
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  }
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  }

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

◆ 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 DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ 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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

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.

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

◆ m_muonTrackBuilder

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

Definition at line 56 of file MuonLayerAmbiguitySolverTool.h.

◆ m_printer

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

Definition at line 58 of file MuonLayerAmbiguitySolverTool.h.

◆ m_seedQualityThreshold

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

Definition at line 61 of file MuonLayerAmbiguitySolverTool.h.

◆ m_segmentMatchingTool

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

Definition at line 54 of file MuonLayerAmbiguitySolverTool.h.

◆ m_segmentSelector

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

Definition at line 52 of file MuonLayerAmbiguitySolverTool.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:
Muon::MuonLayerAmbiguitySolverTool::m_segmentMatchingTool
ToolHandle< IMuonSegmentMatchingTool > m_segmentMatchingTool
Definition: MuonLayerAmbiguitySolverTool.h:54
Muon::MuonLayerAmbiguitySolverTool::m_minSegmentQuality
Gaudi::Property< int > m_minSegmentQuality
Definition: MuonLayerAmbiguitySolverTool.h:62
Muon::MuonLayerAmbiguitySolverTool::m_segmentSelector
ToolHandle< IMuonSegmentSelectionTool > m_segmentSelector
Definition: MuonLayerAmbiguitySolverTool.h:52
TRT_PAI_gasdata::EO
const float EO[NO]
Energy levels for Oxygen.
Definition: TRT_PAI_gasdata.h:301
drawFromPickle.candidates
candidates
Definition: drawFromPickle.py:271
Muon::MuonStationIndex::StIndex::EM
@ EM
Muon::MuonLayerAmbiguitySolverTool::resolveSmallLargeOverlaps
void resolveSmallLargeOverlaps(const EventContext &ctx, std::vector< MuonLayerIntersection > &existingLayerIntersections, std::vector< MuonLayerIntersection > &newLayerIntersections) const
Definition: MuonLayerAmbiguitySolverTool.cxx:209
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
Muon::MuonLayerAmbiguitySolverTool::m_maxSeeds
Gaudi::Property< unsigned int > m_maxSeeds
Definition: MuonLayerAmbiguitySolverTool.h:60
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon::MuonLayerAmbiguitySolverTool::getNextSeed
bool getNextSeed(const std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec, std::set< const MuonSegment * > &usedSegments, std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder, MuonLayerIntersection &layerIntersection) const
Definition: MuonLayerAmbiguitySolverTool.cxx:137
xAOD::MuonSegment
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/MuonSegment.h:13
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
Muon::MuonStationIndex::toStationIndex
StIndex toStationIndex(ChIndex index)
convert ChIndex into StIndex
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Prompt::getDistance
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
Definition: PromptUtils.cxx:41
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AnalysisUtils::copy_if
Out copy_if(In first, const In &last, Out res, const Pred &p)
Definition: IFilterUtils.h:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
Muon::MuonLayerAmbiguitySolverTool::match
bool match(const EventContext &ctx, const MuonCandidate &candidate, const MuonLayerIntersection &layerIntersection) const
Definition: MuonLayerAmbiguitySolverTool.cxx:128
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
Muon::MuonStationIndex::StIndex::BO
@ BO
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
Muon::MuonLayerAmbiguitySolverTool::extendCandidatesWithLayers
bool extendCandidatesWithLayers(const EventContext &ctx, std::vector< MuonCandidate > &candidates, const std::vector< std::vector< MuonLayerIntersection > > &muonLayerRecoDataHashVec, const std::vector< MuonStationIndex::StIndex > &inverseSeedLayerOrder) const
Definition: MuonLayerAmbiguitySolverTool.cxx:76
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MuonLayerAmbiguitySolverTool::buildLayerVec
void buildLayerVec(const EventContext &ctx, const std::vector< MuonLayerRecoData > &allLayers, std::vector< std::vector< MuonLayerIntersection > > &muonLayerDataHashVec) const
Definition: MuonLayerAmbiguitySolverTool.cxx:166
a
TList * a
Definition: liststreamerinfos.cxx:10
columnar::empty
bool empty() const noexcept
Definition: ObjectRange.h:163
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DEBUG
#define DEBUG
Definition: page_access.h:11
python.TrackLeptonConfig.quality
quality
Definition: TrackLeptonConfig.py:16
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:629
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60
Muon::MuonLayerAmbiguitySolverTool::m_printer
PublicToolHandle< MuonEDMPrinterTool > m_printer
Definition: MuonLayerAmbiguitySolverTool.h:58
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
Muon::MuonLayerAmbiguitySolverTool::m_muonTrackBuilder
ToolHandle< IMuonSegmentTrackBuilder > m_muonTrackBuilder
Definition: MuonLayerAmbiguitySolverTool.h:56
Muon::MuonStationIndex::StIndex::BI
@ BI
Muon::MuonStationIndex::StIndex::BM
@ BM
Muon::IMuonSegmentTrackBuilder::PrepVec
std::vector< const Trk::PrepRawData * > PrepVec
Definition: IMuonSegmentTrackBuilder.h:26
Muon::MuonStationIndex::StIndex::EI
@ EI
Muon::MuonLayerIntersection
Definition: MuonLayerIntersection.h:13
Muon::MuonLayerAmbiguitySolverTool::m_seedQualityThreshold
Gaudi::Property< int > m_seedQualityThreshold
Definition: MuonLayerAmbiguitySolverTool.h:61
fitman.k
k
Definition: fitman.py:528
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5