ATLAS Offline Software
MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 #include "GeoModelKernel/throwExcept.h"
6 
14 
25 
26 
27 namespace {
28  template <class MeasType> const Acts::Surface& fetchSurface(const xAOD::UncalibratedMeasurement* meas) {
29  auto castedM = static_cast<const MeasType*>(meas);
31  if constexpr(std::is_same_v<xAOD::MdtDriftCircle, MeasType>) {
32  hash = castedM->measurementHash();
33  } else {
34  hash = castedM->layerHash();
35  }
36  return castedM->readoutElement()->surface(hash);
37  }
38 }
39 
40 namespace xAOD{
42  if (!meas) return nullptr;
44  if (meas->numDimensions() == 0u) {
45  const auto* comp = static_cast<const CombinedMuonStrip*>(meas);
46  return muonReadoutElement(comp->primaryStrip());
47  }
48  switch (meas->type()) {
49  using enum UncalibMeasType;
50  case MdtDriftCircleType: {
51  return static_cast<const MdtDriftCircle*>(meas)->readoutElement();
52  } case RpcStripType: {
53  return static_cast<const RpcMeasurement*>(meas)->readoutElement();
54  } case TgcStripType: {
55  return static_cast<const TgcStrip*>(meas)->readoutElement();
56  } case sTgcStripType: {
57  return static_cast<const sTgcMeasurement*>(meas)->readoutElement();
58  } case MMClusterType: {
59  return static_cast<const MMCluster*>(meas)->readoutElement();
60  } default:
61 #ifndef NDEBUG
62  THROW_EXCEPTION("Unsupported measurement given "<<typeid(*meas).name());
63 #endif
64  break;
65  }
66  return nullptr;
67  }
68  const Acts::Surface& muonSurface(const UncalibratedMeasurement* meas) {
69  if (!meas) {
70  THROW_EXCEPTION("No measurement passed");
71  }
73  if (meas->numDimensions() == 0u) {
74  const auto* comp = static_cast<const CombinedMuonStrip*>(meas);
75  return muonSurface(comp->primaryStrip());
76  }
77  switch (meas->type()) {
78  using enum UncalibMeasType;
79  case MdtDriftCircleType: {
80  return fetchSurface<MdtDriftCircle>(meas);
81  } case RpcStripType: {
82  return fetchSurface<RpcMeasurement>(meas);
83  } case TgcStripType:{
84  return fetchSurface<TgcStrip>(meas);
85  } case sTgcStripType: {
86  return fetchSurface<sTgcMeasurement>(meas);
87  } case MMClusterType:{
88  return fetchSurface<MMCluster>(meas);
89  } default:
90  THROW_EXCEPTION("Unsupported measurement given "<<typeid(*meas).name());
91  break;
92  }
93  }
94 
96  static const Identifier detId{};
97  if (!meas) {
98  return detId;
99  }
101  if (meas->numDimensions() == 0u) {
102  const auto* comp = static_cast<const CombinedMuonStrip*>(meas);
103  return identify(comp->primaryStrip());
104  }
105  switch (meas->type()) {
106  using enum UncalibMeasType;
107  case MdtDriftCircleType: {
108  return static_cast<const MdtDriftCircle*>(meas)->identify();
109  } case RpcStripType: {
110  return static_cast<const RpcMeasurement*>(meas)->identify();
111  } case TgcStripType: {
112  return static_cast<const TgcStrip*>(meas)->identify();
113  } case MMClusterType: {
114  return static_cast<const MMCluster*>(meas)->identify();
115  } case sTgcStripType: {
116  return static_cast<const sTgcMeasurement*>(meas)->identify();
117  } case Other: {
118  return detId;
119  } default: {
120  THROW_EXCEPTION("Unsupported measurement given "<<typeid(*meas).name());
121  break;
122  }
123  }
124  return detId;
125  }
127  if (!meas) {
128  return IdentifierHash{};
129  }
131  if (meas->numDimensions() == 0u) {
132  const auto* comp = static_cast<const CombinedMuonStrip*>(meas);
133  return layerHash(comp->primaryStrip());
134  }
135  switch (meas->type()) {
136  using enum UncalibMeasType;
137  case MdtDriftCircleType: {
138  return static_cast<const MdtDriftCircle*>(meas)->measurementHash();
139  } case RpcStripType: {
140  return static_cast<const RpcMeasurement*>(meas)->layerHash();
141  } case TgcStripType: {
142  return static_cast<const TgcStrip*>(meas)->layerHash();
143  } case MMClusterType: {
144  return static_cast<const MMCluster*>(meas)->layerHash();
145  } case sTgcStripType: {
146  return static_cast<const sTgcMeasurement*>(meas)->layerHash();
147  } case Other: {
148  break;
149  } default: {
150  THROW_EXCEPTION("Unsupported measurement given "<<typeid(*meas).name());
151  break;
152  }
153  }
154  return IdentifierHash{};
155  }
156 }
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:23
xAOD::RpcMeasurement_v1
RpcMeasurement_v1: Class storing the geneic.
Definition: RpcMeasurement_v1.h:21
xAOD::identify
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:95
UtilFunctions.h
xAOD::MMCluster_v1
Definition: MMCluster_v1.h:20
xAOD::TgcStrip_v1
Definition: TgcStrip_v1.h:19
xAOD::UncalibMeasType::MMClusterType
@ MMClusterType
MuonGMR4::MuonReadoutElement
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:38
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
MdtTwinDriftCircle.h
RpcStrip2D.h
xAOD::UncalibMeasType::sTgcStripType
@ sTgcStripType
SpectrometerSector.h
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
RpcStrip.h
xAOD::UncalibMeasType::TgcStripType
@ TgcStripType
GeoPrimitives.h
sTgcReadoutElement.h
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
xAOD::UncalibratedMeasurement_v1::type
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
xAOD::Other
@ Other
Definition: TrackingPrimitives.h:560
MeasurementDefs.h
MdtDriftCircle.h
xAOD::UncalibratedMeasurement_v1::numDimensions
virtual unsigned int numDimensions() const =0
Returns the number of dimensions of the measurement.
TgcStrip.h
sTgcMeasurement.h
RpcMeasurement.h
xAOD::muonSurface
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:68
THROW_EXCEPTION
#define THROW_EXCEPTION(MESSAGE)
Definition: throwExcept.h:10
RpcReadoutElement.h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
xAOD::CombinedMuonStrip_v1
The Acts fitters running on the Uncalibrated measurements are uncapable of producing two track states...
Definition: CombinedMuonStrip_v1.h:19
MdtReadoutElement.h
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:25
MMCluster.h
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
xAOD::muonReadoutElement
const MuonGMR4::MuonReadoutElement * muonReadoutElement(const UncalibratedMeasurement *meas)
Returns the associated readout element to the measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:41
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TgcReadoutElement.h
xAOD::UncalibMeasType::RpcStripType
@ RpcStripType
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
xAOD::layerHash
IdentifierHash layerHash(const UncalibratedMeasurement *meas)
Returns the layer hash from an uncalibrated meaurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:126
MmReadoutElement.h
xAOD::sTgcMeasurement_v1
Definition: sTgcMeasurement_v1.h:21
CombinedMuonStrip.h
Identifier
Definition: IdentifierFieldParser.cxx:14