ATLAS Offline Software
MdtTubeLayer.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 <GeoModelKernel/GeoTube.h>
6 #include <GeoModelKernel/GeoAccessVolumeAction.h>
7 
8 #include <GeoModelHelpers/TransformSorter.h>
9 #include <GeoModelHelpers/GeoPhysVolSorter.h>
10 #include <GeoModelHelpers/getChildNodesWithTrf.h>
12 
13 
14 namespace MuonGMR4{
15  bool operator<(const MdtTubeLayer::CutTubes& a, const unsigned int tube){
16  return a.lastTube < tube;
17  }
18  bool operator<(const unsigned int tube, const MdtTubeLayer::CutTubes& a) {
19  return tube < a.firstTube;
20  }
21  bool operator<(const MdtTubeLayer::TubePositioner&a,const unsigned int tube) {
22  return a.lastTube < tube;
23  }
24  bool operator<(const unsigned int tube, const MdtTubeLayer::TubePositioner& a) {
25  return tube < a.firstTube;
26  }
27 
29  // Don't bother calling the underlying comparisons
30  // if the objects are the same. This saves a lot of time.
31  if (a.m_layTrf != b.m_layTrf) {
32  static const GeoTrf::TransformSorter trfSort{};
33  const int trfCmp = trfSort.compare(a.layerTransform(), b.layerTransform());
34  if (trfCmp) return trfCmp < 0;
35  }
36  if (a.m_layerNode != b.m_layerNode) {
37  static const GeoPhysVolSorter physSort{};
38  return physSort(a.m_layerNode, b.m_layerNode);
39  }
40  return false;
41  }
43  return (*this)(*a, *b);
44  }
45 
46 
47  MdtTubeLayer::MdtTubeLayer(const PVConstLink layer,
48  const GeoIntrusivePtr<const GeoTransform> toLayTrf,
49  const CutTubeSet& cutTubes):
50  m_layerNode{std::move(layer)},
51  m_layTrf{std::move(toLayTrf)},
52  m_cutTubes{cutTubes} {
53 
54  const std::vector<GeoChildNodeWithTrf> children = getChildrenWithRef(m_layerNode, true);
55  unsigned int firstTube{0};
56  bool firstTubeSet{false};
57  for (const GeoChildNodeWithTrf& child : children) {
58  TubePositioner positioner{};
59  positioner.firstTube = firstTube;
60  positioner.lastTube = firstTube + child.nCopies -1;
61  positioner.firstTubePos = child.transform.translation();
62  positioner.tubeVol = child.volume;
63  if (!firstTubeSet && child.nCopies>1) {
64  m_tubePitch = child.inductionRule.translation();
65  firstTubeSet = true;
66  }
67  firstTube = positioner.lastTube + 1;
68  m_tubePos.insert(std::move(positioner));
69  }
70  }
72  return m_layTrf->getDefTransform();
73  }
74  PVConstLink MdtTubeLayer::getTubeNode(unsigned int tube) const {
75  TubePositionerSet::const_iterator tube_itr = m_tubePos.find(tube);
76  if (tube_itr == m_tubePos.end()) {
77  THROW_EXCEPTION(m_layerNode->getLogVol()->getName()<<" has only "<<nTubes()<<" tubes. But "
78  <<tube<<" is requested. Please check.");
79  }
80  return tube_itr->tubeVol;
81  }
82  const Amg::Transform3D MdtTubeLayer::tubeTransform(const unsigned int tube) const {
83  TubePositionerSet::const_iterator tube_itr = m_tubePos.find(tube);
84  if (tube_itr == m_tubePos.end()) {
85  THROW_EXCEPTION(m_layerNode->getLogVol()->getName()<<" has only "<<nTubes()<<" tubes. But "
86  <<tube<<" is requested. Please check.");
87  }
88  return layerTransform() * Amg::getTranslate3D(tube_itr->firstTubePos)*
89  Amg::getTranslate3D(1.*(tube-tube_itr->firstTube)* m_tubePitch);
90  }
91  const Amg::Vector3D MdtTubeLayer::tubePosInLayer(const unsigned int tube) const {
92  return layerTransform().inverse() * tubeTransform(tube).translation();
93  }
94  unsigned int MdtTubeLayer::nTubes() const {
95  return m_layerNode->getNChildVols();
96  }
97  double MdtTubeLayer::tubeHalfLength(const unsigned int tube) const {
98  TubePositionerSet::const_iterator tube_itr = m_tubePos.find(tube);
99  if (tube_itr == m_tubePos.end()) {
100  THROW_EXCEPTION(m_layerNode->getLogVol()->getName()<<" has only "<<nTubes()<<" tubes. But "
101  <<tube<<" is requested. Please check.");
102  }
103  const GeoShape* shape = tube_itr->tubeVol->getLogVol()->getShape();
104  const GeoTube* tubeShape = static_cast<const GeoTube*>(shape);
105  return tubeShape->getZHalfLength();
106  }
107  double MdtTubeLayer::uncutHalfLength(unsigned int tube) const{
108  CutTubeSet::const_iterator itr = m_cutTubes.find(tube);
109  if (itr!= m_cutTubes.end()) {
110  return itr->unCutHalfLength;
111  }
112  return tubeHalfLength(tube);
113  }
114 }
MuonGMR4::MdtTubeLayer::TubePositioner
Helper struct to avoid browsing with the serial transformer.
Definition: MdtTubeLayer.h:51
MuonGMR4::MdtTubeLayer::m_tubePitch
Amg::Vector3D m_tubePitch
Definition: MdtTubeLayer.h:98
GeoModel::TransientConstSharedPtr
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
Definition: TransientConstSharedPtr.h:13
MuonGMR4::MdtTubeLayer::layerTransform
const Amg::Transform3D & layerTransform() const
: Returns the transformation from the layer to the muon station
Definition: MdtTubeLayer.cxx:71
MuonGMR4::MdtTubeLayer
Helper struct to retrieve the tube lengths and the tube centers directly from the GeoModel tree.
Definition: MdtTubeLayer.h:28
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
MdtTubeLayer.h
GeoVisitVolumes.h
Visitor to process all volumes under a GeoModel node.
MuonGMR4
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Definition: MdtCalibInput.h:20
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGMR4::MdtTubeLayer::CutTubes
Constructor taking the GeoModel parent node of the tube nodes.
Definition: MdtTubeLayer.h:36
MuonGMR4::MdtTubeLayer::getTubeNode
PVConstLink getTubeNode(unsigned int tube) const
returns the PVConst link to the n-th tube [0 - nTubes() -1]
Definition: MdtTubeLayer.cxx:74
MuonGMR4::MdtTubeLayer::m_cutTubes
CutTubeSet m_cutTubes
Definition: MdtTubeLayer.h:96
MuonGMR4::MdtTubeLayerSorter::operator()
bool operator()(const MdtTubeLayer &a, const MdtTubeLayer &b) const
Definition: MdtTubeLayer.cxx:28
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MuonGMR4::operator<
bool operator<(const MdtTubeLayer::CutTubes &a, const unsigned int tube)
Definition: MdtTubeLayer.cxx:15
MuonGMR4::MdtTubeLayer::nTubes
unsigned int nTubes() const
Returns the number of tubes in the layer.
Definition: MdtTubeLayer.cxx:94
MuonGMR4::MdtTubeLayer::tubeHalfLength
double tubeHalfLength(const unsigned int tube) const
Returns the half-length of the given tube.
Definition: MdtTubeLayer.cxx:97
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGMR4::MdtTubeLayer::tubeTransform
const Amg::Transform3D tubeTransform(const unsigned int tube) const
Returns the transformation of the tube to the muon station Index counting [0 - nTubes()-1].
Definition: MdtTubeLayer.cxx:82
MuonGMR4::MdtTubeLayer::MdtTubeLayer
MdtTubeLayer(const PVConstLink layer, const GeoIntrusivePtr< const GeoTransform > toLayTrf, const CutTubeSet &cutTubes)
Standard constructor of a MdtTube layer.
Definition: MdtTubeLayer.cxx:47
MuonGMR4::MdtTubeLayer::m_tubePos
TubePositionerSet m_tubePos
Definition: MdtTubeLayer.h:97
MuonGMR4::MdtTubeLayer::m_layerNode
PVConstLink m_layerNode
Definition: MdtTubeLayer.h:94
a
TList * a
Definition: liststreamerinfos.cxx:10
python.DecayParser.children
children
Definition: DecayParser.py:32
MuonGMR4::MdtTubeLayer::CutTubeSet
std::set< CutTubes, std::less<> > CutTubeSet
Definition: MdtTubeLayer.h:48
MuonGMR4::MdtTubeLayer::m_layTrf
GeoIntrusivePtr< const GeoTransform > m_layTrf
Definition: MdtTubeLayer.h:95
MuonGMR4::MdtTubeLayer::tubePosInLayer
const Amg::Vector3D tubePosInLayer(const unsigned int tube) const
Returns the tube position within the given tube layer.
Definition: MdtTubeLayer.cxx:91
calibdata.tube
tube
Definition: calibdata.py:31
Amg::getTranslate3D
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Definition: GeoPrimitivesHelpers.h:289
MuonGMR4::MdtTubeLayer::uncutHalfLength
double uncutHalfLength(const unsigned int tube) const
Returns the uncut-half length of the given tube.
Definition: MdtTubeLayer.cxx:107