Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:25

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DDG4/Geant4GeometryInfo.h>
0016 #include <DDG4/Geant4AssemblyVolume.h>
0017 #include <DD4hep/Printout.h>
0018 
0019 // Geant4 include files
0020 #include <G4VPhysicalVolume.hh>
0021 
0022 using namespace dd4hep::sim;
0023 
0024 std::string Geant4GeometryInfo::placementPath(const Geant4PlacementPath& path, bool reverse)   {
0025   std::string path_name;
0026   if ( reverse )  {
0027     for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) {
0028       path_name += "/"; path_name += (*pIt)->GetName();
0029     }
0030   }
0031   else  {
0032     for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) {
0033       path_name += "/"; path_name += (*pIt)->GetName();
0034     }
0035   }
0036   return path_name;
0037 }
0038 
0039 /// Default constructor
0040 Geant4GeometryInfo::Geant4GeometryInfo()
0041   : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), printLevel(DEBUG), valid(false) {
0042 }
0043 
0044 /// Default destructor
0045 Geant4GeometryInfo::~Geant4GeometryInfo() {
0046   for( auto& a : g4AssemblyVolumes )
0047     delete a.second;
0048   g4AssemblyVolumes.clear();
0049 }
0050 
0051 /// The world placement
0052 G4VPhysicalVolume* Geant4GeometryInfo::world() const   {
0053   if ( m_world ) return m_world;
0054   except("Geant4GeometryInfo", "Attempt to access invalid world placement");
0055   return m_world;
0056 }
0057 
0058 /// Set the world placement
0059 void Geant4GeometryInfo::setWorld(const TGeoNode* node)    {
0060   Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node);
0061   G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second;
0062   if (!g4) {
0063     except("Geant4GeometryInfo", "Attempt to SET invalid world placement");
0064   }
0065   m_world = g4;
0066 }