ATLAS Offline Software
MuonGeoUtilitiyTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "MuonGeoUtilityTool.h"
5 
7 #include <GeoModelKernel/GeoBox.h>
8 #include <GeoModelKernel/GeoTrd.h>
9 #include <GeoModelKernel/GeoSimplePolygonBrep.h>
10 
11 #include <GeoModelKernel/GeoTube.h>
12 
13 #include <GeoModelKernel/GeoShapeUnion.h>
14 #include <GeoModelKernel/GeoShapeIntersection.h>
15 #include <GeoModelKernel/GeoShapeSubtraction.h>
16 #include <GeoModelKernel/GeoShapeShift.h>
17 
18 #include <GeoModelKernel/GeoTransform.h>
19 
20 #include <GeoModelKernel/GeoVolumeCursor.h>
21 
22 #include <GeoModelHelpers/GeoShapeUtils.h>
23 #include <GeoModelHelpers/printVolume.h>
24 #include <GeoModelHelpers/TransformToStringConverter.h>
25 
26 
27 #include <set>
28 #include <sstream>
29 #include <string>
30 
31 
32 using namespace ActsTrk;
33 namespace MuonGMR4{
34 
35 MuonGeoUtilityTool::~MuonGeoUtilityTool() = default;
36 
37 const GeoShape* MuonGeoUtilityTool::extractShape(const PVConstLink& physVol) const {
38  return extractShape(physVol->getLogVol()->getShape());
39 }
40 const GeoShape* MuonGeoUtilityTool::extractShape(const GeoShape* inShape) const {
41 
42  if (inShape->typeID() == GeoShapeShift::getClassTypeID()) {
43  const auto shift = dynamic_pointer_cast<const GeoShapeShift>(compressShift(inShape));
44  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<
45  "Shape is a shift by "<<GeoTrf::toString(shift->getX())
46  << ". Continue navigation "<<printGeoShape(shift));
47  return extractShape(shift->getOp());
48  }
49  if (inShape->typeID() == GeoShapeSubtraction::getClassTypeID()){
50  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<
51  "Shape is a subtraction. Extract the basic shape. Continue navigation "<<inShape);
52  const GeoShapeSubtraction* subtract = static_cast<const GeoShapeSubtraction*>(inShape);
53  return extractShape(subtract->getOpA());
54  }
55  return inShape;
56 }
57 std::string MuonGeoUtilityTool::dumpShape(const GeoShape* shape) const { return printGeoShape(shape); }
58 std::string MuonGeoUtilityTool::dumpVolume(const PVConstLink& physVol) const { return printVolume(physVol); }
59 const GeoAlignableTransform* MuonGeoUtilityTool::findAlignableTransform(const PVConstLink& physVol) const {
60  PVConstLink parent{physVol->getParent()}, child{physVol};
61  while (parent) {
62  const GeoGraphNode * const * node1 = parent->findChildNode(child);
63  const GeoGraphNode * const * fence = parent->getChildNode(0);
64  for(const GeoGraphNode * const * current = node1 - 1; current>=fence; current--) {
65  const GeoGraphNode* node{*current};
66  if (dynamic_cast<const GeoVPhysVol*>(node)) {
67  break;
68  }
69  const GeoAlignableTransform* alignTrans{dynamic_cast<const GeoAlignableTransform*>(node)};
70  if (alignTrans) {
71  return alignTrans;
72  }
73  }
74  child = parent;
75  parent = child->getParent();
76  }
77  return nullptr;
78 }
79 
80 std::vector<MuonGeoUtilityTool::physVolWithTrans> MuonGeoUtilityTool::findAllLeafNodesByName(const PVConstLink& physVol, const std::string& volumeName) const {
81  return getAllSubVolumes(physVol,[&volumeName](const physVolWithTrans& child){
82  return child.volume->getLogVol()->getName() == volumeName || child.nodeName == volumeName;
83  });
84 }
85 std::vector<const GeoShape*> MuonGeoUtilityTool::getComponents(const GeoShape* booleanShape) const {
86  return getBooleanComponents(booleanShape);
87 }
88 
89 std::vector<Amg::Vector2D> MuonGeoUtilityTool::polygonEdges(const GeoSimplePolygonBrep& polygon) const {
90  std::vector<Amg::Vector2D> polygonEdges{};
91  polygonEdges.reserve(polygon.getNVertices());
92  for (unsigned int i = 0; i < polygon.getNVertices(); ++i) {
93  polygonEdges.emplace_back(polygon.getXVertex(i), polygon.getYVertex(i));
94  ATH_MSG_VERBOSE("Polygon vertext point " << i << ": "<< GeoTrf::toString(polygonEdges.back(), 2));
95  }
96  return polygonEdges;
97 }
98 
99 std::vector<Amg::Vector3D> MuonGeoUtilityTool::shapeEdges(const GeoShape* shape,
100  const Amg::Transform3D& refTrf) const {
101  return getPolyShapeEdges(shape, refTrf);
102 }
103 
104 
105 }
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
MuonGeoUtilityTool.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
dumpTruth.getName
getName
Definition: dumpTruth.py:34
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonGMR4
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Definition: MdtCalibInput.h:19
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
MuonGMR4::physVolWithTrans
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
Definition: MdtReadoutGeomTool.cxx:31
MuonDetectorDefs.h
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
node
Definition: node.h:21