ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace 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}
Visitor to process all volumes under a GeoModel node.
static Double_t a
Helper struct to retrieve the tube lengths and the tube centers directly from the GeoModel tree.
Amg::Vector3D m_tubePitch
MdtTubeLayer(const PVConstLink layer, const GeoIntrusivePtr< const GeoTransform > toLayTrf, const CutTubeSet &cutTubes)
Standard constructor of a MdtTube layer.
PVConstLink getTubeNode(unsigned int tube) const
returns the PVConst link to the n-th tube [0 - nTubes() -1]
const Amg::Transform3D & layerTransform() const
: Returns the transformation from the layer to the muon station
std::set< CutTubes, std::less<> > CutTubeSet
unsigned int nTubes() const
Returns the number of tubes in the layer.
const Amg::Vector3D tubePosInLayer(const unsigned int tube) const
Returns the tube position within the given tube layer.
const Amg::Transform3D tubeTransform(const unsigned int tube) const
Returns the transformation of the tube to the muon station Index counting [0 - nTubes()-1].
TubePositionerSet m_tubePos
double tubeHalfLength(const unsigned int tube) const
Returns the half-length of the given tube.
double uncutHalfLength(const unsigned int tube) const
Returns the uncut-half length of the given tube.
GeoIntrusivePtr< const GeoTransform > m_layTrf
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
bool operator<(const MdtTubeLayer::CutTubes &a, const unsigned int tube)
GeoModel::TransientConstSharedPtr< MdtTubeLayer > MdtTubeLayerPtr
STL namespace.
bool operator()(const MdtTubeLayer &a, const MdtTubeLayer &b) const
Constructor taking the GeoModel parent node of the tube nodes.
Helper struct to avoid browsing with the serial transformer.
unsigned int firstTube
First tube of the positioning.
unsigned int lastTube
Last tube of the positioning.
Amg::Vector3D firstTubePos
Transform to reach the first tube.
PVConstLink tubeVol
Underlying physical volume of the tube.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10