ATLAS Offline Software
MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  A Muon GeoVDetectorElement
7  -----------------------------------------
8 ***************************************************************************/
9 
11 
12 #include "GeoModelKernel/GeoDefinitions.h"
13 #include "GeoModelKernel/GeoPhysVol.h"
14 #include "GeoModelKernel/GeoTransform.h"
20 
21 namespace {
22  std::string to_string(const Trk::DetectorElemType type ) {
23  if (type == Trk::DetectorElemType::Mdt) return "Mdt";
24  else if (type == Trk::DetectorElemType::Rpc) return "Rpc";
25  else if (type == Trk::DetectorElemType::Tgc) return "Tgc";
26  else if (type == Trk::DetectorElemType::sTgc) return "sTgc";
27  else if (type == Trk::DetectorElemType::MM) return "Mm";
28  else if (type == Trk::DetectorElemType::Csc) return "Csc";
29  return "Unknown";
30  }
31 }
32 namespace MuonGM {
33 
35  TrkDetElementBase(pv),
36  AthMessaging{to_string(detType)+"MuonReadoutElement"},
37  m_type{detType},
38  m_muon_mgr{mgr} {
39  if (!m_idHelperSvc.retrieve().isSuccess()) {
40  ATH_MSG_FATAL("Failed to retrieve the MuonIdHelperSvc");
41  throw std::runtime_error("Invalid MuonIdHelperSvc");
42  }
43  }
44 
46 
47  const Amg::Vector3D MuonReadoutElement::globalPosition() const { return absTransform().translation(); }
48 
50  // this doesn't apply to TGC
51  if(m_statname.size() >= 3){
52  char c = m_statname[2];
53  if (c == 'L')
54  return true;
55  else if (c == 'S')
56  return false;
57  else {
58  if (c == 'E' || c == 'F' || c == 'G') return false;
59  if (c == 'M' || c == 'R') return true;
60  }
61  }
62  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" largeSector() - is this station a larger sector answer is no for readout element "<<m_idHelperSvc->toStringDetEl(identify()));
63  throw std::runtime_error("Unknown sector");
64  return false;
65  }
66 
68  // this doesn't apply to TGC
69  return (!largeSector());
70  }
71 
72  void MuonReadoutElement::setParentStationPV(const PVConstLink& x) {
75  }
76 
78  if (m_parentStationPV) return;
79 
80  std::string::size_type npos;
81  PVConstLink pStat = PVConstLink(nullptr);
82  PVConstLink myphysvol(getMaterialGeom());
83 
84  std::string name = (myphysvol->getLogVol())->getName();
85  if ((npos = name.find("Station")) != std::string::npos) {
86  pStat = myphysvol;
87  } else {
88  for (unsigned int k = 0; k < 10; k++) {
89  pStat = myphysvol->getParent();
90  if (pStat == PVConstLink(nullptr)) break;
91  name = (pStat->getLogVol())->getName();
92  if ((npos = name.find("Station")) != std::string::npos) { break; }
93  myphysvol = pStat;
94  }
95  }
96  m_parentStationPV = pStat;
98  }
99 
101 
103 
105  PVConstLink par = parentStationPV();
106  if (par == PVConstLink(nullptr)) {
107  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" No parent station found for "<<m_idHelperSvc->toStringDetEl(identify()));
108  throw std::runtime_error("Parent station is a nullptr");
109  }
110  Query<unsigned int> c = par->indexOf(getMaterialGeom());
111  if (c.isValid()) {
113  } else
115  }
116 
118  PVConstLink par = parentStationPV();
119  if (par == PVConstLink(nullptr)) {
120  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" No parent station found for "<<m_idHelperSvc->toStringDetEl(identify()));
121  throw std::runtime_error("Parent station is a nullptr");
122  }
123 
124  if (m_indexOfREinMuonStation >= 0) return par->getXToChildVol((unsigned int)m_indexOfREinMuonStation);
125  return GeoTrf::Transform3D::Identity();
126  }
127 
129  m_parentMuonStation = mstat;
130  if (mstat->getPhysVol()) {
131  setParentStationPV(mstat->getPhysVol());
132  }
133  }
134 
136 
138  return parentMuonStation()->getTransform().translation();
139  }
140 
142  return AmdbLRSToGlobalTransform() * x;
143  }
144 
147  }
148 
150  return GlobalToAmdbLRSTransform() * x;
151  }
152 
155  }
157  m_id = id;
158  if (!m_idHelperSvc->isMuon(id)) {
159  ATH_MSG_FATAL("The Identifier "<<m_idHelperSvc->toString(id)<<" is not a muon one.");
160  throw std::runtime_error("Invalid Identifier set");
161  }
162  m_stIdx = m_idHelperSvc->stationName(id);
163  m_eta = m_idHelperSvc->stationEta(id);
164  m_phi = m_idHelperSvc->stationPhi(id);
165  m_idhash = m_idHelperSvc->moduleHash(id);
166  m_detectorElIdhash = m_idHelperSvc->detElementHash(id);
167  }
168  void MuonReadoutElement::setTechnologyName(const std::string& str) { m_techname = str; }
169  void MuonReadoutElement::setStationName(const std::string& str) { m_statname = str; }
178  clearCache();
179  fillCache();
180  }
181 } // namespace MuonGM
MuonGM::MuonReadoutElement::AmdbLRSToGlobalTransform
virtual Amg::Transform3D AmdbLRSToGlobalTransform() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:145
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
MuonGM::MuonReadoutElement::m_statname
std::string m_statname
examples are BMS5, CSS1, EML1
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:154
MuonGM::MuonReadoutElement::setZsize
void setZsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:176
MuonGM::MuonReadoutElement::absTransform
const Amg::Transform3D & absTransform() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:210
MuonGM::MuonReadoutElement::m_id
Identifier m_id
extended data-collection identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:165
MuonGM::MuonReadoutElement::smallSector
bool smallSector() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:67
MuonGM::MuonReadoutElement::m_techname
std::string m_techname
MDT or RPC or TGC or CSC plus a two digits subtype; example RPC17.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:152
StraightLineSurface.h
MuonGM::MuonReadoutElement::m_Zsize
double m_Zsize
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:145
MuonGM::MuonReadoutElement::m_LongRsize
double m_LongRsize
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:147
MuonGM::MuonReadoutElement::m_eta
int m_eta
Identifier field of the station eta.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:175
MuonGM::MuonReadoutElement::m_detectorElIdhash
IdentifierHash m_detectorElIdhash
detector element hash identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:167
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonGM::MuonReadoutElement::fillCache
virtual void fillCache()=0
MuonGM::MuonStation::getPhysVol
PVConstLink getPhysVol() const
Definition: MuonStation.cxx:383
Trk::DetectorElemType::Tgc
@ Tgc
MuonGM::MuonReadoutElement::largeSector
bool largeSector() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:49
MuonGM::MuonReadoutElement::GlobalToAmdbLRSTransform
virtual Amg::Transform3D GlobalToAmdbLRSTransform() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:153
MuonGM::MuonStation::getTransform
Amg::Transform3D getTransform() const
Definition: MuonStation.h:169
MuonGM::MuonReadoutElement::m_Ssize
double m_Ssize
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:143
MuonGM::MuonReadoutElement::setParentStationPV
void setParentStationPV()
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:77
MuonGM::MuonReadoutElement::setLongRsize
void setLongRsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:172
MuonGM::MuonReadoutElement::m_parentMuonStation
const MuonStation * m_parentMuonStation
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:180
MuonGM::MuonReadoutElement::m_stationS
double m_stationS
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:171
MuonGM::MuonReadoutElement::setSsize
void setSsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:174
x
#define x
MuonGM::MuonReadoutElement::setIndexOfREinMuonStation
void setIndexOfREinMuonStation()
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:104
Trk::DetectorElemType::Csc
@ Csc
MuonGM::MuonReadoutElement::m_phi
int m_phi
Identifier field of the station phi.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:177
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
MuonGM::MuonReadoutElement::setRsize
void setRsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:175
GeoPrimitives.h
MuonGM::MuonReadoutElement::refreshCache
void refreshCache()
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:177
MuonGM::MuonReadoutElement::clearCache
virtual void clearCache()=0
MuonGM::MuonReadoutElement::GlobalToAmdbLRSCoords
virtual Amg::Vector3D GlobalToAmdbLRSCoords(const Amg::Vector3D &x) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:149
MuonGM::MuonReadoutElement::m_Rsize
double m_Rsize
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:144
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
MuonGM::MuonReadoutElement::setIdentifier
void setIdentifier(const Identifier &id)
Sets the Identifier, hashes & station names.
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:156
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:135
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGM::MuonStation
Definition: MuonStation.h:51
MuonGM::MuonReadoutElement::m_parentStationPV
PVConstLink m_parentStationPV
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:179
MuonGM::MuonReadoutElement::setTechnologyName
void setTechnologyName(const std::string &str)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:168
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonGM::MuonStation::getNativeToAmdbLRS
const Amg::Transform3D & getNativeToAmdbLRS() const
Definition: MuonStation.h:182
Trk::DetectorElemType
DetectorElemType
Definition: TrkDetElementBase.h:39
MuonReadoutElement.h
MuonGM::MuonReadoutElement::globalPosition
const Amg::Vector3D globalPosition() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:47
MuonGM::MuonReadoutElement::setLongSsize
void setLongSsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:171
MuonGM::MuonReadoutElement::getIndexOfREinMuonStation
int getIndexOfREinMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:102
MuonGM::MuonReadoutElement::setStationName
void setStationName(const std::string &)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:169
MuonGM::MuonReadoutElement::m_LongSsize
double m_LongSsize
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:146
Trk::DetectorElemType::sTgc
@ sTgc
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
MuonGM::MuonReadoutElement::m_idhash
IdentifierHash m_idhash
data-collection hash identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:166
MuonGM::MuonReadoutElement::setLongZsize
void setLongZsize(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:173
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
MuonGM::MuonReadoutElement::m_LongZsize
double m_LongZsize
size in the specified direction
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:148
python.PyAthena.v
v
Definition: PyAthena.py:157
CylinderBounds.h
MuonGM::MuonReadoutElement::toParentStation
Amg::Transform3D toParentStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:117
Trk::DetectorElemType::MM
@ MM
MuonGM::MuonReadoutElement::AmdbLRSToGlobalCoords
virtual Amg::Vector3D AmdbLRSToGlobalCoords(const Amg::Vector3D &x) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:141
Trk::DetectorElemType::Rpc
@ Rpc
MuonGM::MuonReadoutElement::~MuonReadoutElement
virtual ~MuonReadoutElement()
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
MuonGM::MuonReadoutElement::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:163
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonGM::MuonReadoutElement::identify
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:184
python.changerun.pv
pv
Definition: changerun.py:81
str
Definition: BTagTrackIpAccessor.cxx:11
MuonGM::MuonReadoutElement::m_indexOfREinMuonStation
int m_indexOfREinMuonStation
index of this RE in the mother MuonStation
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:169
MuonGM::MuonReadoutElement::m_stIdx
int m_stIdx
Identifier field of the station index.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:173
MuonGM::MuonReadoutElement::parentMuonStationPos
Amg::Vector3D parentMuonStationPos() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:137
MuonStation.h
python.compressB64.c
def c
Definition: compressB64.py:93
MuonGM::MuonReadoutElement::MuonReadoutElement
MuonReadoutElement(GeoVFullPhysVol *pv, MuonDetectorManager *mgr, Trk::DetectorElemType detType)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:34
MuonGM::MuonReadoutElement::parentStationPV
PVConstLink parentStationPV() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:100
MuonGM::MuonReadoutElement::setParentMuonStation
void setParentMuonStation(const MuonStation *)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:128
Trk::DetectorElemType::Mdt
@ Mdt
fitman.k
k
Definition: fitman.py:528
MuonGM::MuonReadoutElement::setStationS
void setStationS(double)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:170