Files
geant4/source/persistency/ascii/include/G4tgbVolumeMgr.hh
2020-12-04 12:30:43 +01:00

169 lines
5.9 KiB
C++

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4tgbVolumeMgr
//
// Class description:
//
// Class to manage volumes: G4VSolids, G4LogicalVolumes, G4VPhysicalVolumes.
// It is a singleton, accesed always through calls to GetInstance().
// Author: P.Arce, CIEMAT (November 2007)
// --------------------------------------------------------------------
#ifndef G4tgbVolumeMgr_hh
#define G4tgbVolumeMgr_hh 1
#include "globals.hh"
#include <string>
#include <vector>
#include <map>
#include "G4VSolid.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
class G4tgbVolume;
class G4tgrVolume;
class G4tgbDetectorBuilder;
using G4mssvol = std::map<G4String, G4tgbVolume*>;
using G4mmssol = std::multimap<G4String, G4VSolid*>;
using G4mmslv = std::multimap<G4String, G4LogicalVolume*>;
using G4mmspv = std::multimap<G4String, G4VPhysicalVolume*>;
using G4mlvlv = std::map<G4LogicalVolume*, G4LogicalVolume*>;
using G4mpvpv = std::map<G4VPhysicalVolume*, G4VPhysicalVolume*>;
class G4tgbVolumeMgr
{
public:
G4tgbVolumeMgr();
~G4tgbVolumeMgr();
static G4tgbVolumeMgr* GetInstance();
// Get the only instance
void AddTextFile(const G4String& fname);
G4VPhysicalVolume* ReadAndConstructDetector();
void CopyVolumes();
// Build a G4tgbVolume per each G4tgbVolume
G4tgbVolume* FindVolume(const G4String& volname);
// Find a G4tgbVolume by name
void RegisterMe(const G4tgbVolume* vol);
// Register a G4tgbVolume
void RegisterMe(const G4VSolid* solid);
// Register a G4VSolid
void RegisterMe(const G4LogicalVolume* lv);
// Register a G4LogicalVolume
void RegisterMe(const G4VPhysicalVolume* pv);
// Register a G4VPhysicalVolume
void RegisterChildParentLVs(const G4LogicalVolume* logvol,
const G4LogicalVolume* parentLV);
// Register a child and its parent LV
G4VSolid* FindG4Solid(const G4String& name);
// Find if solid already exists, comparing the name and all parameters
// (could be checked before creating it, but it would be quite
// complicated, because it would have to compare the parameters, and
// they depend on the type of solid)
G4LogicalVolume* FindG4LogVol(const G4String& theName,
const G4bool bExists = false);
// Find a G4LogicalVolume if it already exists
G4VPhysicalVolume* FindG4PhysVol(const G4String& theName,
const G4bool bExists = false);
// Find a G4VPhysicalVolume if it already exists
G4VPhysicalVolume* GetTopPhysVol();
// Get the top PV in the hierarchy tree: calls topLV, because
// physicalvolumes are not placed until geometry is initialized
G4LogicalVolume* GetTopLogVol();
// Get the top LV in the hierarchy tree
void BuildPhysVolTree();
// Dumping methods
void DumpSummary();
void DumpG4LogVolTree();
void DumpG4LogVolLeaf(const G4LogicalVolume* lv, unsigned int leafDepth);
void DumpG4PhysVolTree();
void DumpG4PhysVolLeaf(const G4VPhysicalVolume* pv, unsigned int leafDepth);
void DumpG4SolidList();
const std::multimap<G4String, G4VSolid*>& GetSolids() const
{
return theSolids;
}
void SetDetectorBuilder(G4tgbDetectorBuilder* db)
{
theDetectorBuilder = db;
}
G4tgbDetectorBuilder* GetDetectorBuilder() const
{
return theDetectorBuilder;
}
private:
static G4ThreadLocal G4tgbVolumeMgr* theInstance;
G4mssvol theVolumeList;
// Map of G4tgbVolume's: G4String is the G4tgbVolume name,
// G4tgbVolume* the pointer to it.
G4mmssol theSolids;
// Solids container
G4mmslv theLVs;
// Logical volume container
G4mmspv thePVs;
// Physical volume container
G4mlvlv theLVTree;
// Logical volume tree for navigation (from parent to children):
// first is parent, then child
G4mlvlv theLVInvTree;
// Logical volume tree for inverse navigation (from children to parent):
// first is child, then parent
G4mpvpv thePVTree;
// Physical volume tree for navigation (from parent to children):
// first is parent, then child
G4mpvpv thePVInvTree;
// Physical volume tree for inverse navigation (from children to parents):
// first is child, then parent
G4tgbDetectorBuilder* theDetectorBuilder = nullptr;
};
#endif