Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4tgrVolumeMgr
0027 //
0028 // Class description:
0029 //
0030 // Class to manage the detector units. It is a singleton.
0031 
0032 // Author: P.Arce, CIEMAT (November 2007)
0033 // --------------------------------------------------------------------
0034 #ifndef G4tgrVolumeMgr_hh
0035 #define G4tgrVolumeMgr_hh 1
0036 
0037 #include "globals.hh"
0038 #include "G4tgrSolid.hh"
0039 #include "G4tgrVolume.hh"
0040 #include "G4tgrPlace.hh"
0041 #include "G4tgrIsotope.hh"
0042 #include "G4tgrElement.hh"
0043 #include "G4tgrMaterial.hh"
0044 #include "G4tgrRotationMatrix.hh"
0045 
0046 #include <map>
0047 
0048 using G4mapssol = std::map<G4String, G4tgrSolid*>;
0049 using G4mapsvol = std::map<G4String, G4tgrVolume*>;
0050 using G4mmapspl = std::multimap<G4String, const G4tgrPlace*>;
0051 
0052 class G4tgrVolumeMgr
0053 {
0054   public:
0055 
0056     static G4tgrVolumeMgr* GetInstance();
0057       // Get the only instance
0058 
0059     G4tgrSolid* CreateSolid(const std::vector<G4String>& wl, G4bool bVOLUtag);
0060 
0061     void RegisterParentChild(const G4String& parentName, const G4tgrPlace* pl);
0062       // Add to theG4tgrVolumeTree
0063 
0064     G4tgrSolid* FindSolid(const G4String& name, G4bool exists = false);
0065       // Find a G4tgrSolid with name 'name'. If it is not found:
0066       // if exists is true, exit; if exists is false, return nullptr
0067 
0068     G4tgrVolume* FindVolume(const G4String& volname, G4bool exists = false);
0069       // Find a G4tgrVolume with name 'volname'. If it is not found:
0070       // if exists is true, exit; if exists is false, return nullptr
0071 
0072     std::vector<G4tgrVolume*> FindVolumes(const G4String& volname,
0073                                           G4bool exists);
0074       // Find all G4tgrVolume's with name 'volname'. '*' can be used in the
0075       // name to mean 'any character' or 'any substring'. If it is not found:
0076       // if exists is true, exit; if exists is false, return nullptr
0077 
0078     const G4tgrVolume* GetTopVolume();
0079       // Find the top of the volume tree
0080 
0081     std::pair<G4mmapspl::iterator, G4mmapspl::iterator>
0082     GetChildren(const G4String& name);
0083       // Find the list of G4tgrPlace children of G4tgrVolume 'name'
0084 
0085     void DumpSummary();
0086       // Dump summary
0087     void DumpVolumeTree();
0088       // Dump to cout the tree of G4tgrVolume's
0089     void DumpVolumeLeaf(const G4tgrVolume* vol, unsigned int copyNo,
0090                         unsigned int leafDepth);
0091       // Dump a G4tgrVolume indicating its copy no
0092       // and its depth (number of ancestors)
0093 
0094     void RegisterMe(G4tgrSolid* vol);
0095     void UnRegisterMe(G4tgrSolid* vol);
0096     void RegisterMe(G4tgrVolume* vol);
0097     void UnRegisterMe(G4tgrVolume* vol);
0098     void RegisterMe(G4tgrPlace* pl) { theG4tgrPlaceList.push_back(pl); }
0099     void RegisterMe(G4tgrIsotope* iso) { theHgIsotList.push_back(iso); }
0100     void RegisterMe(G4tgrElement* ele) { theHgElemList.push_back(ele); }
0101     void RegisterMe(G4tgrMaterial* mat) { theHgMateList.push_back(mat); }
0102     void RegisterMe(G4tgrRotationMatrix* rm) { theHgRotMList.push_back(rm); }
0103 
0104     // Accessors
0105 
0106     const G4mapssol& GetSolidMap() { return theG4tgrSolidMap; }
0107     const G4mapsvol& GetVolumeMap() { return theG4tgrVolumeMap; }
0108     const G4mmapspl& GetVolumeTree() { return theG4tgrVolumeTree; }
0109     std::vector<G4tgrVolume*> GetVolumeList() { return theG4tgrVolumeList; }
0110     std::vector<G4tgrPlace*> GetDetPlaceList() { return theG4tgrPlaceList; }
0111     std::vector<G4tgrIsotope*> GetIsotopeList() { return theHgIsotList; }
0112     std::vector<G4tgrElement*> GetElementList() { return theHgElemList; }
0113     std::vector<G4tgrMaterial*> GetMaterialList() { return theHgMateList; }
0114     std::vector<G4tgrRotationMatrix*> GetRotMList() { return theHgRotMList; }
0115 
0116   private:
0117 
0118     G4tgrVolumeMgr();
0119     ~G4tgrVolumeMgr();
0120 
0121   private:
0122 
0123     G4mapssol theG4tgrSolidMap;
0124       // Map of G4tgrSolid's: G4String is the G4tgrSolid name,
0125       // G4tgrSolid* the pointer to it
0126 
0127     G4mapsvol theG4tgrVolumeMap;
0128       // Map of G4tgrVolume's: G4String is the G4tgrVolume name,
0129       // G4tgrVolume* the pointer to it
0130 
0131     G4mmapspl theG4tgrVolumeTree;
0132       // Hierarchy tree of G4tgrVolume's: G4String is the name
0133       // of the parent G4tgrVolume, G4tgrPlace* the pointers to children
0134 
0135     static G4ThreadLocal G4tgrVolumeMgr* theInstance;
0136 
0137     std::vector<G4tgrVolume*> theG4tgrVolumeList;
0138     std::vector<G4tgrPlace*> theG4tgrPlaceList;
0139     std::vector<G4tgrIsotope*> theHgIsotList;
0140     std::vector<G4tgrElement*> theHgElemList;
0141     std::vector<G4tgrMaterial*> theHgMateList;
0142     std::vector<G4tgrRotationMatrix*> theHgRotMList;
0143 };
0144 
0145 #endif