DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
GeoHandler.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_GEOHANDLER_H
14 #define DD4HEP_GEOHANDLER_H
15 
17 #include <DD4hep/Detector.h>
18 
20 #include <set>
21 #include <map>
22 #include <vector>
23 
24 // Forward declarations
25 class TGeoMatrix;
26 class TGeoVolume;
27 class TGeoMedium;
28 class TGeoShape;
29 class TGeoNode;
30 
32 namespace dd4hep {
33 
34  // Forward declarations
35  class Detector;
36  class NamedObject;
37  class DetElement;
38  class SensitiveDetector;
39  class VisAttrObject;
40  class Volume;
41  class PlacedVolume;
42 
44  namespace detail {
45 
47 
53  public:
55 
60  class GeometryInfo {
61  public:
62  std::vector<TGeoShape*> solids;
63  std::set<TGeoShape*> solid_set;
64  std::set<Volume> volumeSet;
65  std::vector<Volume> volumes;
66  std::set<VisAttr> vis;
67  std::set<Ref_t> fields;
68  std::set<Material> materials;
69  std::set<TGeoMedium*> media;
70  std::set<TGeoElement*> elements;
71  std::vector<std::pair<std::string, TGeoMatrix*> > trafos;
72  };
73  };
74 
76 
87  class GeoHandler: public GeoHandlerTypes {
88 
89  protected:
90  bool m_propagateRegions { false };
91 
93  std::map<int, std::vector<const TGeoNode*> >* m_data { nullptr };
95  std::map<int, std::set<const TGeoNode*> >* m_set_data { nullptr };
96 
97  std::map<const TGeoNode*, std::vector<TGeoNode*> >* m_daughters { nullptr };
99  GeoHandler& i_collect(const TGeoNode* parent,
100  const TGeoNode* node,
101  int level, Region rg, LimitSet ls);
102 
103  private:
106  }
109  return *this;
110  }
111 
112  public:
114  GeoHandler();
116  GeoHandler(std::map<int, std::vector<const TGeoNode*> >* ptr,
117  std::map<int, std::set<const TGeoNode*> >* ptr_set,
118  std::map<const TGeoNode*, std::vector<TGeoNode*> >* daus = nullptr);
120  virtual ~GeoHandler();
122  bool setPropagateRegions(bool value);
126  GeoHandler& collect(DetElement top, GeometryInfo& info);
128  std::map<int, std::vector<const TGeoNode*> >* release();
129  };
130 
132 
137  class GeoScan {
138  protected:
140  std::map<int, std::vector<const TGeoNode*> >* m_data;
141  public:
143  GeoScan(DetElement e);
145  GeoScan(DetElement e, bool propagateRegions);
147  virtual ~GeoScan();
149  virtual GeoScan& operator()();
150  };
151  } // End namespace detail
152 } // End namespace dd4hep
153 
154 #endif // DD4HEP_GEOHANDLER_H
dd4hep::detail::GeoHandler::m_daughters
std::map< const TGeoNode *, std::vector< TGeoNode * > > * m_daughters
Definition: GeoHandler.h:97
dd4hep::detail::GeoHandlerTypes::GeometryInfo::solids
std::vector< TGeoShape * > solids
Definition: GeoHandler.h:62
dd4hep::detail::GeoHandlerTypes::GeometryInfo::trafos
std::vector< std::pair< std::string, TGeoMatrix * > > trafos
Definition: GeoHandler.h:71
Detector.h
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
dd4hep::detail::GeoHandler::i_collect
GeoHandler & i_collect(const TGeoNode *parent, const TGeoNode *node, int level, Region rg, LimitSet ls)
Internal helper to collect geometry information from traversal.
Definition: GeoHandler.cpp:148
dd4hep::detail::GeoHandlerTypes::GeometryInfo::volumeSet
std::set< Volume > volumeSet
Definition: GeoHandler.h:64
dd4hep::detail::GeoScan::m_data
std::map< int, std::vector< const TGeoNode * > > * m_data
Data holder.
Definition: GeoHandler.h:140
dd4hep::detail::GeoHandlerTypes::GeometryInfo
Data container to store information obtained during the geometry scan.
Definition: GeoHandler.h:60
dd4hep::detail::GeoHandlerTypes::GeometryInfo::vis
std::set< VisAttr > vis
Definition: GeoHandler.h:66
dd4hep::detail::GeoHandlerTypes::GeometryInfo::solid_set
std::set< TGeoShape * > solid_set
Definition: GeoHandler.h:63
dd4hep::detail::GeoHandler::operator=
GeoHandler & operator=(const GeoHandler &)
Never call assignment operator.
Definition: GeoHandler.h:108
dd4hep::detail::GeoScan
Geometry scanner (handle object)
Definition: GeoHandler.h:137
dd4hep::detail::GeoHandler::m_propagateRegions
bool m_propagateRegions
Definition: GeoHandler.h:90
dd4hep::detail::GeoHandler::m_set_data
std::map< int, std::set< const TGeoNode * > > * m_set_data
redundant container with std::set (for lookup purpose)
Definition: GeoHandler.h:95
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::detail::GeoHandler::GeoHandler
GeoHandler(const GeoHandler &)
Never call Copy constructor.
Definition: GeoHandler.h:105
dd4hep::detail::GeoHandler
The base class for all dd4hep geometry crawlers.
Definition: GeoHandler.h:87
dd4hep::detail::GeoScan::GeoScan
GeoScan(DetElement e)
Initializing constructor.
Definition: GeoHandler.cpp:186
dd4hep::detail::GeoHandler::~GeoHandler
virtual ~GeoHandler()
Default destructor.
Definition: GeoHandler.cpp:70
dd4hep::LimitSet
Handle class describing a set of limits as they are used for simulation.
Definition: Objects.h:425
dd4hep::detail::GeoHandler::release
std::map< int, std::vector< const TGeoNode * > > * release()
Access to collected node list.
Definition: GeoHandler.cpp:80
dd4hep::detail::GeoHandlerTypes::GeometryInfo::elements
std::set< TGeoElement * > elements
Definition: GeoHandler.h:70
dd4hep::Region
Handle class describing a region as used in simulation.
Definition: Objects.h:462
dd4hep::detail::GeoHandler::GeoHandler
GeoHandler()
Default constructor.
Definition: GeoHandler.cpp:56
dd4hep::detail::GeoHandler::m_data
std::map< int, std::vector< const TGeoNode * > > * m_data
actual container with std::vector (preserves order)
Definition: GeoHandler.h:93
dd4hep::detail::GeoHandlerTypes::GeometryInfo::fields
std::set< Ref_t > fields
Definition: GeoHandler.h:67
dd4hep::detail::GeoScan::operator()
virtual GeoScan & operator()()
Work callback.
Definition: GeoHandler.cpp:205
dd4hep::detail::GeoHandler::setPropagateRegions
bool setPropagateRegions(bool value)
Propagate regions. Returns the previous value.
Definition: GeoHandler.cpp:95
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::detail::GeoScan::~GeoScan
virtual ~GeoScan()
Default destructor.
Definition: GeoHandler.cpp:198
dd4hep::detail::GeoHandlerTypes::GeometryInfo::media
std::set< TGeoMedium * > media
Definition: GeoHandler.h:69
dd4hep::detail::GeoHandlerTypes::GeometryInfo::volumes
std::vector< Volume > volumes
Definition: GeoHandler.h:65
dd4hep::detail::GeoHandlerTypes::GeometryInfo::materials
std::set< Material > materials
Definition: GeoHandler.h:68
dd4hep::detail::GeoHandlerTypes
Defintion of the object types used by generic geometry handlers.
Definition: GeoHandler.h:52
dd4hep::detail::GeoHandler::collect
GeoHandler & collect(DetElement top)
Collect geometry information from traversal.
Definition: GeoHandler.cpp:101