ATLAS Offline Software
MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 #include "GeoModelHelpers/throwExcept.h"
13 
14 namespace {
15  template<class MeasType> Amg::Transform3D toChamberTransform(const ActsGeometryContext& gctx,
16  const MeasType* unCalibMeas) {
17 
20  hash = unCalibMeas->measurementHash();
21  } else {
22  hash = unCalibMeas->layerHash();
23  }
24  return unCalibMeas->readoutElement()->getChamber()->globalToLocalTrans(gctx) *
25  unCalibMeas->readoutElement()->localToGlobalTrans(gctx, hash);
26  }
27 }
28 
29 namespace xAOD{
31  if (!meas) return nullptr;
33  return static_cast<const xAOD::MdtDriftCircle*>(meas)->readoutElement();
34  } else if (meas->type() == xAOD::UncalibMeasType::RpcStripType) {
35  return static_cast<const xAOD::RpcStrip*>(meas)->readoutElement();
36  } else if (meas->type() == xAOD::UncalibMeasType::TgcStripType) {
37  return static_cast<const xAOD::TgcStrip*>(meas)->readoutElement();
38  } else if (meas->type() == xAOD::UncalibMeasType::MMClusterType) {
39  return static_cast<const xAOD::MMCluster*>(meas)->readoutElement();
40  } else if (meas->type() == xAOD::UncalibMeasType::sTgcStripType) {
41  return static_cast<const xAOD::sTgcMeasurement*>(meas)->readoutElement();
42  }
43  THROW_EXCEPTION("Unsupported measurement given "<<typeid(*meas).name());
44  return nullptr;
45  }
46 
47 
49  const xAOD::UncalibratedMeasurement* meas){
50  if (!meas) return Amg::Vector3D::Zero();
51 
53  const xAOD::MdtDriftCircle* dc = static_cast<const xAOD::MdtDriftCircle*>(meas);
54  return toChamberTransform(gctx, dc).translation();
55  } else if (meas->type() == xAOD::UncalibMeasType::RpcStripType) {
56  const xAOD::RpcStrip* strip = static_cast<const xAOD::RpcStrip*>(meas);
57  return toChamberTransform(gctx, strip) *(strip->localPosition<1>()[0] * Amg::Vector3D::UnitX());
58  } else if (meas->type() == xAOD::UncalibMeasType::TgcStripType) {
59  const xAOD::TgcStrip* strip = static_cast<const xAOD::TgcStrip*>(meas);
60  return toChamberTransform(gctx, strip) *(strip->localPosition<1>()[0] * Amg::Vector3D::UnitX());
61  } else {
62  THROW_EXCEPTION("Measurement "<<typeid(*meas).name()<<" is not supported");
63  }
64  return Amg::Vector3D::Zero();
65  }
67  const xAOD::UncalibratedMeasurement* meas) {
68  if (!meas) return Amg::Vector3D::Zero();
70  const xAOD::MdtDriftCircle* dc = static_cast<const xAOD::MdtDriftCircle*>(meas);
71  return toChamberTransform(gctx,dc).linear() * Amg::Vector3D::UnitZ();
72  } else if (meas->type() == xAOD::UncalibMeasType::RpcStripType) {
73  const xAOD::RpcStrip* strip = static_cast<const xAOD::RpcStrip*>(meas);
74  return toChamberTransform(gctx, strip).linear() * Amg::Vector3D::UnitY();
75  } else if (meas->type() == xAOD::UncalibMeasType::TgcStripType) {
76  const xAOD::TgcStrip* strip = static_cast<const xAOD::TgcStrip*>(meas);
77  const Amg::Transform3D trf = toChamberTransform(gctx, strip);
78  Amg::Vector3D dir{Amg::Vector3D::UnitY()};
79  if (strip->measuresPhi()) {
80  dir.block<2,1>(0,0) = strip->readoutElement()->stripLayout(strip->gasGap()).stripDir(strip->channelNumber());
81  }
82  return trf.linear() *dir;
83  }
84  THROW_EXCEPTION("Measurement "<<typeid(*meas).name()<<" is not supported");
85  return Amg::Vector3D::Zero();
86  }
88  const UncalibratedMeasurement* meas) {
89 
91  const xAOD::MdtDriftCircle* dc = static_cast<const xAOD::MdtDriftCircle*>(meas);
92  return toChamberTransform(gctx,dc).linear() * Amg::Vector3D::UnitY();
93  } else if (meas->type() == xAOD::UncalibMeasType::RpcStripType) {
94  const xAOD::RpcStrip* strip = static_cast<const xAOD::RpcStrip*>(meas);
95  return toChamberTransform(gctx, strip).linear() * Amg::Vector3D::UnitX();
96  } else if (meas->type() == xAOD::UncalibMeasType::TgcStripType) {
97  const xAOD::TgcStrip* strip = static_cast<const xAOD::TgcStrip*>(meas);
98  const Amg::Transform3D trf = toChamberTransform(gctx, strip);
99  Amg::Vector3D dir{Amg::Vector3D::UnitX()};
100  if (strip->measuresPhi()) {
101  dir.block<2,1>(0,0) = strip->readoutElement()->stripLayout(strip->gasGap()).stripNormal(strip->channelNumber());
102  }
103  return trf.linear() *dir;
104  }
105  THROW_EXCEPTION("Measurement "<<typeid(*meas).name()<<" is not supported");
106  return Amg::Vector3D::Zero();
107  }
108 }
UtilFunctions.h
xAOD::MMCluster_v1
Definition: MMCluster_v1.h:16
xAOD::TgcStrip_v1
Definition: TgcStrip_v1.h:16
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
athena.value
value
Definition: athena.py:122
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
xAOD::UncalibMeasType::sTgcStripType
@ sTgcStripType
xAOD::RpcStrip_v1
Definition: RpcStrip_v1.h:11
xAOD::channelDirInChamber
Amg::Vector3D channelDirInChamber(const ActsGeometryContext &gctx, const xAOD::UncalibratedMeasurement *meas)
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:66
RpcStrip.h
xAOD::UncalibMeasType::TgcStripType
@ TgcStripType
AccessorMacros.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::positionInChamber
Amg::Vector3D positionInChamber(const ActsGeometryContext &gctx, const xAOD::UncalibratedMeasurement *meas)
Returns the position of the uncalibrated muon measurement in the attached Muon chamber frame.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:48
xAOD::channelNormalInChamber
Amg::Vector3D channelNormalInChamber(const ActsGeometryContext &gctx, const UncalibratedMeasurement *meas)
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:87
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonChamber.h
xAOD::readoutElement
const MuonGMR4::MuonReadoutElement * readoutElement(const UncalibratedMeasurement *meas)
Returns the associated readout element to the measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:30
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:28
MdtDriftCircle.h
beamspotman.dir
string dir
Definition: beamspotman.py:623
TgcStrip.h
sTgcMeasurement.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
MMCluster.h
CaloLCW_tf.trf
trf
Definition: CaloLCW_tf.py:20
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:18
IdentifierHash
Definition: IdentifierHash.h:38
xAOD::UncalibMeasType::RpcStripType
@ RpcStripType
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
xAOD::sTgcMeasurement_v1
Definition: sTgcMeasurement_v1.h:19
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32