ATLAS Offline Software
MuonTagToSegMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace MuonCombined {
8 
9  unsigned int MuonTagToSegMap::persistify(const Muon::MuonSegment* assoc_seg, Trk::SegmentCollection* container) {
10  unsigned int curr_size = container->size();
11  unsigned int test_stored = linkIndex(assoc_seg);
12  if (test_stored < curr_size) return test_stored;
13  std::unique_ptr<Muon::MuonSegment> copy = std::make_unique<Muon::MuonSegment>(*assoc_seg);
14  m_map.emplace_back(assoc_seg, copy.get(), curr_size);
15  container->push_back(std::move(copy));
16  return curr_size;
17  }
18 
19  unsigned int MuonTagToSegMap::linkIndex(const Trk::Segment* storegate) const {
20  LinkMap::const_iterator itr =
21  std::find_if(m_map.begin(), m_map.end(), [storegate](const SegmentLink& link) { return link.storegate == storegate; });
22  if (itr != m_map.end()) return itr->index;
23  return -1;
24  }
25 
27  std::set<const Trk::Segment*> MuonTagToSegMap::getPersistifiedSegments() const {
28  std::set<const Trk::Segment*> ret;
29  for (const SegmentLink& link : m_map) ret.insert(link.storegate);
30  return ret;
31  }
32 
33 } // namespace MuonCombined
MuonCombined::MuonTagToSegMap::linkIndex
unsigned int linkIndex(const Trk::Segment *storegate) const
Returns the index of the persistent in the output container In case, that the segment has not been pe...
Definition: MuonTagToSegMap.cxx:19
MuonTagToSegMap.h
ret
T ret(T t)
Definition: rootspy.cxx:260
Trk::Segment
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:56
DataVector< Trk::Segment >
MuonCombined::MuonTagToSegMap::getPersistifiedSegments
std::set< const Trk::Segment * > getPersistifiedSegments() const
Returns the set of all store gate segments that were persitified.
Definition: MuonTagToSegMap.cxx:27
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
MuonCombined::MuonTagToSegMap::persistify
unsigned int persistify(const Muon::MuonSegment *assoc_seg, Trk::SegmentCollection *container)
Pushes back the segment cached in the store gate back to the new segment container meant for write-ou...
Definition: MuonTagToSegMap.cxx:9
MuonCombined
The MuonTagToSegMap is an auxillary construct that links the MuonSegments associated with a combined ...
Definition: IMuonSystemExtensionTool.h:23
MuonCombined::MuonTagToSegMap::m_map
LinkMap m_map
Definition: MuonTagToSegMap.h:54
calibdata.copy
bool copy
Definition: calibdata.py:27
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.