ATLAS Offline Software
MuonSimHitHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include <AthLinks/ElementLink.h>
11 
12 namespace MuonR4 {
15  if (acc.isAvailable(prdHit)){
16  const ElementLink<xAOD::MuonSimHitContainer>& link{acc(prdHit)};
17  if (link.isValid()) {
18  return (*link);
19  }
20  }
21  return nullptr;
22  }
23 
24  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const xAOD::MuonSegment& segment) {
25  using SimHitLinkVec = std::vector<ElementLink<xAOD::MuonSimHitContainer>>;
26  static const SG::ConstAccessor<SimHitLinkVec> acc{"simHitLinks"};
27  std::unordered_set<const xAOD::MuonSimHit*> hits{};
28  if (!acc.isAvailable(segment)){
29  return hits;
30  }
31  hits.reserve(acc(segment).size());
33  if (link.isValid()) {
34  hits.insert(*link);
35  }
36  }
37  return hits;
38  }
39 
40  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const std::vector<const SpacePoint*>& spacePoints) {
41  std::unordered_set<const xAOD::MuonSimHit*> hits{};
42  for (const SpacePoint* sp : spacePoints) {
43  const xAOD::MuonSimHit* primHit{getTruthMatchedHit(*sp->primaryMeasurement())};
44  const xAOD::MuonSimHit* secHit{sp->dimension() == 2 ? getTruthMatchedHit(*sp->secondaryMeasurement()) : nullptr};
45  if(primHit){
46  hits.insert(primHit);
47  }
48  if (secHit && secHit != primHit) {
49  hits.insert(secHit);
50  }
51  }
52  return hits;
53  }
54 
55  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const std::vector<const CalibratedSpacePoint*>& measurements) {
56  std::unordered_set<const xAOD::MuonSimHit*> hits{};
57  for (const CalibratedSpacePoint* meas : measurements) {
58  const SpacePoint* sp = meas->spacePoint();
59  if (!sp) continue;
61  const xAOD::MuonSimHit* secHit{sp->dimension() == 2 ? getTruthMatchedHit(*sp->secondaryMeasurement()) : nullptr};
62  if(primHit){
63  hits.insert(primHit);
64  }
65  if (secHit && secHit != primHit) {
66  hits.insert(secHit);
67  }
68  }
69  return hits;
70  }
71  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const Segment& segment) {
72  std::vector<const CalibratedSpacePoint*> calibSps{};
73  calibSps.reserve(segment.measurements().size());
74  std::ranges::transform(segment.measurements(), std::back_inserter(calibSps), [](const auto& meas){return meas.get();});
75  return getTruthMatchedHits(calibSps);
76  }
77  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const SpacePointBucket& bucket) {
78  std::vector<const SpacePoint*> spacePoints{};
79  spacePoints.reserve(bucket.size());
80  std::ranges::transform(bucket, std::back_inserter(spacePoints), [](const SpacePointBucket::value_type& sp){return sp.get();});
81  return getTruthMatchedHits(spacePoints);
82  }
83  std::unordered_set<const xAOD::MuonSimHit*> getTruthMatchedHits(const SegmentSeed& seed) {
84  return getTruthMatchedHits(seed.getHitsInMax());
85  }
86 }
87 
88 
MuonSimHitHelpers.h
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
MuonR4::SpacePointBucket
: The muon space point bucket represents a collection of points that will bre processed together in t...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:21
MuonR4::getTruthMatchedHits
std::unordered_set< const xAOD::MuonSimHit * > getTruthMatchedHits(const xAOD::MuonSegment &segment)
: Returns all truth hits matched to a xAOD::MuonSegment
Definition: MuonSimHitHelpers.cxx:24
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
SpacePoint.h
MuonR4::SpacePoint::secondaryMeasurement
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:110
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
MuonR4::SpacePoint::primaryMeasurement
const xAOD::UncalibratedMeasurement * primaryMeasurement() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:107
CalibratedSpacePoint.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
MuonSimHitContainer.h
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:18
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::CalibratedSpacePoint
The calibrated Space point is created during the calibration process.
Definition: CalibratedSpacePoint.h:15
MuonR4::SpacePoint::dimension
unsigned int dimension() const
Is the space point a 1D or combined 2D measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:157
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
MuonR4::getTruthMatchedHit
const xAOD::MuonSimHit * getTruthMatchedHit(const xAOD::UncalibratedMeasurement &prdHit)
Returns the MuonSimHit, if there's any, matched to the uncalibrated muon measurement.
Definition: MuonSimHitHelpers.cxx:13
Segment.h
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5