]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFluka.h
Coding conventions.
[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 VirtualMC 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 class TGeoMaterial;
28
29
30 class TFluka : public TVirtualMC {
31   
32  public:
33   TFluka(const char *title, Int_t verbosity = 0,  Bool_t isRootGeometrySupported = 0);
34   TFluka();
35   virtual ~TFluka();
36   
37   //
38   // methods for building/management of geometry
39   // ------------------------------------------------
40   //
41   
42   // functions from GCONS 
43   virtual void  Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
44                        Float_t &dens, Float_t &radl, Float_t &absl,
45                        Float_t* ubuf, Int_t& nbuf);
46   virtual void  Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,  
47                        Double_t &dens, Double_t &radl, Double_t &absl,
48                        Double_t* ubuf, Int_t& nbuf);
49   
50   // detector composition
51   virtual void  Material(Int_t& kmat, const char* name, Double_t a, 
52                          Double_t z, Double_t dens, Double_t radl, Double_t absl,
53                          Float_t* buf, Int_t nwbuf);
54   virtual void  Material(Int_t& kmat, const char* name, Double_t a, 
55                          Double_t z, Double_t dens, Double_t radl, Double_t absl,
56                          Double_t* buf, Int_t nwbuf);
57   virtual void  Mixture(Int_t& kmat, const char *name, Float_t *a, 
58                         Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat);
59   virtual void  Mixture(Int_t& kmat, const char *name, Double_t *a, 
60                         Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat);
61   virtual void  Medium(Int_t& kmed, const char *name, Int_t nmat, 
62                        Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
63                        Double_t stemax, Double_t deemax, Double_t epsil, 
64                        Double_t stmin, Float_t* ubuf, Int_t nbuf);
65   virtual void  Medium(Int_t& kmed, const char *name, Int_t nmat, 
66                        Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
67                        Double_t stemax, Double_t deemax, Double_t epsil, 
68                        Double_t stmin, Double_t* ubuf, Int_t nbuf);
69   virtual void  Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, 
70                        Double_t thetaY, Double_t phiY, Double_t thetaZ, 
71                        Double_t phiZ);
72   virtual void  Gstpar(Int_t itmed, const char *param, Double_t parval);
73   
74   // functions from GGEOM 
75   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
76                         Float_t *upar, Int_t np);
77   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
78                         Double_t *upar, Int_t np);
79   virtual void  Gsdvn(const char *name, const char *mother, Int_t ndiv, 
80                       Int_t iaxis);
81   virtual void  Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
82                        Int_t iaxis, Double_t c0i, Int_t numed);
83   virtual void  Gsdvt(const char *name, const char *mother, Double_t step, 
84                       Int_t iaxis, Int_t numed, Int_t ndvmx);
85   virtual void  Gsdvt2(const char *name, const char *mother, Double_t step, 
86                        Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx);
87   virtual void  Gsord(const char *name, Int_t iax);
88   virtual void  Gspos(const char *name, Int_t nr, const char *mother,  
89                       Double_t x, Double_t y, Double_t z, Int_t irot, 
90                       const char *konly="ONLY");
91   virtual void  Gsposp(const char *name, Int_t nr, const char *mother,  
92                        Double_t x, Double_t y, Double_t z, Int_t irot,
93                        const char *konly, Float_t *upar, Int_t np);
94   virtual void  Gsposp(const char *name, Int_t nr, const char *mother,  
95                        Double_t x, Double_t y, Double_t z, Int_t irot,
96                        const char *konly, Double_t *upar, Int_t np);
97   virtual void  Gsbool(const char* onlyVolName, const char* manyVolName);
98   
99   virtual void  SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
100                             Float_t *absco, Float_t *effic, Float_t *rindex);
101   virtual void  SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
102                             Double_t *absco, Double_t *effic, Double_t *rindex);
103   
104   
105   // functions for drawing
106   virtual void  DrawOneSpec(const char* /*name*/)
107     {printf("WARNING: DrawOneSpec not yet implemented !\n");}
108   virtual void  Gsatt(const char* /*name*/, const char* /*att*/, Int_t /*val*/)
109     {printf("WARNING: Gsatt not yet implemented !\n");}
110   virtual void  Gdraw(const char*,Double_t /*theta = 30*/, Double_t /*phi = 30*/,
111                       Double_t /*psi = 0*/, Double_t /*u0 = 10*/, Double_t /*v0 = 10*/,
112                       Double_t /*ul = 0.01*/, Double_t /*vl = 0.01*/)
113     {printf("WARNING: Gdraw not yet implemented !\n");}
114   
115   // Euclid
116   virtual void  WriteEuclid(const char*, const char*, Int_t, Int_t);
117   
118   // get methods
119   virtual Int_t VolId(const Text_t* volName) const;
120   virtual const char* VolName(Int_t id) const;
121   virtual Int_t NofVolumes() const {return fNVolumes;}
122   virtual Int_t VolId2Mate(Int_t id) const;
123   //
124   // methods for physics management
125   // ------------------------------------------------
126   //
127   
128   // set methods
129   virtual void     SetProcess(const char* flagName, Int_t flagValue);
130   virtual void     SetCut(const char* cutName, Double_t cutValue);
131   virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
132   
133   // particle table usage         
134   virtual Int_t   IdFromPDG(Int_t id) const;
135   virtual Int_t   PDGFromId(Int_t pdg) const;
136   virtual void    DefineParticles()
137   {printf("WARNING: DefineParticles not yet implemented !\n");}     
138   
139   //
140   // methods for step management
141   // ------------------------------------------------
142   //
143   
144   // action methods
145   virtual void StopTrack()
146     {printf("WARNING: StopTrack not yet implemented !\n");}
147   virtual void StopEvent()
148     {printf("WARNING: StopEvent not yet implemented !\n");}   
149   
150   // set methods
151   virtual void SetMaxStep(Double_t);
152   virtual void SetMaxNStep(Int_t);
153   virtual void SetUserDecay(Int_t);
154   
155   // get methods
156   // tracking volume(s) 
157   virtual Int_t    CurrentVolID(Int_t& copyNo) const;
158   virtual Int_t    CurrentVolOffID(Int_t off, Int_t& copyNo) const;
159   virtual const char* CurrentVolName() const;
160   virtual const char* CurrentVolOffName(Int_t off) const;
161   virtual Int_t    CurrentMaterial(Float_t &a, Float_t &z, 
162                                    Float_t &dens, Float_t &radl, Float_t &absl) const;
163   virtual Int_t    CurrentEvent() const
164       {printf("WARNING: CurrentEvent not yet implemented !\n"); return -1;} 
165   virtual void     Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
166   
167   virtual void     Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
168   
169   virtual void     Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
170   
171   virtual void     Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
172   
173   virtual Double_t MaxStep() const
174     {printf("WARNING: MaxStep not yet implemented !\n"); return -1.;}
175   virtual Int_t    GetMaxNStep() const
176     {printf("WARNING: GetMaxNStep not yet implemented !\n"); return -1;}
177   virtual Int_t    GetMedium() const;
178   
179   // tracking particle 
180   // dynamic properties
181   virtual void     TrackPosition(TLorentzVector& position) const;
182   virtual void     TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
183   virtual void     TrackMomentum(TLorentzVector& momentum) const;
184   virtual void     TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) 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 iproc) 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     // Dummy methods 
244     virtual void DefineParticle(int, const char*, TMCParticleType, double, double, double){;}
245     virtual void DefineIon(const char*, int, int, int, double, double){;}
246     virtual TString  ParticleName(int) const {return "";}
247     virtual Double_t ParticleMass(int) const {return 0.;}
248     virtual Double_t ParticleCharge(int) const {return 0.;}
249     virtual Double_t ParticleLifeTime(int) const {return 0.;}
250     virtual TMCParticleType ParticleMCType(int) const {return (TMCParticleType) 0;}
251     void   SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
252     Int_t  GetDummyBoundary() const {return fDummyBoundary;}
253   //
254   // control methods
255   // ------------------------------------------------
256   //
257   
258   virtual void Init();
259   virtual void InitPhysics();
260   virtual void FinishGeometry();
261   virtual void BuildPhysics();
262   virtual void ProcessEvent();
263   virtual void ProcessRun(Int_t nevent);
264   
265
266   //
267   //New Getter and Setters
268   // ------------------------------------------------
269   //
270   // - Core input file name
271   TString GetCoreInputFileName() const {return sCoreInputFileName;}
272   void SetCoreInputFileName(const char* n) {sCoreInputFileName = n;}
273
274   // - Input file name
275   TString GetInputFileName() const {return sInputFileName;}
276   void SetInputFileName(const char* n) {sInputFileName = n;}
277
278   // - SetProcess and SetCut
279   Int_t GetProcessNb() const {return iNbOfProc;}
280   void SetProcessNb(Int_t l) {iNbOfProc = l;}
281   Int_t GetCutNb() const {return iNbOfProc;}
282   void SetCutNb(Int_t l) {iNbOfCut = l;}
283
284   // - Verbosity level
285   Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
286   void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
287
288   // - Fluka Draw procedures identifiers
289   // bxdraw = 1  inside
290   // bxdraw = 11 entering
291   // bxdraw = 12 exiting
292   // eedraw = 2
293   // endraw = 3
294   // mgdraw = 4
295   // sodraw = 5
296   // usdraw = 6
297   Int_t GetCaller() const {return fCaller;}
298   void SetCaller(Int_t l) {fCaller = l;}
299   
300   // - Fluka Draw procedures formal parameters
301   Int_t GetIcode() const {return fIcode;}
302   void SetIcode(Int_t l) {fIcode = l;}
303   // in the case of sodraw fIcode=0
304
305   Int_t GetMreg() const {return fCurrentFlukaRegion;}
306   void SetMreg(Int_t l) {fCurrentFlukaRegion = l;}
307
308   Int_t GetNewreg() const {return iNewreg;}
309   void SetNewreg(Int_t l) {iNewreg = l;}
310
311   Double_t GetRull() const {return fRull;}
312   void SetRull(Double_t r) {fRull = r;}
313
314   Double_t GetXsco() const {return fXsco;}
315   void SetXsco(Double_t x) {fXsco = x;}
316
317   Double_t GetYsco() const {return fYsco;}
318   void SetYsco(Double_t y) {fYsco = y;}
319
320   Double_t GetZsco() const {return fZsco;}
321   void SetZsco(Double_t z) {fZsco = z;}
322
323   void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
324   Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
325
326   void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
327   void SetTrackIsExiting() {fTrackIsExiting  = kTRUE; fTrackIsEntering = kFALSE;}
328   void SetTrackIsInside()  {fTrackIsExiting  = kFALSE; fTrackIsEntering = kFALSE;}
329   void SetTrackIsNew(Bool_t flag=kTRUE) {fTrackIsNew = flag;}
330
331  private:
332   TFluka(const TFluka &mc): TVirtualMC(mc) {;}
333   TFluka & operator=(const TFluka &) {return (*this);}
334                                                                                 
335  protected:
336   Int_t   fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
337                                                                                 
338   TString sInputFileName;     //Name of the real input file (e.g. alice.inp)
339   TString sCoreInputFileName; //Name of the input file (e.g. corealice.inp)
340                                                                                 
341   Int_t    fCaller; //Parameter to indicate who is the caller of the Fluka Draw
342   Int_t    fIcode;  //Fluka Draw procedures formal parameter
343   Int_t    iNewreg; //Fluka Draw procedures formal parameter
344   Double_t fRull;   //Fluka Draw procedures formal parameter
345   Double_t fXsco;   //Fluka Draw procedures formal parameter
346   Double_t fYsco;   //Fluka Draw procedures formal parameter
347   Double_t fZsco;   //Fluka Draw procedures formal parameter
348   Bool_t   fTrackIsEntering;  // Flag for track entering
349   Bool_t   fTrackIsExiting;   // Flag for track exiting
350   Bool_t   fTrackIsNew;       // Flag for new track
351                                                                                 
352   //variables for SetProcess and SetCut
353   Int_t    iNbOfProc;
354   Int_t    iProcessValue[100];
355   Char_t   sProcessFlag[100][5];
356   Int_t    iNbOfCut;
357   Double_t fCutValue[100];
358   Char_t   sCutFlag[100][7];
359   Int_t    fDummyBoundary;
360   
361   //Geometry through Geant4 for the time being!!!
362   TG4GeometryManager*  fGeometryManager; //Geometry manager
363   TG4DetConstruction*  fDetector;        //Detector
364                                                                                 
365   TClonesArray*        fVolumeMediaMap;  //!Transient list of volumes
366
367   Int_t                fNVolumes;        //!Current number of volumes
368   Int_t*               fMediaByRegion;   //!Media by Fluka region
369   Int_t                fCurrentFlukaRegion; //Index of fluka region at each step
370   ClassDef(TFluka,1)  //C++ interface to Fluka montecarlo
371 };
372
373 #endif //TFLUKA
374