ATLAS Offline Software
Public Member Functions | Private Member Functions | List of all members
MuonGMR4::MuonGeoUtilityTool Class Referencefinal

#include <MuonGeoUtilityTool.h>

Inheritance diagram for MuonGMR4::MuonGeoUtilityTool:
Collaboration diagram for MuonGMR4::MuonGeoUtilityTool:

Public Member Functions

 MuonGeoUtilityTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~MuonGeoUtilityTool () override final
 
const GeoAlignableTransform * findAlignableTransform (const PVConstLink &physVol) const override final
 
const GeoShape * extractShape (const PVConstLink &physVol) const override final
 
const GeoShape * extractShape (const GeoShape *inShape) const override final
 
Amg::Transform3D extractShifts (const PVConstLink &physVol) const override final
 
Amg::Transform3D extractShifts (const GeoShape *inShape) const override final
 
std::vector< physVolWithTransfindAllLeafNodesByName (const PVConstLink &physVol, const std::string &volumeName) const override final
 
std::vector< const GeoShape * > getComponents (const GeoShape *booleanShape) const override final
 
std::string dumpShape (const GeoShape *inShape) const override final
 Dumps the shape to string. More...
 
std::string dumpVolume (const PVConstLink &physVol) const override final
 
std::vector< Amg::Vector2DpolygonEdges (const GeoSimplePolygonBrep &polygon) const override
 Transforms the vertices of the Polygon shape into a std::vector consisting of Amg::Vector2D objects. More...
 
std::vector< Amg::Vector3DshapeEdges (const GeoShape *shape, const Amg::Transform3D &refTrf) const override
 

Private Member Functions

std::string dumpVolume (const PVConstLink &physVol, const std::string &childDelim) const
 

Detailed Description

Definition at line 18 of file MuonGeoUtilityTool.h.

Constructor & Destructor Documentation

◆ MuonGeoUtilityTool()

MuonGMR4::MuonGeoUtilityTool::MuonGeoUtilityTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 34 of file MuonGeoUtilitiyTool.cxx.

35  :
36  base_class(type,name,parent) {}

◆ ~MuonGeoUtilityTool()

MuonGMR4::MuonGeoUtilityTool::~MuonGeoUtilityTool ( )
finaloverridevirtualdefault

Member Function Documentation

◆ dumpShape()

std::string MuonGMR4::MuonGeoUtilityTool::dumpShape ( const GeoShape *  inShape) const
finaloverride

Dumps the shape to string.

Definition at line 90 of file MuonGeoUtilitiyTool.cxx.

90 { return printGeoShape(shape); }

◆ dumpVolume() [1/2]

std::string MuonGMR4::MuonGeoUtilityTool::dumpVolume ( const PVConstLink &  physVol) const
finaloverride

Definition at line 91 of file MuonGeoUtilitiyTool.cxx.

91  {
92  return dumpVolume(physVol, "");
93 }

◆ dumpVolume() [2/2]

std::string MuonGMR4::MuonGeoUtilityTool::dumpVolume ( const PVConstLink &  physVol,
const std::string &  childDelim 
) const
private

Definition at line 94 of file MuonGeoUtilitiyTool.cxx.

94  {
95  std::stringstream sstr{};
96  if (!physVol || !physVol->getLogVol()){
97  ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" "<<__func__<<" No logical volume attached ");
98  return sstr.str();
99  }
100  const GeoShape* shape = extractShape(physVol);
101  if (!shape) {
102  ATH_MSG_WARNING(__FILE__<<":"<<__LINE__<<" "<<__func__
103  <<" Failed to extract shape from phys volume "
104  << physVol->getLogVol()->getName());
105  return sstr.str();
106  }
107  sstr<<"logical volume "<<physVol->getLogVol()->getName()<<", ";
108  if (physVol->isShared() || !physVol->getParent()){
109  sstr<<"shared volume, ";
110  } else {
111  const GeoVPhysVol* pv = physVol;
112  if (typeid(*pv) == typeid(GeoFullPhysVol)){
113  const Amg::Transform3D absTrans = static_cast<const GeoFullPhysVol&>(*physVol).getAbsoluteTransform();
114  sstr<<"absolute pos: "<<GeoTrf::toString(absTrans,true) << ", ";
115  } else{
116  sstr<<"relative pos: "<<GeoTrf::toString(physVol->getX(), true)<<", ";
117  }
118  }
119  sstr<<dumpShape(shape)<<", ";
120  const Amg::Transform3D shift = extractShifts(physVol);
121  if (!Amg::isIdentity(shift)) {
122  sstr<<" shape shifted by "<<GeoTrf::toString(shift, true);
123  }
124  sstr<<"number of children "<<physVol->getNChildVols()<<", "<<std::endl;
125  std::vector<GeoChildNodeWithTrf> children = getChildrenWithRef(physVol, false);
126  for (unsigned int child = 0; child < children.size(); ++child) {
127  sstr<<childDelim<<(child+1)<<": "<<GeoTrf::toString(children[child].transform, true)
128  <<", "<< dumpVolume(children[child].volume, childDelim + " ");
129  }
130  return sstr.str();
131 }

