DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4GeometryInfo.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "G4VPhysicalVolume.hh"
18 
19 // C/C++ include files
20 #include <stdexcept>
21 
22 using namespace std;
23 using namespace DD4hep::Simulation;
24 
25 
26 string Geant4GeometryMaps::placementPath(const Geant4PlacementPath& path, bool reverse) {
27  string s;
28  if ( reverse ) {
29  for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) {
30  s += "/"; s += (*pIt)->GetName();
31  }
32  }
33  else {
34  for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) {
35  s += "/"; s += (*pIt)->GetName();
36  }
37  }
38  return s;
39 }
40 
42 Geant4GeometryInfo::Geant4GeometryInfo()
43  : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), valid(false) {
44 }
45 
48 }
49 
51 G4VPhysicalVolume* Geant4GeometryInfo::world() const {
52  if ( m_world ) return m_world;
53  throw runtime_error("Geant4GeometryInfo: Attempt to access invalid world placement");
54 }
55 
57 void Geant4GeometryInfo::setWorld(const TGeoNode* node) {
58  Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node);
59  G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second;
60  if (!g4) {
61  throw runtime_error("Geant4GeometryInfo: Attempt to SET invalid world placement");
62  }
63  m_world = g4;
64 }
void setWorld(const TGeoNode *node)
Set the world volume.
std::vector< const G4VPhysicalVolume * > Geant4PlacementPath
TGeoShape * s
Definition: Volumes.cpp:294
virtual ~Geant4GeometryInfo()
Default destructor.
std::string placementPath(DetElement element)
Assemble the placement path from a given detector element to the world volume.
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:34
G4VPhysicalVolume * world() const
The world placement.
Geant4GeometryMaps::PlacementMap g4Placements