Skip to content
Snippets Groups Projects
Geant4GeometryInfo.cpp 1.94 KiB
Newer Older
Markus Frank's avatar
Markus Frank committed
// $Id: $
//==========================================================================
//  AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
Markus Frank's avatar
Markus Frank committed
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
// Author     : M.Frank
//
//==========================================================================
// Framework include files
#include "G4VPhysicalVolume.hh"
#include "DDG4/Geant4GeometryInfo.h"

// C/C++ include files
#include <stdexcept>

using namespace std;
using namespace DD4hep::Simulation;


string Geant4GeometryMaps::placementPath(const Geant4PlacementPath& path, bool reverse)   {
  string s;
  if ( reverse )  {
    for (Geant4PlacementPath::const_reverse_iterator pIt = path.rbegin(); pIt != path.rend(); ++pIt) {
      s += "/"; s += (*pIt)->GetName();
    }
  }
  else  {
    for (Geant4PlacementPath::const_iterator pIt = path.begin(); pIt != path.end(); ++pIt) {
      s += "/"; s += (*pIt)->GetName();
    }
  }
  return s;
}

Geant4GeometryInfo::Geant4GeometryInfo()
  : TNamed("Geant4GeometryInfo", "Geant4GeometryInfo"), m_world(0), valid(false) {
Geant4GeometryInfo::~Geant4GeometryInfo() {

/// The world placement
G4VPhysicalVolume* Geant4GeometryInfo::world() const   {
  if ( m_world ) return m_world;
  throw runtime_error("Geant4GeometryInfo: Attempt to access invalid world placement");
}

/// Set the world placement
void Geant4GeometryInfo::setWorld(const TGeoNode* node)    {
  Geant4GeometryMaps::PlacementMap::const_iterator g4it = g4Placements.find(node);
  G4VPhysicalVolume* g4 = (g4it == g4Placements.end()) ? 0 : (*g4it).second;
  if (!g4) {
    throw runtime_error("Geant4GeometryInfo: Attempt to SET invalid world placement");
  }
  m_world = g4;
}