ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGeoUtilitiyTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
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
32using namespace ActsTrk;
33namespace MuonGMR4{
34
36
37const GeoShape* MuonGeoUtilityTool::extractShape(const PVConstLink& physVol) const {
38 return extractShape(physVol->getLogVol()->getShape());
39}
40const 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}
57std::string MuonGeoUtilityTool::dumpShape(const GeoShape* shape) const { return printGeoShape(shape); }
58std::string MuonGeoUtilityTool::dumpVolume(const PVConstLink& physVol) const { return printVolume(physVol); }
59const 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
80std::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}
85std::vector<const GeoShape*> MuonGeoUtilityTool::getComponents(const GeoShape* booleanShape) const {
86 return getBooleanComponents(booleanShape);
87}
88
89std::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
99std::vector<Amg::Vector3D> MuonGeoUtilityTool::shapeEdges(const GeoShape* shape,
100 const Amg::Transform3D& refTrf) const {
101 return getPolyShapeEdges(shape, refTrf);
102}
103
104
105}
#define ATH_MSG_VERBOSE(x)
std::string dumpShape(const GeoShape *inShape) const override final
Dumps the shape to string.
std::vector< const GeoShape * > getComponents(const GeoShape *booleanShape) const override final
const GeoAlignableTransform * findAlignableTransform(const PVConstLink &physVol) const override final
const GeoShape * extractShape(const PVConstLink &physVol) const override final
virtual ~MuonGeoUtilityTool() override final
std::vector< Amg::Vector3D > shapeEdges(const GeoShape *shape, const Amg::Transform3D &refTrf) const override
std::string dumpVolume(const PVConstLink &physVol) const override final
std::vector< physVolWithTrans > findAllLeafNodesByName(const PVConstLink &physVol, const std::string &volumeName) const override final
std::vector< Amg::Vector2D > polygonEdges(const GeoSimplePolygonBrep &polygon) const override
Transforms the vertices of the Polygon shape into a std::vector consisting of Amg::Vector2D objects.
Definition node.h:24
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Eigen::Affine3d Transform3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans