]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/TFluka.h
Extracting PHOS and EMCAL trackers from the correspondig reconstructors (Yu.Belikov)
[u/mrichter/AliRoot.git] / TFluka / TFluka.h
1 #ifndef TFLUKA_H
2 #define TFLUKA_H
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
19 //Forward declaration
20 class TGeoMCGeometry;
21 class TFlukaMCGeometry;
22 class TGeoMaterial;
23
24 class TFluka : public TVirtualMC {
25   
26  public:
27   TFluka(const char *title, Int_t verbosity = 0,  Bool_t isRootGeometrySupported = 0);
28   TFluka();
29   virtual ~TFluka();
30   
31   //
32   // Methods for building/management of geometry
33   // ------------------------------------------------
34   //
35   
36   // Functions from GCONS 
37   virtual void   Gfmate(Int_t imat, char *name, Float_t &a, Float_t &z,  
38                         Float_t &dens, Float_t &radl, Float_t &absl,
39                         Float_t* ubuf, Int_t& nbuf);
40   virtual void   Gfmate(Int_t imat, char *name, Double_t &a, Double_t &z,
41                         Double_t &dens, Double_t &radl, Double_t &absl,
42                         Double_t* ubuf, Int_t& nbuf);
43   
44   // Detector composition
45   virtual void   Material(Int_t& kmat, const char* name, Double_t a, 
46                           Double_t z, Double_t dens, Double_t radl, Double_t absl,
47                           Float_t* buf, Int_t nwbuf);
48   virtual void   Material(Int_t& kmat, const char* name, Double_t a, 
49                           Double_t z, Double_t dens, Double_t radl, Double_t absl,
50                           Double_t* buf, Int_t nwbuf);
51   virtual void   Mixture(Int_t& kmat, const char *name, Float_t *a, 
52                          Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat);
53   virtual void   Mixture(Int_t& kmat, const char *name, Double_t *a, 
54                          Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat);
55   virtual void   Medium(Int_t& kmed, const char *name, Int_t nmat, 
56                         Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
57                         Double_t stemax, Double_t deemax, Double_t epsil, 
58                         Double_t stmin, Float_t* ubuf, Int_t nbuf);
59   virtual void   Medium(Int_t& kmed, const char *name, Int_t nmat, 
60                         Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, 
61                         Double_t stemax, Double_t deemax, Double_t epsil, 
62                         Double_t stmin, Double_t* ubuf, Int_t nbuf);
63   virtual void   Matrix(Int_t& krot, Double_t thetaX, Double_t phiX, 
64                         Double_t thetaY, Double_t phiY, Double_t thetaZ, 
65                         Double_t phiZ);
66   virtual void   Gstpar(Int_t itmed, const char *param, Double_t parval);
67   
68   // Functions from GGEOM 
69   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
70                         Float_t *upar, Int_t np);
71   virtual Int_t  Gsvolu(const char *name, const char *shape, Int_t nmed,  
72                         Double_t *upar, Int_t np);
73   virtual void   Gsdvn(const char *name, const char *mother, Int_t ndiv, 
74                        Int_t iaxis);
75   virtual void   Gsdvn2(const char *name, const char *mother, Int_t ndiv, 
76                         Int_t iaxis, Double_t c0i, Int_t numed);
77   virtual void   Gsdvt(const char *name, const char *mother, Double_t step, 
78                        Int_t iaxis, Int_t numed, Int_t ndvmx);
79   virtual void   Gsdvt2(const char *name, const char *mother, Double_t step, 
80                        Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx);
81   virtual void   Gsord(const char *name, Int_t iax);
82   virtual void   Gspos(const char *name, Int_t nr, const char *mother,  
83                        Double_t x, Double_t y, Double_t z, Int_t irot, 
84                       const char *konly="ONLY");
85   virtual void   Gsposp(const char *name, Int_t nr, const char *mother,  
86                         Double_t x, Double_t y, Double_t z, Int_t irot,
87                         const char *konly, Float_t *upar, Int_t np);
88   virtual void   Gsposp(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, Double_t *upar, Int_t np);
91   virtual void   Gsbool(const char* onlyVolName, const char* manyVolName);
92   
93   virtual void   SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
94                              Float_t *absco, Float_t *effic, Float_t *rindex);
95   virtual void   SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
96                              Double_t *absco, Double_t *effic, Double_t *rindex);
97   
98   
99   // Functions for drawing
100   virtual void   DrawOneSpec(const char* /*name*/)
101       {printf("WARNING: DrawOneSpec not yet implemented !\n");}
102   virtual void   Gsatt(const char* name, const char* att, Int_t val);
103   virtual void   Gdraw(const char*,Double_t /*theta = 30*/, Double_t /*phi = 30*/,
104                        Double_t /*psi = 0*/, Double_t /*u0 = 10*/, Double_t /*v0 = 10*/,
105                        Double_t /*ul = 0.01*/, Double_t /*vl = 0.01*/)
106       {printf("WARNING: Gdraw not yet implemented !\n");}
107   
108   // Euclid
109   virtual void   WriteEuclid(const char*, const char*, Int_t, Int_t);
110   
111   // Getters
112   virtual Int_t  VolId(const Text_t* volName) const;
113   virtual const  char* VolName(Int_t id) const;
114   virtual Int_t  NofVolumes() const {return fNVolumes;}
115   virtual Int_t  VolId2Mate(Int_t id) const;
116   //
117   // Methods for physics management
118   // ------------------------------------------------
119   //
120   
121   // User configuration
122   virtual Bool_t   SetProcess(const char* flagName, Int_t flagValue);
123   virtual void     SetProcess(const char* flagName, Int_t flagValue, Int_t imed);
124   virtual Bool_t   SetCut(const char* cutName, Double_t cutValue);
125   virtual void     SetCut(const char* cutName, Double_t cutValue, Int_t imed);
126   virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
127   
128   // Particle table usage         
129   virtual Int_t    IdFromPDG(Int_t id) const;
130   virtual Int_t    PDGFromId(Int_t pdg) const;
131   virtual void     DefineParticles()
132   {printf("WARNING: DefineParticles not yet implemented !\n");}     
133   
134   //
135   // methods for step management
136   // ------------------------------------------------
137   //
138   
139   // Action methods
140   virtual void   StopTrack();
141   virtual void   ResetStoppingCondition() {fStopped = kFALSE;}
142   virtual Bool_t GetStoppingCondition()   {return fStopped;}
143
144   virtual void   StopEvent() {fStopEvent = kTRUE;}   
145   virtual void   StopRun()   {fStopEvent = kTRUE; fStopRun   = kTRUE;}
146   virtual Bool_t EventIsStopped() {return fStopEvent;}
147   virtual void   SetStopEvent(Bool_t flag) {fStopEvent = flag;}
148   
149   // Set methods
150   virtual void SetMaxStep (Double_t step);
151   virtual void SetMaxNStep(Int_t);
152   virtual void SetUserDecay(Int_t);
153   
154   // Get methods
155   // Tracking volume(s) 
156   virtual Int_t    CurrentVolID(Int_t& copyNo) const;
157   virtual Int_t    CurrentVolOffID(Int_t off, Int_t& copyNo) const;
158   virtual const char* CurrentVolName() const;
159   virtual const char* CurrentVolOffName(Int_t off) const;
160   virtual Int_t    CurrentMaterial(Float_t &a, Float_t &z, 
161                                    Float_t &dens, Float_t &radl, Float_t &absl) const;
162   virtual Int_t    CurrentEvent() const {return fNEvent;}
163
164   virtual void     Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
165   
166   virtual void     Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
167   
168   virtual void     Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
169   
170   virtual void     Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
171   
172   virtual Double_t MaxStep() const;
173   virtual Int_t    GetMaxNStep() const
174       {printf("WARNING: GetMaxNStep not yet implemented !\n"); return -1;}
175   virtual Int_t    GetMedium() const;
176   
177   // Tracking particle 
178   // dynamic properties
179   virtual void     TrackPosition(TLorentzVector& position) const;
180   virtual void     TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
181   virtual void     TrackMomentum(TLorentzVector& momentum) const;
182   virtual void     TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const;
183   virtual Double_t TrackStep() const;
184   virtual Double_t TrackLength() const;
185   virtual Double_t TrackTime() const;
186   virtual Double_t Edep() const;
187   // Static properties
188   virtual Int_t    TrackPid() const;
189   virtual Double_t TrackCharge() const;
190   virtual Double_t TrackMass() const;
191   virtual Double_t Etot() const;
192   // Track status
193   virtual Bool_t   IsNewTrack() const;
194   virtual Bool_t   IsTrackInside() const;
195   virtual Bool_t   IsTrackEntering() const;
196   virtual Bool_t   IsTrackExiting() const;
197   virtual Bool_t   IsTrackOut() const;
198   virtual Bool_t   IsTrackDisappeared() const;
199   virtual Bool_t   IsTrackStop() const;
200   virtual Bool_t   IsTrackAlive() const;
201  
202   // Secondaries
203   virtual Int_t    NSecondaries() const;
204   virtual void     SetNCerenkov(Int_t nc) {fNCerenkov = nc;}
205           
206   virtual void     GetSecondary(Int_t isec, Int_t& particleId, 
207                         TLorentzVector& position, TLorentzVector& momentum);
208   virtual Bool_t   SecondariesAreOrdered() const {return kFALSE;}
209   virtual TMCProcess ProdProcess(Int_t iproc) const ;
210   virtual Int_t    StepProcesses(TArrayI & proc) const;
211   //
212   // Geant3 specific methods
213   // !!! need to be transformed to common interface
214   //
215   virtual void Gdopt(const char*,const char*)
216     {printf("WARNING: Gdopt not yet implemented !\n");}
217   virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
218                           Double_t=0,Double_t=-9999,Double_t=0)
219     {printf("WARNING: SetClipBox not yet implemented !\n");}
220   virtual void DefaultRange()
221     {printf("WARNING: DefaultRange not yet implemented !\n");}
222   virtual void Gdhead(Int_t, const char*, Double_t=0)
223     {printf("WARNING: Gdhead not yet implemented !\n");}  
224   virtual void Gdman(Double_t, Double_t, const char*)
225     {printf("WARNING: Gdman not yet implemented !\n");}
226   virtual void SetColors()
227     {printf("WARNING: SetColors not yet implemented !\n");}
228   virtual void Gtreve()
229     {printf("WARNING: Gtreve not yet implemented !\n");}
230   virtual void GtreveRoot()
231     {printf("WARNING: GtreveRoot not yet implemented !\n");}
232   virtual void Gckmat(Int_t, char*)
233     {printf("WARNING: Gckmat not yet implemented !\n");}
234   virtual void InitLego()
235     {printf("WARNING: InitLego not yet implemented !\n");}
236 //
237   virtual void Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife);
238   virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
239       {printf("WARNING: Gspart not yet implemented !\n");}
240
241
242   //
243   // FLUKA Scoring specific methods
244   // ------------------------------
245   //
246   virtual void SetUserScoring(const char* option, Int_t npar, Float_t* what);
247   //
248   // Particle Properties
249   // -------------------
250   //
251   virtual Bool_t DefineParticle(int, const char*, TMCParticleType, double, double, double) {return kFALSE;}
252   virtual Bool_t DefineIon(const char*, int, int, int, double, double) {return kFALSE;}
253   virtual TString  ParticleName(int pdg)      const;
254   virtual Double_t ParticleMass(int pdg)      const;
255   virtual Double_t ParticleCharge(int pdg)    const;
256   virtual Double_t ParticleLifeTime(int pdg)  const;
257   virtual TMCParticleType ParticleMCType(int) const {return (TMCParticleType) 9;}
258   //
259   // Control methods
260   // ------------------------------------------------
261   //
262   
263   virtual void Init();
264   virtual void InitPhysics();
265   virtual void FinishGeometry();
266   virtual void BuildPhysics();
267   virtual void ProcessEvent();
268   virtual Bool_t ProcessRun(Int_t nevent);
269
270   //
271   // New Getter and Setters
272   // ------------------------------------------------
273   //
274   // - Core input file name
275   TString GetCoreInputFileName() const {return fCoreInputFileName;}
276   void SetCoreInputFileName(const char* file = "coreFlukaVmc.inp") {fCoreInputFileName = file;}
277
278   // - Input file name
279   TString GetInputFileName() const {return fInputFileName;}
280   void SetInputFileName(const char* file = "FlukaVmc.inp") {fInputFileName = file;}
281
282   // - Verbosity level
283   Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
284   void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
285
286   // - Fluka Draw procedures identifiers
287   // bxdraw = 1  inside
288   // bxdraw = 11 entering
289   // bxdraw = 12 exiting
290   // eedraw = 2
291   // endraw = 3
292   // mgdraw = 4
293   // sodraw = 5
294   // usdraw = 6
295   Int_t GetCaller() const {return fCaller;}
296   void SetCaller(Int_t l) {fCaller = l;}
297   
298   // - Fluka Draw procedures formal parameters
299   Int_t GetIcode() const {return fIcode;}
300   void SetIcode(Int_t l) {fIcode = l;}
301   // in the case of sodraw fIcode=0
302
303   Int_t GetMreg() const {return fCurrentFlukaRegion;}
304   void SetMreg(Int_t l);
305
306   Int_t GetNewreg() const {return fNewReg;}
307   void SetNewreg(Int_t l) {fNewReg = l;}
308
309   Double_t GetRull() const {return fRull;}
310   void SetRull(Double_t r) {fRull = r;}
311
312   Double_t GetXsco() const {return fXsco;}
313   void SetXsco(Double_t x) {fXsco = x;}
314
315   Double_t GetYsco() const {return fYsco;}
316   void SetYsco(Double_t y) {fYsco = y;}
317
318   Double_t GetZsco() const {return fZsco;}
319   void SetZsco(Double_t z) {fZsco = z;}
320
321   void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
322   Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
323
324   void   SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
325   Int_t  GetDummyBoundary() const {return fDummyBoundary;}
326   Bool_t IsDummyBoundary() const {return (fDummyBoundary==0)?kFALSE:kTRUE;}
327   
328   void   SetGeneratePemf(Bool_t flag = kTRUE) {fGeneratePemf = flag;}
329   Bool_t IsGeneratePemf() const {return fGeneratePemf;}
330   
331   void   EnableField(Bool_t flag=kTRUE) {fFieldFlag = flag;}
332   Bool_t IsFieldEnabled() const {return fFieldFlag;}
333   void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
334   void SetTrackIsExiting() {fTrackIsExiting  = kTRUE; fTrackIsEntering = kFALSE;}
335   void SetTrackIsInside()  {fTrackIsExiting  = kFALSE; fTrackIsEntering = kFALSE;}
336   void SetTrackIsNew(Bool_t flag = kTRUE);
337   
338   Int_t GetMaterialIndex(Int_t idmat) const {return fMaterials[idmat];}
339   TObjArray *GetFlukaMaterials();
340   //
341   // Fluka specific scoring options
342   //
343
344   Bool_t  SetFlukaScoringOption(Float_t what[12], const char* sdum) {return kTRUE;}
345       
346   private:
347   TFluka(const TFluka &mc): TVirtualMC(mc) {;}
348   TFluka & operator=(const TFluka &) {return (*this);}
349
350   
351   Int_t   fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
352   Int_t   fNEvent;         //Current event number
353   TString fInputFileName;     //Name of the real input file 
354   TString fCoreInputFileName; //Name of the input file 
355
356   Int_t    fCaller; //Parameter to indicate who is the caller of the Fluka Draw
357   Int_t    fIcode;  //Fluka Draw procedures formal parameter 
358   Int_t    fNewReg; //Fluka Draw procedures formal parameter
359   Double_t fRull;   //Fluka Draw procedures formal parameter
360   Double_t fXsco;   //Fluka Draw procedures formal parameter
361   Double_t fYsco;   //Fluka Draw procedures formal parameter
362   Double_t fZsco;   //Fluka Draw procedures formal parameter
363   Bool_t   fTrackIsEntering;  // Flag for track entering
364   Bool_t   fTrackIsExiting;   // Flag for track exiting  
365   Bool_t   fTrackIsNew;       // Flag for new track
366   Bool_t   fFieldFlag;        // Flag for magnetic field
367   Bool_t   fGeneratePemf;     // Flag for automatic .pemf generation
368   Int_t    fDummyBoundary;    // Flag for crossing dummy boundaries
369   Bool_t   fStopped;          // Flag for stopping 
370   Bool_t   fStopEvent;        // Flag for stopped event
371   Bool_t   fStopRun;          // Flag for stopped run 
372   
373   //
374   //Geometry through TGeo
375   //
376   Int_t*               fMaterials;          //!Array of indices
377   Int_t                fNVolumes;           //!Current number of volumes
378   Int_t                fCurrentFlukaRegion; // Index of fluka region at each step
379   Int_t                fNCerenkov;          // Number of cerekov photons 
380   TFlukaMCGeometry    *fGeom;               // TGeo-FLUKA interface
381   TGeoMCGeometry      *fMCGeo;              // Interface to TGeo builder
382
383   // SetProcess, SetCut and user Scoring dynamic storage
384   TObjArray* fProcesses;             // List of processes
385   TObjArray* fCuts;                  // List of cuts
386   TObjArray* fUserScore;             // List of user scoring options
387   
388   ClassDef(TFluka,1)  //C++ interface to Fluka montecarlo
389 };
390
391 #endif //TFLUKA
392