◆ extractShape() [1/2]

const GeoShape * MuonGMR4::MuonGeoUtilityTool::extractShape ( const GeoShape *  inShape) const
finaloverride

Definition at line 46 of file MuonGeoUtilitiyTool.cxx.

46  {
47 
48  if (!inShape) {
49  ATH_MSG_INFO(__FILE__<<":"<<__LINE__<<" "<<__func__<<" nullptr given ");
50  return nullptr;
51  }
52  if (inShape->typeID() == GeoShapeShift::getClassTypeID()) {
53  const GeoShapeShift* shift = dynamic_pointer_cast<const GeoShapeShift>(compressShift(inShape));
54  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<
55  "Shape is a shift by "<<GeoTrf::toString(shift->getX())
56  << ". Continue navigation "<<shift);
57  return extractShape(shift->getOp());
58  }
59  if (inShape->typeID() == GeoShapeSubtraction::getClassTypeID()){
60  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<
61  "Shape is a subtraction. Extract the basic shape. Continue navigation "<<inShape);
62  const GeoShapeSubtraction* subtract = static_cast<const GeoShapeSubtraction*>(inShape);
63  return extractShape(subtract->getOpA());
64  }
65  return inShape;
66 }

◆ extractShape() [2/2]

const GeoShape * MuonGMR4::MuonGeoUtilityTool::extractShape ( const PVConstLink &  physVol) const
finaloverride

Definition at line 38 of file MuonGeoUtilitiyTool.cxx.

38  {
39  const GeoLogVol* logVol = physVol->getLogVol();
40  if (!logVol) {
41  ATH_MSG_ERROR(__FILE__<<":"<<__LINE__<<" Physical volume has no logical volume attached ");
42  return nullptr;
43  }
44  return extractShape(logVol->getShape());
45 }

◆ extractShifts() [1/2]

Amg::Transform3D MuonGMR4::MuonGeoUtilityTool::extractShifts ( const GeoShape *  inShape) const
finaloverride

Definition at line 76 of file MuonGeoUtilitiyTool.cxx.

