ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgrVolumeMgr.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgrVolumeMgr.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // class G4tgrVolumeMgr
30 //
31 // Class description:
32 //
33 // Class to manage the detector units. It is a singleton.
34 
35 // History:
36 // - Created. P.Arce, CIEMAT (November 2007)
37 // -------------------------------------------------------------------------
38 
39 #ifndef G4tgrVolumeMgr_h
40 #define G4tgrVolumeMgr_h
41 
42 #include "globals.hh"
43 #include "G4tgrSolid.hh"
44 #include "G4tgrVolume.hh"
45 #include "G4tgrPlace.hh"
46 #include "G4tgrIsotope.hh"
47 #include "G4tgrElement.hh"
48 #include "G4tgrMaterial.hh"
49 #include "G4tgrRotationMatrix.hh"
50 
51 #include <map>
52 
53 typedef std::map< G4String, G4tgrSolid* > G4mapssol;
54 typedef std::map< G4String, G4tgrVolume* > G4mapsvol;
55 typedef std::multimap< G4String, const G4tgrPlace* > G4mmapspl;
56 
57 //----------------------------------------------------------------------------
59 {
60  public: // with description
61 
62  static G4tgrVolumeMgr* GetInstance();
63  // Get the only instance
64 
65  G4tgrSolid* CreateSolid( const std::vector<G4String>& wl, G4bool bVOLUtag );
66 
67  void RegisterParentChild( const G4String& parentName,
68  const G4tgrPlace* pl );
69  // Add to theG4tgrVolumeTree
70 
71  G4tgrSolid* FindSolid( const G4String& name, G4bool exists = false );
72  // Find a G4tgrSolid with name 'name'. If it is not found:
73  // if exists is true, exit; if exists is false, return 0
74 
75  G4tgrVolume* FindVolume( const G4String& volname, G4bool exists = false );
76  // Find a G4tgrVolume with name 'volname'. If it is not found:
77  // if exists is true, exit; if exists is false, return 0
78 
79  std::vector<G4tgrVolume*> FindVolumes( const G4String& volname,
80  G4bool exists );
81  // Find all G4tgrVolume's with name 'volname'. '*' can be used in the
82  // name to mean 'any character' or 'any substring'. If it is not found:
83  // if exists is true, exit; if exists is false, return 0
84 
85  const G4tgrVolume* GetTopVolume();
86  // Find the top of the volume tree
87 
88  std::pair<G4mmapspl::iterator, G4mmapspl::iterator>
89  GetChildren( const G4String& name );
90  // Find the list of G4tgrPlace children of G4tgrVolume 'name'
91 
92  void DumpSummary();
93  // Dump summary
94  void DumpVolumeTree();
95  // Dump to cout the tree of G4tgrVolume's
96  void DumpVolumeLeaf( const G4tgrVolume* vol, unsigned int copyNo,
97  unsigned int leafDepth);
98  // Dump a G4tgrVolume indicating its copy no
99  // and its depth (number of ancestors)
100 
101  void RegisterMe( G4tgrSolid* vol);
102  void UnRegisterMe( G4tgrSolid* vol );
103  void RegisterMe( G4tgrVolume* vol);
104  void UnRegisterMe( G4tgrVolume* vol );
105  void RegisterMe( G4tgrPlace* pl ) { theG4tgrPlaceList.push_back( pl ); }
106  void RegisterMe( G4tgrIsotope* iso ) { theHgIsotList.push_back( iso ); }
107  void RegisterMe( G4tgrElement* ele ) { theHgElemList.push_back( ele ); }
108  void RegisterMe( G4tgrMaterial* mat ) { theHgMateList.push_back( mat ); }
109  void RegisterMe( G4tgrRotationMatrix* rm ) { theHgRotMList.push_back(rm); }
110 
111  // Accessors
112 
116  std::vector<G4tgrVolume*> GetVolumeList() {return theG4tgrVolumeList;}
117  std::vector<G4tgrPlace*> GetDetPlaceList() {return theG4tgrPlaceList;}
118  std::vector<G4tgrIsotope*> GetIsotopeList() {return theHgIsotList;}
119  std::vector<G4tgrElement*> GetElementList() {return theHgElemList;}
120  std::vector<G4tgrMaterial*> GetMaterialList() {return theHgMateList;}
121  std::vector<G4tgrRotationMatrix*> GetRotMList() {return theHgRotMList;}
122 
123  private:
124 
125  G4tgrVolumeMgr();
126  ~G4tgrVolumeMgr();
127 
128  private:
129 
131  // Map of G4tgrSolid's: G4String is the G4tgrSolid name,
132  // G4tgrSolid* the pointer to it
133 
135  // Map of G4tgrVolume's: G4String is the G4tgrVolume name,
136  // G4tgrVolume* the pointer to it
137 
139  // Hierarchy tree of G4tgrVolume's: G4String is the name
140  // of the parent G4tgrVolume, G4tgrPlace* the pointers to children
141 
143 
144  std::vector<G4tgrVolume*> theG4tgrVolumeList;
145  std::vector<G4tgrPlace*> theG4tgrPlaceList;
146  std::vector<G4tgrIsotope*> theHgIsotList;
147  std::vector<G4tgrElement*> theHgElemList;
148  std::vector<G4tgrMaterial*> theHgMateList;
149  std::vector<G4tgrRotationMatrix*> theHgRotMList;
150 };
151 
152 #endif