G4tgbVolumeMgr.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4tgbVolumeMgr.hh 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgbVolume
00031 //
00032 // Class description:
00033 //
00034 // Class to manage volumes: G4VSolids, G4LogicalVolumes, G4VPhysicalVolumes.
00035 // It is a singleton, accesed always through calls to GetInstance().
00036 
00037 // History:
00038 // - Created.                                 P.Arce, CIEMAT (November 2007)
00039 // -------------------------------------------------------------------------
00040 
00041 #ifndef G4tgbVolumeMgr_h
00042 #define G4tgbVolumeMgr_h
00043 
00044 #include "globals.hh"
00045 
00046 #include <string>
00047 #include <vector>
00048 #include <map>
00049 
00050 #include "G4VSolid.hh"
00051 #include "G4LogicalVolume.hh"
00052 #include "G4VPhysicalVolume.hh"
00053 
00054 class G4tgbVolume;
00055 class G4tgrVolume;
00056 class G4tgbDetectorBuilder;
00057 
00058 typedef std::map< G4String, G4tgbVolume* > G4mssvol;
00059 typedef std::multimap< G4String, G4VSolid* > G4mmssol;
00060 typedef std::multimap< G4String, G4LogicalVolume* > G4mmslv;
00061 typedef std::multimap< G4String, G4VPhysicalVolume* > G4mmspv;
00062 typedef std::map< G4LogicalVolume*, G4LogicalVolume* > G4mlvlv;
00063 typedef std::map< G4VPhysicalVolume*, G4VPhysicalVolume* > G4mpvpv;
00064 
00065 //----------------------------------------------------------------------------  
00066 class G4tgbVolumeMgr 
00067 { 
00068   public:  // with description
00069 
00070     G4tgbVolumeMgr();
00071    ~G4tgbVolumeMgr();
00072 
00073     static G4tgbVolumeMgr* GetInstance();  
00074       // Get the only instance 
00075 
00076     void AddTextFile( const G4String& fname );
00077     G4VPhysicalVolume* ReadAndConstructDetector();
00078 
00079     void CopyVolumes();
00080       // Build a G4tgbVolume per each G4tgbVolume
00081 
00082     G4tgbVolume* FindVolume( const G4String& volname);
00083       // Find a G4tgbVolume by name
00084 
00085     void RegisterMe( const G4tgbVolume* vol );
00086       // Register a G4tgbVolume
00087     void RegisterMe( const G4VSolid* solid );
00088       // Register a G4VSolid
00089     void RegisterMe( const G4LogicalVolume* lv );
00090       // Register a G4LogicalVolume
00091     void RegisterMe( const G4VPhysicalVolume* pv );
00092       // Register a G4VPhysicalVolume
00093     void RegisterChildParentLVs( const G4LogicalVolume* logvol,
00094                                  const G4LogicalVolume* parentLV );
00095       // Register a child and its parent LV
00096 
00097     G4VSolid* FindG4Solid( const G4String& name );
00098       // Find if solid already exists, comparing the name and all parameters 
00099       // (could be checked before creating it, but it would be quite
00100       // complicated, because it would have to compare the parameters, and
00101       // they depend on the type of solid)
00102 
00103     G4LogicalVolume* FindG4LogVol( const G4String& theName,
00104                                    const G4bool bExists = 0 );
00105       // Find a G4LogicalVolume if it already exists
00106 
00107     G4VPhysicalVolume* FindG4PhysVol( const G4String& theName,
00108                                    const G4bool bExists = 0 );
00109       // Find a G4VPhysicalVolume if it already exists
00110 
00111     G4VPhysicalVolume* GetTopPhysVol();
00112       // Get the top PV in the hierarchy tree: calls topLV, because
00113       // physicalvolumes are not placed until geometry is initialized
00114 
00115     G4LogicalVolume* GetTopLogVol();
00116       // Get the top LV in the hierarchy tree
00117 
00118     void BuildPhysVolTree();
00119 
00120     // Dumping methods
00121 
00122     void DumpSummary();
00123     void DumpG4LogVolTree();
00124     void DumpG4LogVolLeaf(const G4LogicalVolume* lv, unsigned int leafDepth);
00125     void DumpG4PhysVolTree();
00126     void DumpG4PhysVolLeaf(const G4VPhysicalVolume* pv, unsigned int leafDepth);
00127     void DumpG4SolidList();
00128 
00129   public:  // without description
00130 
00131     const std::multimap< G4String, G4VSolid* >& GetSolids() const
00132       { return theSolids; }
00133     void SetDetectorBuilder( G4tgbDetectorBuilder* db )
00134       { theDetectorBuilder = db; }
00135     G4tgbDetectorBuilder* GetDetectorBuilder() const
00136       { return theDetectorBuilder; }
00137 
00138   private:
00139 
00140     static G4tgbVolumeMgr* theInstance;
00141 
00142     G4mssvol theVolumeList;
00143       // Map of G4tgbVolume's: G4String is the G4tgbVolume name,
00144       // G4tgbVolume* the pointer to it.
00145 
00146     G4mmssol theSolids;
00147       // Solids container
00148 
00149     G4mmslv theLVs;
00150       // Logical volume container
00151     G4mmspv thePVs;
00152       // Physical volume container
00153 
00154     G4mlvlv theLVTree;
00155       // Logical volume tree for navigation (from parent to children):
00156       // first is parent, then child
00157     G4mlvlv theLVInvTree;
00158       // Logical volume tree for inverse navigation (from children to parent):
00159       // first is child, then parent
00160 
00161     G4mpvpv thePVTree;
00162       // Physical volume tree for navigation (from parent to children):
00163       // first is parent, then child
00164     G4mpvpv thePVInvTree;
00165       // Physical volume tree for inverse navigation (from children to parents):
00166       // first is child, then parent
00167 
00168     G4tgbDetectorBuilder* theDetectorBuilder;
00169 };
00170 
00171 #endif

Generated on Mon May 27 17:49:58 2013 for Geant4 by  doxygen 1.4.7