]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4GeometryManager.h
IS0/ANSI standard corrections: added G4std::, changed endl -> G4endl
[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* fileName, const char* topVolName, 
96                          Int_t number, Int_t nlevel); //new
97                                
98     // get methods
99     Int_t VolId(const Text_t* volName) const;                
100     const char* VolName(Int_t id) const; //new
101     Int_t NofVolumes() const; 
102     
103     // end of methods
104     // 
105
106     //
107     // methods for Geant4 only 
108  
109     G4VPhysicalVolume* CreateG4Geometry();
110     void ReadG3Geometry(G4String filePath);
111     void UseG3TrackingMediaLimits();
112     void ClearG3Tables();       
113     void ClearG3TablesFinal();
114     void OpenOutFile(G4String filePath);
115     void PrintNameMap();
116     
117     // set methods
118     void SetWriteGeometry(G4bool writeGeometry);
119     void SetMapSecond(const G4String& name);
120
121     // get methods
122           // volumes
123     Int_t NofG3Volumes() const; 
124     Int_t NofG4LogicalVolumes() const; 
125     Int_t NofG4PhysicalVolumes() const; 
126     Int_t NofSensitiveDetectors() const; 
127     G4bool IsG3Volume(G4String lvName) const;
128     void G4ToG3VolumeName(G4String& name) const;
129     const G4String& GetMapSecond(const G4String& name);
130
131           // sensitive volumes
132     G3SensVolVector GetG3SensVolVector() const;
133
134           // materials
135     G4int GetMediumId(G4Material* material) const;    
136     G4double GetEffA(G4Material* material) const;
137     G4double GetEffZ(G4Material* material) const;
138
139     // end of methods for Geant4 only 
140     //
141     
142   protected:
143     TG4GeometryManager(const TG4GeometryManager& right);
144
145     // operators
146     TG4GeometryManager& operator=(const TG4GeometryManager& right);
147
148   private:
149     // methods
150     G4double* CreateG4doubleArray(Float_t* array, G4int size) const;
151     G4String  CutName(const char* name) const;
152     void GstparCut(G4int itmed, TG3Cut par, G4double parval);
153     void GstparFlag(G4int itmed, TG3Flag par, G4double parval);
154     void FillMediumIdVector();
155         
156     // static data members
157     static TG4GeometryManager*  fgInstance;     //this instance
158
159     // data members
160     TG4GeometryOutputManager*   fOutputManager; //output manager 
161     TG4NameMap    fNameMap;         //map of volumes names to modules names
162     TG4intVector  fMediumIdVector;  //vector of second indexes for materials
163     G4int         fMediumCounter;   //global medium counter
164     G4int         fMaterialCounter; //global material counter
165     G4int         fMatrixCounter;   //global matrix counter
166     G4bool        fUseG3TMLimits;   //if true: G3 limits are passed to G4 
167                                     //(in development)
168     G4bool        fWriteGeometry;   //if true: geometry parameters are written
169                                     //in a file (ASCII)  
170 };
171
172 // inline methods
173 inline TG4GeometryManager* TG4GeometryManager::Instance()
174 { return fgInstance; }
175
176 inline G3SensVolVector TG4GeometryManager::GetG3SensVolVector() const
177 { return G3SensVol; }
178
179 #endif //TG4_GEOMETRY_MANAGER_H
180