DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4GeometryInfo.cpp
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 
14 // Framework include files
17 #include <DD4hep/Printout.h>
18 
19 // Geant4 include files
20 #include <G4VPhysicalVolume.hh>
21 
22 using namespace dd4hep::sim;
23 
24 std::string Geant4GeometryInfo::placementPath(const Geant4PlacementPath& path, bool reverse) {
25  std::string path_name;
26  if ( reverse ) {
27  for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) {
28  path_name += "/"; path_name += (*pIt)->GetName();
29  }
30  }
31  else {
32  for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) {
33  path_name += "/"; path_name += (*pIt)->GetName();
34  }
35  }
36  return path_name;
37 }
38 
41  : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), printLevel(DEBUG), valid(false) {
42 }
43 
46  for( auto& a : g4AssemblyVolumes )
47  delete a.second;
48  g4AssemblyVolumes.clear();
49 }
50 
52 G4VPhysicalVolume* Geant4GeometryInfo::world() const {
53  if ( m_world ) return m_world;
54  except("Geant4GeometryInfo", "Attempt to access invalid world placement");
55  return m_world;
56 }
57 
59 void Geant4GeometryInfo::setWorld(const TGeoNode* node) {
60  Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node);
61  G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second;
62  if (!g4) {
63  except("Geant4GeometryInfo", "Attempt to SET invalid world placement");
64  }
65  m_world = g4;
66 }
dd4hep::sim::Geant4GeometryInfo::placementPath
static std::string placementPath(const Geant4PlacementPath &path, bool reverse=true)
Assemble Geant4 volume path.
Definition: Geant4GeometryInfo.cpp:24
Geant4GeometryInfo.h
dd4hep::sim::Geant4GeometryInfo::g4AssemblyVolumes
Geant4GeometryMaps::AssemblyMap g4AssemblyVolumes
Definition: Geant4GeometryInfo.h:118
dd4hep::sim::Geant4GeometryInfo::Geant4GeometryInfo
Geant4GeometryInfo()
Default constructor.
Definition: Geant4GeometryInfo.cpp:40
dd4hep::sim::Geant4GeometryInfo::setWorld
void setWorld(const TGeoNode *node)
Set the world volume.
Definition: Geant4GeometryInfo.cpp:59
dd4hep::sim::Geant4GeometryInfo::~Geant4GeometryInfo
virtual ~Geant4GeometryInfo()
Default destructor.
Definition: Geant4GeometryInfo.cpp:45
Geant4AssemblyVolume.h
dd4hep::sim::Geant4GeometryInfo::g4Placements
Geant4GeometryMaps::PlacementMap g4Placements
Definition: Geant4GeometryInfo.h:117
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::sim::Geant4GeometryInfo::m_world
G4VPhysicalVolume * m_world
Definition: Geant4GeometryInfo.h:140
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4GeometryInfo::Geant4PlacementPath
std::vector< const G4VPhysicalVolume * > Geant4PlacementPath
Definition: Geant4GeometryInfo.h:110
dd4hep::sim::Geant4GeometryInfo::world
G4VPhysicalVolume * world() const
The world placement.
Definition: Geant4GeometryInfo.cpp:52
valid
unsigned char valid
Definition: AlignmentsCalculator.cpp:69
Printout.h