DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
Geant4GeometryInfo.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 DDG4_GEANT4GEOMETRYINFO_H
14 #define DDG4_GEANT4GEOMETRYINFO_H
15 
16 // Framework include files
17 #include <DD4hep/Objects.h>
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/GeoHandler.h>
20 #include <DD4hep/PropertyTable.h>
21 #include <DDG4/Geant4Primitives.h>
23 
24 
25 // C/C++ include files
26 #include <map>
27 #include <vector>
28 #include <cstdint>
29 
30 // Forward declarations (TGeo)
31 class TGeoElement;
32 class TGeoMedium;
33 class TGeoVolume;
34 class TGeoShape;
35 class TGeoNode;
36 // Forward declarations (Geant4)
37 class G4Isotope;
38 class G4Element;
39 class G4Material;
40 class G4VSolid;
41 class G4LogicalVolume;
42 class G4Region;
43 class G4UserLimits;
44 class G4VisAttributes;
45 class G4VPhysicalVolume;
46 class G4OpticalSurface;
47 class G4LogicalSkinSurface;
48 class G4LogicalBorderSurface;
49 class G4AssemblyVolume;
51 class G4PhysicsOrderedFreeVector;
52 
54 namespace dd4hep {
55 
57  namespace sim {
58 
59  // Forward declarations
60  class Geant4Mapping;
61  class Geant4AssemblyVolume;
62 
64 
69  namespace Geant4GeometryMaps {
70  typedef std::map<Atom, G4Element*> ElementMap;
71  typedef std::map<const TGeoIsotope*, G4Isotope*> IsotopeMap;
72  typedef std::map<Material, G4Material*> MaterialMap;
73  typedef std::map<PlacedVolume, G4VPhysicalVolume*> PlacementMap;
74  typedef std::map<Volume, G4LogicalVolume*> VolumeMap;
75  typedef std::map<PlacedVolume, Geant4AssemblyVolume*> AssemblyMap;
76 
77  typedef std::vector<const TGeoNode*> PlacedVolumeChain;
78  typedef std::pair<PlacedVolumeChain,const G4VPhysicalVolume*> ImprintEntry;
79  typedef std::vector<ImprintEntry> Imprints;
80  typedef std::map<Volume,Imprints> VolumeImprintMap;
81  typedef std::map<const TGeoShape*, G4VSolid*> SolidMap;
82  typedef std::map<const G4VPhysicalVolume*, PlacedVolume> G4PlacementMap;
83  }
84 
86 
92  public:
94  int value;
95  struct _flags {
96  unsigned parametrised:1;
97  unsigned replicated:1;
98  } flags;
99  PlacementFlags() { this->value = 0; }
100  PlacementFlags(int v) { this->value = v; }
101  };
102  struct Placement {
104  int flags;
105  };
106 
107  class DebugInfo;
108  TGeoManager* manager { nullptr };
109  DebugInfo* g4DebugInfo { nullptr };
120  struct PropertyVector {
121  std::vector<double> bins;
122  std::vector<double> values;
123  std::string name, title;
124  PropertyVector() = default;
125  ~PropertyVector() = default;
126  };
127  std::map<PropertyTable, PropertyVector*> g4OpticalProperties;
128  std::map<OpticalSurface, G4OpticalSurface*> g4OpticalSurfaces;
129  std::map<SkinSurface, G4LogicalSkinSurface*> g4SkinSurfaces;
130  std::map<BorderSurface, G4LogicalBorderSurface*> g4BorderSurfaces;
131  std::map<Region, G4Region*> g4Regions;
132  std::map<VisAttr, G4VisAttributes*> g4Vis;
133  std::map<LimitSet, G4UserLimits*> g4Limits;
134  std::map<uint64_t, Placement> g4Paths;
135  std::map<SensitiveDetector,std::set<const TGeoVolume*> > sensitives;
136  std::map<Region, std::set<const TGeoVolume*> > regions;
137  std::map<LimitSet, std::set<const TGeoVolume*> > limits;
138  G4VPhysicalVolume* m_world;
139  PrintLevel printLevel;
140  bool has_volmgr { false };
141  bool valid { false };
142 
144  static std::string placementPath(const Geant4TouchableHandler::Geant4PlacementPath& path, bool reverse=true) {
145  return Geant4TouchableHandler::placementPath(path, reverse);
146  }
147 
148  private:
149  friend class Geant4Mapping;
153  virtual ~Geant4GeometryInfo();
154 
155  public:
157  G4VPhysicalVolume* world() const;
159  void setWorld(const TGeoNode* node);
160  };
161  } // End namespace sim
162 } // End namespace dd4hep
163 #endif // DDG4_GEANT4GEOMETRYINFO_H
dd4hep::sim::Geant4GeometryInfo::PropertyVector::~PropertyVector
~PropertyVector()=default
dd4hep::sim::Geant4GeometryInfo::sensitives
std::map< SensitiveDetector, std::set< const TGeoVolume * > > sensitives
Definition: Geant4GeometryInfo.h:135
dd4hep::sim::Geant4GeometryInfo::PlacementFlags
Definition: Geant4GeometryInfo.h:93
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags::parametrised
unsigned parametrised
Definition: Geant4GeometryInfo.h:96
dd4hep::sim::Geant4GeometryInfo::Placement::volumeID
VolumeID volumeID
Definition: Geant4GeometryInfo.h:103
Objects.h
Geant4Primitives.h
dd4hep::sim::Geant4GeometryInfo::g4OpticalSurfaces
std::map< OpticalSurface, G4OpticalSurface * > g4OpticalSurfaces
Definition: Geant4GeometryInfo.h:128
dd4hep::sim::Geant4GeometryInfo::g4AssemblyVolumes
Geant4GeometryMaps::AssemblyMap g4AssemblyVolumes
Definition: Geant4GeometryInfo.h:116
dd4hep::sim::Geant4GeometryMaps::ImprintEntry
std::pair< PlacedVolumeChain, const G4VPhysicalVolume * > ImprintEntry
Definition: Geant4GeometryInfo.h:78
v
View * v
Definition: MultiView.cpp:28
dd4hep::sim::Geant4GeometryInfo::g4Regions
std::map< Region, G4Region * > g4Regions
Definition: Geant4GeometryInfo.h:131
dd4hep::sim::Geant4GeometryMaps::AssemblyMap
std::map< PlacedVolume, Geant4AssemblyVolume * > AssemblyMap
Definition: Geant4GeometryInfo.h:75
dd4hep::sim::Geant4GeometryInfo::placementPath
static std::string placementPath(const Geant4TouchableHandler::Geant4PlacementPath &path, bool reverse=true)
Assemble Geant4 volume path.
Definition: Geant4GeometryInfo.h:144
dd4hep::detail::GeoHandlerTypes::GeometryInfo
Data container to store information obtained during the geometry scan.
Definition: GeoHandler.h:60
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::flags
struct dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags flags
dd4hep::sim::Geant4GeometryInfo::g4Materials
Geant4GeometryMaps::MaterialMap g4Materials
Definition: Geant4GeometryInfo.h:112
dd4hep::sim::Geant4TouchableHandler::Geant4PlacementPath
std::vector< const G4VPhysicalVolume * > Geant4PlacementPath
Definition: Geant4TouchableHandler.h:47
dd4hep::sim::Geant4GeometryInfo::g4Vis
std::map< VisAttr, G4VisAttributes * > g4Vis
Definition: Geant4GeometryInfo.h:132
dd4hep::sim::Geant4GeometryMaps::IsotopeMap
std::map< const TGeoIsotope *, G4Isotope * > IsotopeMap
Definition: Geant4GeometryInfo.h:71
dd4hep::sim::Geant4GeometryInfo::Placement
Definition: Geant4GeometryInfo.h:102
dd4hep::sim::Geant4GeometryInfo::PropertyVector::bins
std::vector< double > bins
Definition: Geant4GeometryInfo.h:121
dd4hep::sim::Geant4GeometryInfo::g4Paths
std::map< uint64_t, Placement > g4Paths
Definition: Geant4GeometryInfo.h:134
dd4hep::sim::Geant4GeometryInfo::manager
TGeoManager * manager
Definition: Geant4GeometryInfo.h:108
dd4hep::sim::Geant4GeometryInfo::Geant4GeometryInfo
Geant4GeometryInfo()
Default constructor.
Definition: Geant4GeometryInfo.cpp:25
dd4hep::sim::Geant4GeometryInfo::setWorld
void setWorld(const TGeoNode *node)
Set the world volume.
Definition: Geant4GeometryInfo.cpp:44
dd4hep::sim::Geant4GeometryInfo::printLevel
PrintLevel printLevel
Definition: Geant4GeometryInfo.h:139
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags
Definition: Geant4GeometryInfo.h:95
G4UserLimits
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:23
dd4hep::sim::Geant4GeometryInfo::~Geant4GeometryInfo
virtual ~Geant4GeometryInfo()
Default destructor.
Definition: Geant4GeometryInfo.cpp:30
dd4hep::sim::Geant4GeometryInfo::g4Parameterised
Geant4GeometryMaps::G4PlacementMap g4Parameterised
Definition: Geant4GeometryInfo.h:118
dd4hep::sim::Geant4GeometryInfo::PropertyVector::title
std::string title
Definition: Geant4GeometryInfo.h:123
dd4hep::sim::Geant4GeometryInfo::limits
std::map< LimitSet, std::set< const TGeoVolume * > > limits
Definition: Geant4GeometryInfo.h:137
dd4hep::sim::Geant4Mapping
Geometry mapping from dd4hep to Geant 4.
Definition: Geant4Mapping.h:35
dd4hep::sim::Geant4GeometryInfo::PropertyVector::values
std::vector< double > values
Definition: Geant4GeometryInfo.h:122
G4VSensitiveDetector
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:59
dd4hep::sim::Geant4GeometryInfo::PropertyVector::name
std::string name
Definition: Geant4GeometryInfo.h:123
dd4hep::sim::Geant4GeometryInfo::g4Placements
Geant4GeometryMaps::PlacementMap g4Placements
Definition: Geant4GeometryInfo.h:115
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
Geant4TouchableHandler.h
dd4hep::sim::Geant4GeometryInfo::g4DebugInfo
DebugInfo * g4DebugInfo
Definition: Geant4GeometryInfo.h:109
dd4hep::sim::Geant4GeometryInfo::g4Isotopes
Geant4GeometryMaps::IsotopeMap g4Isotopes
Definition: Geant4GeometryInfo.h:110
dd4hep::sim::Geant4GeometryInfo::g4BorderSurfaces
std::map< BorderSurface, G4LogicalBorderSurface * > g4BorderSurfaces
Definition: Geant4GeometryInfo.h:130
dd4hep::sim::Geant4GeometryInfo::g4VolumeImprints
Geant4GeometryMaps::VolumeImprintMap g4VolumeImprints
Definition: Geant4GeometryInfo.h:117
dd4hep::sim::Geant4GeometryMaps::G4PlacementMap
std::map< const G4VPhysicalVolume *, PlacedVolume > G4PlacementMap
Definition: Geant4GeometryInfo.h:82
dd4hep::sim::Geant4GeometryInfo::m_world
G4VPhysicalVolume * m_world
Definition: Geant4GeometryInfo.h:138
dd4hep::sim::Geant4GeometryInfo::g4Replicated
Geant4GeometryMaps::G4PlacementMap g4Replicated
Definition: Geant4GeometryInfo.h:119
dd4hep::sim::Geant4GeometryMaps::MaterialMap
std::map< Material, G4Material * > MaterialMap
Definition: Geant4GeometryInfo.h:72
dd4hep::sim::Geant4GeometryMaps::ElementMap
std::map< Atom, G4Element * > ElementMap
Definition: Geant4GeometryInfo.h:70
dd4hep::sim::Geant4GeometryInfo::g4Limits
std::map< LimitSet, G4UserLimits * > g4Limits
Definition: Geant4GeometryInfo.h:133
dd4hep::sim::Geant4GeometryInfo::g4Solids
Geant4GeometryMaps::SolidMap g4Solids
Definition: Geant4GeometryInfo.h:113
dd4hep::sim::Geant4GeometryInfo::PropertyVector::PropertyVector
PropertyVector()=default
G4AssemblyVolume
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:7
dd4hep::sim::Geant4GeometryInfo::valid
bool valid
Definition: Geant4GeometryInfo.h:141
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:50
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::_flags::replicated
unsigned replicated
Definition: Geant4GeometryInfo.h:97
dd4hep::sim::Geant4TouchableHandler::placementPath
static std::string placementPath(const Geant4PlacementPath &path, bool reverse=true)
Assemble Geant4 volume path.
Definition: Geant4TouchableHandler.cpp:58
dd4hep::sim::Geant4GeometryMaps::Imprints
std::vector< ImprintEntry > Imprints
Definition: Geant4GeometryInfo.h:79
dd4hep::sim::Geant4GeometryInfo
Concreate class holding the relation information between geant4 objects and dd4hep objects.
Definition: Geant4GeometryInfo.h:91
dd4hep::sim::Geant4GeometryInfo::Placement::flags
int flags
Definition: Geant4GeometryInfo.h:104
PropertyTable.h
dd4hep::sim::Geant4GeometryInfo::has_volmgr
bool has_volmgr
Definition: Geant4GeometryInfo.h:140
dd4hep::sim::Geant4GeometryMaps::VolumeImprintMap
std::map< Volume, Imprints > VolumeImprintMap
Definition: Geant4GeometryInfo.h:80
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::PlacementFlags
PlacementFlags()
Definition: Geant4GeometryInfo.h:99
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::value
int value
Definition: Geant4GeometryInfo.h:94
dd4hep::sim::Geant4GeometryInfo::PlacementFlags::PlacementFlags
PlacementFlags(int v)
Definition: Geant4GeometryInfo.h:100
dd4hep::sim::Geant4GeometryInfo::regions
std::map< Region, std::set< const TGeoVolume * > > regions
Definition: Geant4GeometryInfo.h:136
dd4hep::sim::Geant4GeometryInfo::g4Elements
Geant4GeometryMaps::ElementMap g4Elements
Definition: Geant4GeometryInfo.h:111
dd4hep::sim::Geant4GeometryInfo::world
G4VPhysicalVolume * world() const
The world placement.
Definition: Geant4GeometryInfo.cpp:37
dd4hep::sim::Geant4GeometryInfo::g4SkinSurfaces
std::map< SkinSurface, G4LogicalSkinSurface * > g4SkinSurfaces
Definition: Geant4GeometryInfo.h:129
dd4hep::sim::Geant4GeometryMaps::PlacedVolumeChain
std::vector< const TGeoNode * > PlacedVolumeChain
Definition: Geant4GeometryInfo.h:77
Printout.h
dd4hep::sim::Geant4GeometryInfo::PropertyVector
Definition: Geant4GeometryInfo.h:120
dd4hep::sim::Geant4GeometryMaps::VolumeMap
std::map< Volume, G4LogicalVolume * > VolumeMap
Definition: Geant4GeometryInfo.h:74
dd4hep::sim::Geant4GeometryMaps::SolidMap
std::map< const TGeoShape *, G4VSolid * > SolidMap
Definition: Geant4GeometryInfo.h:81
dd4hep::sim::Geant4GeometryInfo::g4OpticalProperties
std::map< PropertyTable, PropertyVector * > g4OpticalProperties
Definition: Geant4GeometryInfo.h:127
dd4hep::sim::Geant4GeometryInfo::g4Volumes
Geant4GeometryMaps::VolumeMap g4Volumes
Definition: Geant4GeometryInfo.h:114
dd4hep::sim::Geant4GeometryMaps::PlacementMap
std::map< PlacedVolume, G4VPhysicalVolume * > PlacementMap
Definition: Geant4GeometryInfo.h:73
GeoHandler.h