76  {
77  if (!inShape) {
78  ATH_MSG_ERROR(__FILE__<<":"<<__LINE__<<" "<<__func__<<" nullptr given ");
79  return Amg::Transform3D::Identity();
80  }
81  Amg::Transform3D sumTrans{Amg::Transform3D::Identity()};
82  if (inShape->typeID() == GeoShapeShift::getClassTypeID()) {
83  const GeoShapeShift* shift = dynamic_pointer_cast<const GeoShapeShift>(compressShift(inShape));
84  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Shape is a shift . Continue navigation "<<shift);
85  sumTrans = shift->getX();
86  }
87  ATH_MSG_VERBOSE(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Extacted transformation "<<GeoTrf::toString(sumTrans));
88  return sumTrans;
89 }

◆ extractShifts() [2/2]

Amg::Transform3D MuonGMR4::MuonGeoUtilityTool::extractShifts ( const PVConstLink &  physVol) const
finaloverride

Definition at line 67 of file MuonGeoUtilitiyTool.cxx.

67  {
68  const GeoLogVol* logVol = physVol->getLogVol();
69  if (!logVol) {
70  ATH_MSG_ERROR(__FILE__<<":"<<__LINE__<<" Physical volume has no logical volume attached. ");
71  return Amg::Transform3D::Identity();
72  }
73  return extractShifts(logVol->getShape());
74 }

◆ findAlignableTransform()

const GeoAlignableTransform * MuonGMR4::MuonGeoUtilityTool::findAlignableTransform ( const PVConstLink &  physVol) const
finaloverride

Definition at line 133 of file MuonGeoUtilitiyTool.cxx.

133  {
134  PVConstLink parent{physVol->getParent()}, child{physVol};
135  while (parent) {
136  const GeoGraphNode * const * node1 = parent->findChildNode(child);
137  const GeoGraphNode * const * fence = parent->getChildNode(0);
138  for(const GeoGraphNode * const * current = node1 - 1; current>=fence; current--) {
139  const GeoGraphNode* node{*current};
140  if (dynamic_cast<const GeoVPhysVol*>(node)) break;
141  const GeoAlignableTransform* alignTrans{dynamic_cast<const GeoAlignableTransform*>(node)};
142  if (alignTrans) return alignTrans;
143  }
144  child = parent;
145  parent = child->getParent();
146  }
147  return nullptr;
148 }

◆ findAllLeafNodesByName()

std::vector< MuonGeoUtilityTool::physVolWithTrans > MuonGMR4::MuonGeoUtilityTool::findAllLeafNodesByName ( const PVConstLink &  physVol,
const std::string &  volumeName 
) const
finaloverride

The logical volume has precisely the name for what we're searching for

There are no grand children of this volume. We're at a leaf node

Definition at line 150 of file MuonGeoUtilitiyTool.cxx.

150  {
151  const std::vector<physVolWithTrans> children = getChildrenWithRef(physVol, false);
152  std::vector<physVolWithTrans> foundVols{};
153  for (const physVolWithTrans& child : children) {
155  if (child.volume->getLogVol()->getName() == volumeName || child.nodeName == volumeName) {
156  foundVols.push_back(child);
157  }
159  if (!child.volume->getNChildVols()) {
160  continue;
161  }
162  std::vector<physVolWithTrans> grandChildren = findAllLeafNodesByName(child.volume, volumeName);
163  std::transform(std::make_move_iterator(grandChildren.begin()),
164  std::make_move_iterator(grandChildren.end()), std::back_inserter(foundVols),
165  [&child](physVolWithTrans&& vol){
166  vol.transform = child.transform * vol.transform;
167  return vol;
168  });
169  }
170  return foundVols;
171 }

◆ getComponents()

std::vector< const GeoShape * > MuonGMR4::MuonGeoUtilityTool::getComponents ( const GeoShape *  booleanShape) const
finaloverride

Definition at line 172 of file MuonGeoUtilitiyTool.cxx.

172  {
173  return getBooleanComponents(booleanShape);
174 }

◆ polygonEdges()

std::vector< Amg::Vector2D > MuonGMR4::MuonGeoUtilityTool::polygonEdges ( const GeoSimplePolygonBrep &  polygon) const
override

Transforms the vertices of the Polygon shape into a std::vector consisting of Amg::Vector2D objects.

Definition at line 176 of file MuonGeoUtilitiyTool.cxx.

176  {
177  std::vector<Amg::Vector2D> polygonEdges{};
178  polygonEdges.reserve(polygon.getNVertices());
179  for (unsigned int i = 0; i < polygon.getNVertices(); ++i) {
180  polygonEdges.emplace_back(polygon.getXVertex(i), polygon.getYVertex(i));
181  ATH_MSG_VERBOSE("Polygon vertext point " << i << ": "<< GeoTrf::toString(polygonEdges.back(), 2));
182  }
183  return polygonEdges;
184 }

◆ shapeEdges()

std::vector< Amg::Vector3D > MuonGMR4::MuonGeoUtilityTool::shapeEdges ( const GeoShape *  shape,
const Amg::Transform3D refTrf 
) const
override

Definition at line 186 of file MuonGeoUtilitiyTool.cxx.

187  {
188  return getPolyShapeEdges(shape, refTrf);
189 }

The documentation for this class was generated from the following files:
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonGMR4::MuonGeoUtilityTool::dumpVolume
std::string dumpVolume(const PVConstLink &physVol) const override final
Definition: MuonGeoUtilitiyTool.cxx:91
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonGMR4::MuonGeoUtilityTool::polygonEdges
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: MuonGeoUtilitiyTool.cxx:176
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Amg::isIdentity
bool isIdentity(const Amg::Transform3D &trans)
Checks whether the transformation is the Identity transformation.
Definition: GeoPrimitivesHelpers.h:393
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
MuonGMR4::MuonGeoUtilityTool::extractShifts
Amg::Transform3D extractShifts(const PVConstLink &physVol) const override final
Definition: MuonGeoUtilitiyTool.cxx:67
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonGMR4::MuonGeoUtilityTool::findAllLeafNodesByName
std::vector< physVolWithTrans > findAllLeafNodesByName(const PVConstLink &physVol, const std::string &volumeName) const override final
Definition: MuonGeoUtilitiyTool.cxx:150
MuonGMR4::physVolWithTrans
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
Definition: MdtReadoutGeomTool.cxx:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.changerun.pv
pv
Definition: changerun.py:81
python.DecayParser.children
children
Definition: DecayParser.py:32
MuonGMR4::MuonGeoUtilityTool::dumpShape
std::string dumpShape(const GeoShape *inShape) const override final
Dumps the shape to string.
Definition: MuonGeoUtilitiyTool.cxx:90
node
Definition: memory_hooks-stdcmalloc.h:74
MuonGMR4::MuonGeoUtilityTool::extractShape
const GeoShape * extractShape(const PVConstLink &physVol) const override final
Definition: MuonGeoUtilitiyTool.cxx:38