ATLAS Offline Software
GeoVisitVolumes.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
4  */
15 #ifndef GEOMODELUTILITIES_GEOVISITVOLUMES_H
16 #define GEOMODELUTILITIES_GEOVISITVOLUMES_H
17 
20 
21 #include "GeoModelKernel/GeoNodeAction.h"
22 #include "GeoModelKernel/GeoDefinitions.h"
23 #include <vector>
24 #include <variant>
25 
26 
27 class GeoVPhysVol;
28 class GeoTransform;
29 class GeoVAlignmentStore;
30 
31 
38 {
39 public:
40  virtual ~IGeoVisitVolumesAction() = default;
41  virtual void operator() (GeoNodeAction& action,
42  int id,
43  const std::string& name,
44  const GeoVPhysVol* volume,
46  const GeoTrf::Transform3D& defTransform) = 0;
47 };
48 
49 
57 {
58 public:
59  virtual ~IGeoVisitVolumesNoXformAction() = default;
60  virtual void operator() (GeoNodeAction& action,
61  int id,
62  const std::string& name,
63  const GeoVPhysVol* volume) = 0;
64 };
65 
66 
76 class GeoVisitVolumes : public GeoNodeAction
77 {
78 public:
80  GeoVisitVolumes (IGeoVisitVolumesAction& action, int depthLimit = 1);
81 
84 
86  virtual void handleTransform (const GeoTransform *xform) override;
87 
89  virtual void handlePhysVol (const GeoPhysVol *vol) override;
90 
92  virtual void handleFullPhysVol (const GeoFullPhysVol *vol) override;
93 
95  virtual void handleNameTag (const GeoNameTag *nameTag) override;
96 
98  virtual void handleSerialDenominator (const GeoSerialDenominator *sD) override;
99 
101  virtual void handleSerialTransformer (const GeoSerialTransformer *sT) override;
102 
104  virtual void handleIdentifierTag (const GeoIdentifierTag *idTag) override;
105 
107  virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override;
108 
109 
110 private:
111  GeoVisitVolumes (const GeoVisitVolumes &right) = delete;
112  GeoVisitVolumes & operator=(const GeoVisitVolumes &right) = delete;
113 
114  void handleVol (const GeoVPhysVol *vol);
115 
117  std::variant<IGeoVisitVolumesAction*,
119 
121  const GeoNameTag *m_nameTag;
122 
124  const GeoSerialDenominator *m_serialDenominator;
125 
127  const GeoIdentifierTag *m_idTag;
128 
130  std::vector<const GeoTransform *> m_pendingTransformList;
131 
132  const GeoSerialIdentifier *m_serialIdentifier;
133 };
134 
135 
139 template <class FUNCTION>
141  : public IGeoVisitVolumesAction
142 {
143 public:
144  GeoVisitVolumesAction (FUNCTION f) : m_f (f) {}
145  virtual void operator() (GeoNodeAction& /*action*/,
146  int id,
147  const std::string& name,
148  const GeoVPhysVol* volume,
150  const GeoTrf::Transform3D& defTransform) override
151  {
152  m_f (id, name, volume, transform, defTransform);
153  }
154  FUNCTION m_f;
155 };
156 
157 
163 template <class FUNCTION>
166 {
167 public:
169  virtual void operator() (GeoNodeAction& /*action*/,
170  int id,
171  const std::string& name,
172  const GeoVPhysVol* volume) override
173  {
174  m_f (id, name, volume);
175  }
176  FUNCTION m_f;
177 };
178 
179 
180 
184 template <class FUNCTION>
185 void geoVisitVolumes (FUNCTION f, const GeoGraphNode* node, int depthLimit = 1)
186 {
188  GeoVisitVolumes visitor (act, depthLimit);
189  node->exec (&visitor);
190 }
191 
192 
198 template <class FUNCTION>
199 void geoVisitVolumesNoXform (FUNCTION f, const GeoGraphNode* node, int depthLimit = 1)
200 {
202  GeoVisitVolumes visitor (act, depthLimit);
203  node->exec (&visitor);
204 }
205 
206 
218 typedef std::vector<std::pair<const GeoVPhysVol*, GeoTrf::Transform3D> >
220 GeoVolumeVec_t geoGetVolumes (const GeoGraphNode* node,
221  int depthLimit = 1,
222  int sizeHint = 20);
223 
224 
235 std::vector<const GeoVPhysVol*>
236 geoGetVolumesNoXform (const GeoGraphNode* node,
237  int depthLimit = 1,
238  int sizeHint = 20);
239 
240 
241 #endif // not GEOMODELUTILITIES_GEOVISITVOLUMES_H
geoGetVolumes
GeoVolumeVec_t geoGetVolumes(const GeoGraphNode *node, int depthLimit=1, int sizeHint=20)
Return the child volumes and associated transforms.
Definition: GeoVisitVolumes.cxx:211
GeoVisitVolumes::handleFullPhysVol
virtual void handleFullPhysVol(const GeoFullPhysVol *vol) override
Handles a physical volume.
Definition: GeoVisitVolumes.cxx:103
geoVisitVolumesNoXform
void geoVisitVolumesNoXform(FUNCTION f, const GeoGraphNode *node, int depthLimit=1)
Template helper for running the visitor.
Definition: GeoVisitVolumes.h:199
GeoVisitVolumesNoXformAction::GeoVisitVolumesNoXformAction
GeoVisitVolumesNoXformAction(FUNCTION f)
Definition: GeoVisitVolumes.h:168
GeoVisitVolumesAction::GeoVisitVolumesAction
GeoVisitVolumesAction(FUNCTION f)
Definition: GeoVisitVolumes.h:144
GeoVolumeVec_t
std::vector< std::pair< const GeoVPhysVol *, GeoTrf::Transform3D > > GeoVolumeVec_t
Return the child volumes and associated transforms.
Definition: GeoVisitVolumes.h:219
GeoVisitVolumes::handleIdentifierTag
virtual void handleIdentifierTag(const GeoIdentifierTag *idTag) override
Handles an Identifier Tag.
Definition: GeoVisitVolumes.cxx:187
GeoVisitVolumes::m_idTag
const GeoIdentifierTag * m_idTag
A pointer to an identifier tag. If the volume is identified.
Definition: GeoVisitVolumes.h:127
IGeoVisitVolumesNoXformAction::~IGeoVisitVolumesNoXformAction
virtual ~IGeoVisitVolumesNoXformAction()=default
GeoVisitVolumes::handleNameTag
virtual void handleNameTag(const GeoNameTag *nameTag) override
Handles a Name Tag.
Definition: GeoVisitVolumes.cxx:109
geoGetVolumesNoXform
std::vector< const GeoVPhysVol * > geoGetVolumesNoXform(const GeoGraphNode *node, int depthLimit=1, int sizeHint=20)
Return the child volumes.
Definition: GeoVisitVolumes.cxx:240
GeoVisitVolumes::handleSerialTransformer
virtual void handleSerialTransformer(const GeoSerialTransformer *sT) override
Handles a Serial Transformer.
Definition: GeoVisitVolumes.cxx:130
GeoVisitVolumes::handleVol
void handleVol(const GeoVPhysVol *vol)
Definition: GeoVisitVolumes.cxx:55
IGeoVisitVolumesAction::operator()
virtual void operator()(GeoNodeAction &action, int id, const std::string &name, const GeoVPhysVol *volume, const GeoTrf::Transform3D &transform, const GeoTrf::Transform3D &defTransform)=0
GeoVisitVolumes::handleSerialDenominator
virtual void handleSerialDenominator(const GeoSerialDenominator *sD) override
Handles a Serial Denominator.
Definition: GeoVisitVolumes.cxx:116
GeoVisitVolumes::m_pendingTransformList
std::vector< const GeoTransform * > m_pendingTransformList
List of Pending Transformations.
Definition: GeoVisitVolumes.h:130
GeoVisitVolumesAction::m_f
FUNCTION m_f
Definition: GeoVisitVolumes.h:154
GeoPrimitives.h
GeoVisitVolumes::m_serialDenominator
const GeoSerialDenominator * m_serialDenominator
A pointer to a serial denominator. If one exists.
Definition: GeoVisitVolumes.h:124
IGeoVisitVolumesNoXformAction
Define a simple callback for each volume found, without keeping track of geometrical transforms.
Definition: GeoVisitVolumes.h:57
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
hist_file_dump.f
f
Definition: hist_file_dump.py:135
IGeoVisitVolumesNoXformAction::operator()
virtual void operator()(GeoNodeAction &action, int id, const std::string &name, const GeoVPhysVol *volume)=0
GeoVisitVolumes::GeoVisitVolumes
GeoVisitVolumes(IGeoVisitVolumesAction &action, int depthLimit=1)
Initialize to visit volumes keeping track of transformations.
Definition: GeoVisitVolumes.cxx:23
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
GeoVisitVolumes::GeoVisitVolumes
GeoVisitVolumes(const GeoVisitVolumes &right)=delete
GeoVisitVolumes::handlePhysVol
virtual void handlePhysVol(const GeoPhysVol *vol) override
Handles a physical volume.
Definition: GeoVisitVolumes.cxx:98
GeoVisitVolumes::operator=
GeoVisitVolumes & operator=(const GeoVisitVolumes &right)=delete
GeoVisitVolumesNoXformAction::m_f
FUNCTION m_f
Definition: GeoVisitVolumes.h:176
GeoVisitVolumes::m_action
std::variant< IGeoVisitVolumesAction *, IGeoVisitVolumesNoXformAction * > m_action
Callback.
Definition: GeoVisitVolumes.h:118
IGeoVisitVolumesAction
Define a simple callback for each volume found.
Definition: GeoVisitVolumes.h:38
GeoVisitVolumes::m_nameTag
const GeoNameTag * m_nameTag
A pointer to a name tag. If the volume is named.
Definition: GeoVisitVolumes.h:121
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
GeoVisitVolumesNoXformAction
Callback object calling a templated functional.
Definition: GeoVisitVolumes.h:166
GeoVisitVolumesNoXformAction::operator()
virtual void operator()(GeoNodeAction &, int id, const std::string &name, const GeoVPhysVol *volume) override
Definition: GeoVisitVolumes.h:169
GeoVisitVolumesAction
Callback object calling a templated functional.
Definition: GeoVisitVolumes.h:142
GeoVisitVolumesAction::operator()
virtual void operator()(GeoNodeAction &, int id, const std::string &name, const GeoVPhysVol *volume, const GeoTrf::Transform3D &transform, const GeoTrf::Transform3D &defTransform) override
Definition: GeoVisitVolumes.h:145
GeoVisitVolumes
Visitor to process all volumes under a GeoModel node.
Definition: GeoVisitVolumes.h:77
GeoVisitVolumes::handleSerialIdentifier
virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override
Handles an Serial Identifier.
Definition: GeoVisitVolumes.cxx:194
GeoVisitVolumes::m_serialIdentifier
const GeoSerialIdentifier * m_serialIdentifier
Definition: GeoVisitVolumes.h:132
GeoVisitVolumes::handleTransform
virtual void handleTransform(const GeoTransform *xform) override
Handles a Transform.
Definition: GeoVisitVolumes.cxx:48
node
Definition: memory_hooks-stdcmalloc.h:74
IGeoVisitVolumesAction::~IGeoVisitVolumesAction
virtual ~IGeoVisitVolumesAction()=default
geoVisitVolumes
void geoVisitVolumes(FUNCTION f, const GeoGraphNode *node, int depthLimit=1)
Template helper for running the visitor.
Definition: GeoVisitVolumes.h:185