]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFluka.h
Current track number correctly stored in stack.
[u/mrichter/AliRoot.git] / TFluka / TFluka.h
1 #ifndef TFLUKA
2 #define TFLUKA
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 //                                                                           //
10 //                                                                           //
11 // FLUKA implementation of the AliMC Interface                               //
12 //                                                                           //
13 //                                                                           //
14 ///////////////////////////////////////////////////////////////////////////////
15
16
17 #include "TVirtualMC.h"
18 #include "TMCProcess.h" 
19
20 #include <map>
21 #include <vector>
22
23 //Forward declaration
24 class TG4GeometryManager;
25 class TG4DetConstruction;
26 class TClonesArray;
27
28
29 class TFluka : public TVirtualMC {
30   
31  public:
32   TFluka(const char *title, Int_t verbosity = 0);
33   TFluka();
34   virtual ~TFluka();
35   
36   //
37   // methods for building/management of geometry
38   // ------------------------------------------------
39   //
40   
41   // functions from GCONS 
42   virtual void  Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
43                        Float_t &dens, Float_t &radl, Float_t &absl,
44                        Float_t* ubuf, Int_t& nbuf);
45   virtual void  Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,  
46                        Double_t &dens, Double_t &radl, Double_t &absl,
47                        Double_t* ubuf, Int_t& nbuf);
48   
49   // detector composition
50   virtual void  Material(Int_t& kmat, const char* name, Double_t a, 
51                          Double_t z, Double_t dens, Double_t radl, Double_t absl,
52                          Float_t* buf, Int_t nwbuf);
53   virtual void  Material(Int_t& kmat, const char* name, Double_t a, 
54                          Double_t z, Double_t dens, Double_t radl, Double_t absl,
55                          Double_t* buf, Int_t nwbuf);
56   virtual void  Mixture(Int_t& kmat, const char *name, Float_t *a, 
57                         Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat);
58   virtual void  Mixture(Int_t& kmat, const char *name, Double_t *a, 
59                         Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat);
60   virtual void  Medium(Int_t& kmed, const char *name, Int_t nmat, 
61                        Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
62                        Double_t stemax, Double_t deemax, Double_t epsil, 
63                        Double_t stmin, Float_t* ubuf, Int_t nbuf);
64   virtual void  Medium(Int_t& kmed, const char *name, Int_t nmat, 
65                        Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
66                        Double_t stemax, Double_t deemax, Double_t epsil, 
67                        Double_t stmin, Double_t* ubuf, Int_t nbuf);
68   virtual void  Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, 
69                        Double_t thetaY, Double_t phiY, Double_t thetaZ, 
70                        Double_t phiZ);
71   virtual void  Gstpar(Int_t itmed, const char *param, Double_t parval);
72   
73   // functions from GGEOM 
74   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
75                         Float_t *upar, Int_t np);
76   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
77                         Double_t *upar, Int_t np);
78   virtual void  Gsdvn(const char *name, const char *mother, Int_t ndiv, 
79                       Int_t iaxis);
80   virtual void  Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
81                        Int_t iaxis, Double_t c0i, Int_t numed);
82   virtual void  Gsdvt(const char *name, const char *mother, Double_t step, 
83                       Int_t iaxis, Int_t numed, Int_t ndvmx);
84   virtual void  Gsdvt2(const char *name, const char *mother, Double_t step, 
85                        Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx);
86   virtual void  Gsord(const char *name, Int_t iax);
87   virtual void  Gspos(const char *name, Int_t nr, const char *mother,  
88                       Double_t x, Double_t y, Double_t z, Int_t irot, 
89                       const char *konly="ONLY");
90   virtual void  Gsposp(const char *name, Int_t nr, const char *mother,  
91                        Double_t x, Double_t y, Double_t z, Int_t irot,
92                        const char *konly, Float_t *upar, Int_t np);
93   virtual void  Gsposp(const char *name, Int_t nr, const char *mother,  
94                        Double_t x, Double_t y, Double_t z, Int_t irot,
95                        const char *konly, Double_t *upar, Int_t np);
96   virtual void  Gsbool(const char* onlyVolName, const char* manyVolName);
97   
98   virtual void  SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
99                             Float_t *absco, Float_t *effic, Float_t *rindex);
100   virtual void  SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
101                             Double_t *absco, Double_t *effic, Double_t *rindex);
102   
103   
104   // functions for drawing
105   virtual void  DrawOneSpec(const char* name)
106     {printf("WARNING: DrawOneSpec not yet implemented !\n");}
107   virtual void  Gsatt(const char* name, const char* att, Int_t val)
108     {printf("WARNING: Gsatt not yet implemented !\n");}
109   virtual void  Gdraw(const char*,Double_t theta = 30, Double_t phi = 30,
110                       Double_t psi = 0, Double_t u0 = 10, Double_t v0 = 10,
111                       Double_t ul = 0.01, Double_t vl = 0.01)
112     {printf("WARNING: Gdraw not yet implemented !\n");}
113   
114   // Euclid
115   virtual void  WriteEuclid(const char*, const char*, Int_t, Int_t);
116   
117   // get methods
118   virtual Int_t VolId(const Text_t* volName) const;
119   virtual const char* VolName(Int_t id) const;
120   virtual Int_t NofVolumes() const {return fNVolumes;}
121   virtual Int_t VolId2Mate(Int_t id) const;
122   //
123   // methods for physics management
124   // ------------------------------------------------
125   //
126   
127   // set methods
128   virtual void     SetCut(const char* cutName, Double_t cutValue)
129     {printf("WARNING: SetCut not yet implemented !\n");}
130   virtual void     SetProcess(const char* flagName, Int_t flagValue)
131     {printf("WARNING: SetProcess not yet implemented !\n");}
132   virtual Double_t Xsec(char*, Double_t, Int_t, Int_t)
133     {printf("WARNING: Xsec not yet implemented !\n"); return -1.;}
134   
135   // particle table usage         
136   virtual Int_t   IdFromPDG(Int_t id) const;
137   virtual Int_t   PDGFromId(Int_t pdg) const;
138   virtual void    DefineParticles()
139   {printf("WARNING: DefineParticles not yet implemented !\n");}     
140   
141   //
142   // methods for step management
143   // ------------------------------------------------
144   //
145   
146   // action methods
147   virtual void StopTrack()
148     {printf("WARNING: StopTrack not yet implemented !\n");}
149   virtual void StopEvent()
150     {printf("WARNING: StopEvent not yet implemented !\n");}   
151   
152   // set methods
153   virtual void SetMaxStep(Double_t);
154   virtual void SetMaxNStep(Int_t);
155   virtual void SetUserDecay(Int_t);
156   
157   // get methods
158   // tracking volume(s) 
159   virtual Int_t    CurrentVolID(Int_t& copyNo) const;
160   virtual Int_t    CurrentVolOffID(Int_t off, Int_t& copyNo) const;
161   virtual const char* CurrentVolName() const;
162   virtual const char* CurrentVolOffName(Int_t off) const;
163   virtual Int_t    CurrentMaterial(Float_t &a, Float_t &z, 
164                                    Float_t &dens, Float_t &radl, Float_t &absl) const;
165   virtual Int_t    CurrentEvent() const
166       {printf("WARNING: CurrentEvent not yet implemented !\n"); return -1;} 
167   virtual void     Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
168   
169   virtual void     Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
170   
171   virtual void     Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
172   
173   virtual void     Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
174   
175   virtual Double_t MaxStep() const
176     {printf("WARNING: MaxStep not yet implemented !\n"); return -1.;}
177   virtual Int_t    GetMaxNStep() const
178     {printf("WARNING: GetMaxNStep not yet implemented !\n"); return -1;}
179   virtual Int_t    GetMedium() const;
180   
181   // tracking particle 
182   // dynamic properties
183   virtual void     TrackPosition(TLorentzVector& position) const;
184   virtual void     TrackMomentum(TLorentzVector& momentum) const;
185   virtual Double_t TrackStep() const;
186   virtual Double_t TrackLength() const;
187   virtual Double_t TrackTime() const;
188   virtual Double_t Edep() const;
189   // static properties
190   virtual Int_t    TrackPid() const;
191   virtual Double_t TrackCharge() const;
192   virtual Double_t TrackMass() const;
193   virtual Double_t Etot() const;
194   // track status
195   virtual Bool_t   IsNewTrack() const;
196   virtual Bool_t   IsTrackInside() const;
197   virtual Bool_t   IsTrackEntering() const;
198   virtual Bool_t   IsTrackExiting() const;
199   virtual Bool_t   IsTrackOut() const;
200   virtual Bool_t   IsTrackDisappeared() const;
201   virtual Bool_t   IsTrackStop() const;
202   virtual Bool_t   IsTrackAlive() const;
203  
204   // secondaries
205   virtual Int_t    NSecondaries() const ;
206   virtual void     GetSecondary(Int_t isec, Int_t& particleId, 
207                         TLorentzVector& position, TLorentzVector& momentum);
208   virtual TMCProcess ProdProcess(Int_t isec) const ;
209   virtual Int_t    StepProcesses(TArrayI &proc) const
210     {printf("WARNING: StepProcesses not yet implemented !\n"); return -1;}
211   
212   
213   //
214   // Geant3 specific methods
215   // !!! need to be transformed to common interface
216   //
217   virtual void Gdopt(const char*,const char*)
218     {printf("WARNING: Gdopt not yet implemented !\n");}
219   virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
220                           Double_t=0,Double_t=-9999,Double_t=0)
221     {printf("WARNING: SetClipBox not yet implemented !\n");}
222   virtual void DefaultRange()
223     {printf("WARNING: DefaultRange not yet implemented !\n");}
224   virtual void Gdhead(Int_t, const char*, Double_t=0)
225     {printf("WARNING: Gdhead not yet implemented !\n");}  
226   virtual void Gdman(Double_t, Double_t, const char*)
227     {printf("WARNING: Gdman not yet implemented !\n");}
228   virtual void SetColors()
229     {printf("WARNING: SetColors not yet implemented !\n");}
230   virtual void Gtreve()
231     {printf("WARNING: Gtreve not yet implemented !\n");}
232   virtual void GtreveRoot()
233     {printf("WARNING: GtreveRoot not yet implemented !\n");}
234   virtual void Gckmat(Int_t, char*)
235     {printf("WARNING: Gckmat not yet implemented !\n");}
236   virtual void InitLego()
237     {printf("WARNING: InitLego not yet implemented !\n");}
238   virtual void Gfpart(Int_t, char*, Int_t&, Float_t&, Float_t&, Float_t&)
239     {printf("WARNING: Gfpart not yet implemented !\n");}
240   virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
241     {printf("WARNING: Gspart not yet implemented !\n");}
242   
243   //
244   // control methods
245   // ------------------------------------------------
246   //
247   
248   virtual void Init();
249   virtual void FinishGeometry();
250   virtual void BuildPhysics();
251   virtual void ProcessEvent();
252   virtual void ProcessRun(Int_t nevent);
253   
254
255   //
256   //New Getter and Setters
257   // ------------------------------------------------
258   //
259   // - Input file name
260   TString GetInputFileName() const {return fInputFileName;}
261   void SetInputFileName(const char* n) {fInputFileName = n;}
262   // - Verbosity level
263   Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
264   void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
265
266   // - Fluka Draw procedures formal parameters
267   Int_t GetIcode() const {return fIcode;}
268   void SetIcode(Int_t l) {fIcode = l;}
269
270   Int_t GetMreg() const {return fCurrentFlukaRegion;}
271   void SetMreg(Int_t l) {fCurrentFlukaRegion = l;}
272
273   Int_t GetNewreg() const {return fNewreg;}
274   void SetNewreg(Int_t l) {fNewreg = l;}
275
276   Double_t GetRull() const {return fRull;}
277   void SetRull(Double_t r) {fRull = r;}
278
279   Double_t GetXsco() const {return fXsco;}
280   void SetXsco(Double_t x) {fXsco = x;}
281
282   Double_t GetYsco() const {return fYsco;}
283   void SetYsco(Double_t y) {fYsco = y;}
284
285   Double_t GetZsco() const {return fZsco;}
286   void SetZsco(Double_t z) {fZsco = z;}
287
288   void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
289   Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
290
291   void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
292   void SetTrackIsExiting() {fTrackIsExiting  = kTRUE;}
293   void SetTrackIsInside()  {fTrackIsExiting  = kFALSE; fTrackIsEntering = kFALSE;}
294   
295   //
296   // test
297   // ------------------------------------------------
298   //
299   virtual void     FutoTest() ;
300
301  private:
302   TFluka(const TFluka &mc){}
303   TFluka & operator=(const TFluka &) {return (*this);}
304
305  protected:
306   Int_t   fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
307
308   TString fInputFileName; //Name of the input file (f.e. mu.inp)
309
310   Int_t    fIcode;  //Fluka Draw procedures formal parameter 
311   Int_t    fNewreg; //Fluka Draw procedures formal parameter
312   Double_t fRull;   //Fluka Draw procedures formal parameter
313   Double_t fXsco;   //Fluka Draw procedures formal parameter
314   Double_t fYsco;   //Fluka Draw procedures formal parameter
315   Double_t fZsco;   //Fluka Draw procedures formal parameter
316   Bool_t   fTrackIsEntering;  // Flag for track entering
317   Bool_t   fTrackIsExiting;   // Flag for track exiting  
318
319
320   //Geometry through Geant4 for the time being!!!
321   TG4GeometryManager*  fGeometryManager; //Geometry manager
322   TG4DetConstruction*  fDetector;        //Detector
323
324   TClonesArray*        fVolumeMediaMap;  //!Transient list of volumes
325   Int_t                fNVolumes;        //!Current number of volumes
326   Int_t*               fMediaByRegion;   //!Media by Fluka region
327
328   
329   Int_t fCurrentFlukaRegion; //Index of fluka region at each step
330   ClassDef(TFluka,1)  //C++ interface to Fluka montecarlo
331 };
332
333 #endif //TFLUKA
334