]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4GeometryServices.h
method PrintLogicalVolumeStore() added; added formatting in PrintStatistics()
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryServices.h
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TG4GeometryServices
7 // -------------------------
8 // The class provides service methods for accessing to Geant4 geometry,
9 // namely using AliMC volumes and materials identifiers. 
10
11 #ifndef TG4_GEOMETRY_SERVICES_H
12 #define TG4_GEOMETRY_SERVICES_H
13
14 #include "TG4Verbose.h"
15 #include "TG4Globals.h"
16
17 #include <globals.hh>
18
19 #include <Rtypes.h>
20
21 class TG4IntMap;
22 class TG4NameMap;
23 class TG4Limits;
24 class TG4G3ControlVector;
25
26 class G4Material;
27 class G4LogicalVolume;
28 class G4VPhysicalVolume;
29 class G4UserLimits;
30
31 class TG4GeometryServices : public TG4Verbose
32 {
33   public:
34     TG4GeometryServices(TG4IntMap* mediumMap, TG4NameMap* nameMap);
35     // --> protected
36     // TG4GeometryServices();
37     // TG4GeometryServices(const TG4GeometryServices& right);
38     virtual ~TG4GeometryServices();
39
40     // static access method
41     static TG4GeometryServices* Instance();
42
43     // methods
44            // utilities  
45     G4double* CreateG4doubleArray(Float_t* array, G4int size) const;
46     G4String  CutName(const char* name) const;
47     G4String  CutMaterialName(const char* name) const;
48     G4String  G4ToG3VolumeName(const G4String& name) const;
49     G4String  GenerateLimitsName(G4int id, const G4String& medName,
50                                            const G4String& matName) const;
51
52     G4Material* MixMaterials(G4String name, G4double density,
53                              const TG4StringVector& matNames, 
54                              const TG4doubleVector& matWeights);
55            // printing 
56     void PrintNameMap() const;
57     void PrintLimits(const G4String& name) const;
58     void PrintVolumeLimits(const G4String& volumeName) const;
59     void PrintStatistics(G4bool open, G4bool close) const;
60     void PrintLogicalVolumeStore() const;
61
62     // set methods
63     void SetWorld(G4VPhysicalVolume* world);
64
65     // get methods
66            // volumes
67     Int_t NofG3Volumes() const; 
68     Int_t NofG4LogicalVolumes() const; 
69     Int_t NofG4PhysicalVolumes() const; 
70     G4bool IsSpecialControls() const;
71     G4VPhysicalVolume* GetWorld() const;
72
73     TG4Limits* GetLimits(G4UserLimits* limits) const;
74     const G4String& GetMapSecond(const G4String& name);
75
76     G4LogicalVolume* FindLogicalVolume(const G4String& name, 
77                                        G4bool silent = false) const;
78     TG4Limits*       FindLimits(const G4String& name, 
79                                        G4bool silent = false) const;
80
81           // materials
82     G4int    GetMediumId(G4LogicalVolume* lv) const;    
83     G4double GetEffA(G4Material* material) const;
84     G4double GetEffZ(G4Material* material) const;
85     G4Material* FindMaterial(G4double a, G4double z, G4double density) const;
86     G4Material* FindMaterial(G4double* a, G4double* z, G4double density, 
87                              G4int nmat, G4double* wmat) const;
88
89   protected:
90     TG4GeometryServices();
91     TG4GeometryServices(const TG4GeometryServices& right);
92
93     // operators
94     TG4GeometryServices& operator=(const TG4GeometryServices& right);
95
96   private:
97     // methods        
98     G4bool IsG3Volume(const G4String& lvName) const;
99     G4bool CompareElement(G4double a, G4double z, const G4Element* elem) const;
100     G4bool CompareMaterial(G4int nofElements, G4double density, 
101                            const G4Material* material) const;
102     G4double* ConvertAtomWeight(G4int nmat, G4double* a, G4double* wmat) const;
103
104     // static data members
105     static TG4GeometryServices*  fgInstance;   //this instance
106     static const G4double  fgkAZTolerance;     //A,Z tolerance
107     static const G4double  fgkDensityTolerance;//density tolerance (percentual)
108  
109     // data members
110     TG4IntMap*         fMediumMap; //map of volumes names to medias IDs
111     TG4NameMap*        fNameMap;   //map of volumes names to modules names
112     G4VPhysicalVolume* fWorld;     //top pgysical volume (world)
113 };
114
115 // inline methods
116 inline TG4GeometryServices* TG4GeometryServices::Instance()
117 { return fgInstance; }
118
119 inline void TG4GeometryServices::SetWorld(G4VPhysicalVolume* world)
120 { fWorld = world; }
121
122 inline G4VPhysicalVolume* TG4GeometryServices::GetWorld() const
123 { return fWorld; }
124
125 #endif //TG4_GEOMETRY_SERVICES_H
126