]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4GeometryManager.h
corrected includes from g4std
[u/mrichter/AliRoot.git] / TGeant4 / TG4GeometryManager.h
1 // $Id$
2 // Category: geometry
3 //
4 // Geant4 implementation of the MonteCarlo interface methods                    
5 // for building Geant4 geometry and access to it
6
7 #ifndef TG4_GEOMETRY_MANAGER_H
8 #define TG4_GEOMETRY_MANAGER_H
9
10 #include "TG4NameMap.h"
11 #include "TG4Globals.h"
12 #include "TG3Cut.h"
13 #include "TG3Flag.h"
14
15 #include <globals.hh>
16 #include <G3SensVolVector.hh>
17
18 #include <Rtypes.h>
19
20 #include <g4std/fstream>
21 #include <g4std/vector>
22
23 class TG4CutVector;
24 class TG4FlagVector;
25 class TG4GeometryOutputManager;
26
27 class G4Material;
28 class G4VPhysicalVolume;
29
30 class TG4GeometryManager
31 {
32   public:
33     TG4GeometryManager();
34     // --> protected
35     // TG4GeometryManager(const TG4GeometryManager& right);
36     virtual ~TG4GeometryManager();
37
38     // static access method
39     static TG4GeometryManager* Instance();
40
41     //
42     // methods (from the base class)
43     
44     // detector composition
45     void  Material(Int_t& kmat, const char* name, Float_t a, 
46                      Float_t z, Float_t dens, Float_t radl, Float_t absl,
47                      Float_t* buf, Int_t nwbuf);
48     void  Mixture(Int_t& kmat, const char *name, Float_t *a, 
49                      Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat);
50     void  Medium(Int_t& kmed, const char *name, Int_t nmat, 
51                      Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, 
52                      Float_t stemax, Float_t deemax, Float_t epsil, 
53                      Float_t stmin, Float_t* ubuf, Int_t nbuf);
54     void  Matrix(Int_t& krot, Float_t thetaX, Float_t phiX, 
55                      Float_t thetaY, Float_t phiY, Float_t thetaZ, 
56                      Float_t phiZ);
57
58     // NEW - for G4 only
59     G4Material* MixMaterials(G4String name, G4double density,
60                      TG4StringVector* matNames, TG4doubleVector* matWeights);
61
62     // functions from GBASE 
63     void  Ggclos(); 
64
65     // functions from GCONS 
66     void  Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
67                          Float_t &dens, Float_t &radl, Float_t &absl,
68                          Float_t* ubuf, Int_t& nbuf); 
69     void  Gstpar(Int_t itmed, const char *param, Float_t parval); 
70     void  Gsckov(Int_t itmed, Int_t npckov, Float_t *ppckov,
71                          Float_t *absco, Float_t *effic, Float_t *rindex); 
72
73     // functions from GGEOM 
74     Int_t Gsvolu(const char *name, const char *shape, Int_t nmed,  
75                          Float_t *upar, Int_t np); 
76     void  Gsdvn(const char *name, const char *mother, Int_t ndiv, 
77                         Int_t iaxis);
78  
79     void  Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
80                          Int_t iaxis, Float_t c0i, Int_t numed); 
81     void  Gsdvt(const char *name, const char *mother, Float_t step,
82                          Int_t iaxis, Int_t numed, Int_t ndvmx); 
83     void  Gsdvt2(const char *name, const char *mother, Float_t step, 
84                          Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx); 
85
86     void  Gsord(const char *name, Int_t iax); 
87     void  Gspos(const char *name, Int_t nr, const char *mother,  
88                         Float_t x, Float_t y, Float_t z, Int_t irot, 
89                         const char *konly); 
90     void  Gsposp(const char *name, Int_t nr, const char *mother,  
91                          Float_t x, Float_t y, Float_t z, Int_t irot,
92                          const char *konly, Float_t *upar, Int_t np); 
93         
94     // Euclid                  
95     void WriteEuclid(const char*, const char*, Int_t, Int_t); //new
96                                
97     // get methods
98     Int_t VolId(const Text_t* volName) const;                
99     const char* VolName(Int_t id) const; //new
100     Int_t NofVolumes() const; 
101     
102     // end of methods
103     // 
104
105     //
106     // methods for Geant4 only 
107  
108     G4VPhysicalVolume* CreateG4Geometry();
109     void ReadG3Geometry(G4String filePath);
110     void UseG3TrackingMediaLimits();
111     void ClearG3Tables();       
112     void ClearG3TablesFinal();
113     void OpenOutFile(G4String filePath);
114     void PrintNameMap();
115     
116     // set methods
117     void SetWriteGeometry(G4bool writeGeometry);
118     void SetMapSecond(const G4String& name);
119
120     // get methods
121           // volumes
122     Int_t NofG3Volumes() const; 
123     Int_t NofG4LogicalVolumes() const; 
124     Int_t NofG4PhysicalVolumes() const; 
125     Int_t NofSensitiveDetectors() const; 
126     G4bool IsG3Volume(G4String lvName) const;
127     void G4ToG3VolumeName(G4String& name) const;
128     const G4String& GetMapSecond(const G4String& name);
129
130           // sensitive volumes
131     G3SensVolVector GetG3SensVolVector() const;
132
133           // materials
134     G4int GetMediumId(G4Material* material) const;    
135     G4double GetEffA(G4Material* material) const;
136     G4double GetEffZ(G4Material* material) const;
137
138     // end of methods for Geant4 only 
139     //
140     
141   protected:
142     TG4GeometryManager(const TG4GeometryManager& right);
143
144     // operators
145     TG4GeometryManager& operator=(const TG4GeometryManager& right);
146
147   private:
148     // methods
149     G4double* CreateG4doubleArray(Float_t* array, G4int size) const;
150     G4String  CutName(const char* name) const;
151     void GstparCut(G4int itmed, TG3Cut par, G4double parval);
152     void GstparFlag(G4int itmed, TG3Flag par, G4double parval);
153     void FillMediumIdVector();
154         
155     // static data members
156     static TG4GeometryManager*  fgInstance;     //this instance
157
158     // data members
159     TG4GeometryOutputManager*   fOutputManager; //output manager 
160     TG4NameMap       fNameMap;         //map of volumes names to modules names
161     vector<G4int>    fMediumIdVector;  //vector of second indexes for materials
162     G4int            fMediumCounter;   //global medium counter
163     G4int            fMaterialCounter; //global material counter
164     G4int            fMatrixCounter;   //global matrix counter
165     G4bool           fUseG3TMLimits;   //if true: G3 limits are passed to G4 
166                                        //(in development)
167     G4bool           fWriteGeometry;   //if true: geometry parameters are written
168                                        //in a file (ASCII)  
169 };
170
171 // inline methods
172 inline TG4GeometryManager* TG4GeometryManager::Instance()
173 { return fgInstance; }
174
175 inline G3SensVolVector TG4GeometryManager::GetG3SensVolVector() const
176 { return G3SensVol; }
177
178 #endif //TG4_GEOMETRY_MANAGER_H
179