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