Fixing a little bug
[u/mrichter/AliRoot.git] / TFluka / TFluka.h
CommitLineData
6f5667d1 1#ifndef TFLUKA_H
2#define TFLUKA_H
829fb838 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"
a9ea1616 18#include "TFlukaCodes.h"
829fb838 19//Forward declaration
6f5667d1 20class TGeoMCGeometry;
829fb838 21class TFlukaMCGeometry;
22class TGeoMaterial;
23
24class TFluka : public TVirtualMC {
25
26 public:
27 TFluka(const char *title, Int_t verbosity = 0, Bool_t isRootGeometrySupported = 0);
28 TFluka();
29 virtual ~TFluka();
7110de2d 30 virtual Bool_t IsRootGeometrySupported() const { return kTRUE;}
829fb838 31
32 //
b496f27c 33 // Methods for building/management of geometry
829fb838 34 // ------------------------------------------------
35 //
36
b496f27c 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
829fb838 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);
b496f27c 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,
829fb838 81 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx);
b496f27c 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,
829fb838 85 const char *konly="ONLY");
b496f27c 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
a9ea1616 94 // functions for access to geometry
95 //
96 // Return the Transformation matrix between the volume specified by
97 // the path volumePath and the top or master volume.
98 virtual Bool_t GetTransformation(const TString& volumePath,
99 TGeoHMatrix& matrix);
100
101 // Return the name of the shape and its parameters for the volume
102 // specified by the volume name.
103 virtual Bool_t GetShape(const TString& volumePath,
104 TString& shapeType, TArrayD& par);
105
106 // Returns the material parameters for the volume specified by
107 // the volume name.
108 virtual Bool_t GetMaterial(const TString& volumeName,
109 TString& name, Int_t& imat,
110 Double_t& a, Double_t& z, Double_t& density,
111 Double_t& radl, Double_t& inter, TArrayD& par);
112
113 // Returns the medium parameters for the volume specified by the
114 // volume name.
115 virtual Bool_t GetMedium(const TString& volumeName,
116 TString& name, Int_t& imed,
117 Int_t& nmat, Int_t& isvol, Int_t& ifield,
118 Double_t& fieldm, Double_t& tmaxfd, Double_t& stemax,
119 Double_t& deemax, Double_t& epsil, Double_t& stmin,
120 TArrayD& par);
121
b496f27c 122 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
123 Float_t *absco, Float_t *effic, Float_t *rindex);
124 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
125 Double_t *absco, Double_t *effic, Double_t *rindex);
b2be0e73 126 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
127 Float_t *absco, Float_t *effic, Float_t *rindex, Float_t *rfl);
128 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
129 Double_t *absco, Double_t *effic, Double_t *rindex, Double_t *rfl);
b496f27c 130
131
132 // Functions for drawing
133 virtual void DrawOneSpec(const char* /*name*/)
a9ea1616 134 {Warning("DrawOneSpec", "Not yet implemented !\n");}
b496f27c 135 virtual void Gsatt(const char* name, const char* att, Int_t val);
136 virtual void Gdraw(const char*,Double_t /*theta = 30*/, Double_t /*phi = 30*/,
137 Double_t /*psi = 0*/, Double_t /*u0 = 10*/, Double_t /*v0 = 10*/,
138 Double_t /*ul = 0.01*/, Double_t /*vl = 0.01*/)
a9ea1616 139 {Warning("Gdraw", "Not yet implemented !\n");}
829fb838 140
141 // Euclid
b496f27c 142 virtual void WriteEuclid(const char*, const char*, Int_t, Int_t);
829fb838 143
b496f27c 144 // Getters
a9ea1616 145 Int_t GetDummyRegion() const;
146 Int_t GetDummyLattice() const;
b496f27c 147 virtual Int_t VolId(const Text_t* volName) const;
148 virtual const char* VolName(Int_t id) const;
149 virtual Int_t NofVolumes() const {return fNVolumes;}
150 virtual Int_t VolId2Mate(Int_t id) const;
829fb838 151 //
b496f27c 152 // Methods for physics management
829fb838 153 // ------------------------------------------------
154 //
155
b496f27c 156 // User configuration
b2129742 157 virtual Bool_t SetProcess(const char* flagName, Int_t flagValue);
158 virtual void SetProcess(const char* flagName, Int_t flagValue, Int_t imed);
159 virtual Bool_t SetCut(const char* cutName, Double_t cutValue);
160 virtual void SetCut(const char* cutName, Double_t cutValue, Int_t imed);
acf2e119 161 virtual void SetModelParameter(const char* parName, Double_t parValue, Int_t imed);
fb2cbbec 162 virtual TObjArray* GetListOfUserConfigs() {return fUserConfig;}
b2129742 163 virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
f450e9d0 164
829fb838 165
b496f27c 166 // Particle table usage
167 virtual Int_t IdFromPDG(Int_t id) const;
168 virtual Int_t PDGFromId(Int_t pdg) const;
169 virtual void DefineParticles()
a9ea1616 170 {Warning("DefineParticles", "Not yet implemented !\n");}
829fb838 171
172 //
173 // methods for step management
174 // ------------------------------------------------
175 //
176
b496f27c 177 // Action methods
bd3d5c8a 178 virtual void StopTrack();
179 virtual void ResetStoppingCondition() {fStopped = kFALSE;}
eb49ba4d 180 virtual Bool_t GetStoppingCondition() const {return fStopped;}
bd3d5c8a 181
b496f27c 182 virtual void StopEvent() {fStopEvent = kTRUE;}
183 virtual void StopRun() {fStopEvent = kTRUE; fStopRun = kTRUE;}
eb49ba4d 184 virtual Bool_t EventIsStopped() const {return fStopEvent;}
b496f27c 185 virtual void SetStopEvent(Bool_t flag) {fStopEvent = flag;}
829fb838 186
b496f27c 187 // Set methods
07f5b33e 188 virtual void SetMaxStep (Double_t step);
829fb838 189 virtual void SetMaxNStep(Int_t);
190 virtual void SetUserDecay(Int_t);
191
b496f27c 192 // Get methods
193 // Tracking volume(s)
829fb838 194 virtual Int_t CurrentVolID(Int_t& copyNo) const;
195 virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const;
196 virtual const char* CurrentVolName() const;
197 virtual const char* CurrentVolOffName(Int_t off) const;
198 virtual Int_t CurrentMaterial(Float_t &a, Float_t &z,
199 Float_t &dens, Float_t &radl, Float_t &absl) const;
b496f27c 200 virtual Int_t CurrentEvent() const {return fNEvent;}
201
829fb838 202 virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
203
204 virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
205
206 virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
207
208 virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
209
2f09b80e 210 virtual Double_t MaxStep() const;
829fb838 211 virtual Int_t GetMaxNStep() const
a9ea1616 212 {Warning("GetMaxNStep", "Not yet implemented !\n"); return -1;}
829fb838 213 virtual Int_t GetMedium() const;
432716fc 214 virtual Int_t CurrentMedium() const {return GetMedium();}
829fb838 215
b496f27c 216 // Tracking particle
829fb838 217 // dynamic properties
218 virtual void TrackPosition(TLorentzVector& position) const;
219 virtual void TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
220 virtual void TrackMomentum(TLorentzVector& momentum) const;
221 virtual void TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const;
222 virtual Double_t TrackStep() const;
223 virtual Double_t TrackLength() const;
224 virtual Double_t TrackTime() const;
225 virtual Double_t Edep() const;
b496f27c 226 // Static properties
18e0cabb 227 virtual Int_t CorrectFlukaId() const;
829fb838 228 virtual Int_t TrackPid() const;
229 virtual Double_t TrackCharge() const;
230 virtual Double_t TrackMass() const;
231 virtual Double_t Etot() const;
b496f27c 232 // Track status
829fb838 233 virtual Bool_t IsNewTrack() const;
234 virtual Bool_t IsTrackInside() const;
235 virtual Bool_t IsTrackEntering() const;
236 virtual Bool_t IsTrackExiting() const;
237 virtual Bool_t IsTrackOut() const;
238 virtual Bool_t IsTrackDisappeared() const;
239 virtual Bool_t IsTrackStop() const;
240 virtual Bool_t IsTrackAlive() const;
241
b496f27c 242 // Secondaries
7b203b6e 243 virtual Int_t NSecondaries() const;
244 virtual void SetNCerenkov(Int_t nc) {fNCerenkov = nc;}
245
829fb838 246 virtual void GetSecondary(Int_t isec, Int_t& particleId,
247 TLorentzVector& position, TLorentzVector& momentum);
bd3d5c8a 248 virtual Bool_t SecondariesAreOrdered() const {return kFALSE;}
829fb838 249 virtual TMCProcess ProdProcess(Int_t iproc) const ;
b496f27c 250 virtual Int_t StepProcesses(TArrayI & proc) const;
829fb838 251 //
252 // Geant3 specific methods
253 // !!! need to be transformed to common interface
254 //
255 virtual void Gdopt(const char*,const char*)
a9ea1616 256 {Warning("Gdopt", "Not yet implemented !\n");}
829fb838 257 virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
258 Double_t=0,Double_t=-9999,Double_t=0)
a9ea1616 259 {Warning("SetClipBox", "Not yet implemented !\n");}
829fb838 260 virtual void DefaultRange()
a9ea1616 261 {Warning("DefaultRange", "Not yet implemented !\n");}
829fb838 262 virtual void Gdhead(Int_t, const char*, Double_t=0)
a9ea1616 263 {Warning("Gdhead", "Not yet implemented !\n");}
829fb838 264 virtual void Gdman(Double_t, Double_t, const char*)
a9ea1616 265 {Warning("Gdman", "Not yet implemented !\n");}
829fb838 266 virtual void SetColors()
a9ea1616 267 {Warning("SetColors", "Not yet implemented !\n");}
829fb838 268 virtual void Gtreve()
a9ea1616 269 {Warning("Gtreve", "Not yet implemented !\n");}
829fb838 270 virtual void GtreveRoot()
a9ea1616 271 {Warning("GtreveRoot", "Not yet implemented !\n");}
829fb838 272 virtual void Gckmat(Int_t, char*)
a9ea1616 273 {Warning("Gckmat", "Not yet implemented !\n");}
829fb838 274 virtual void InitLego()
a9ea1616 275 {Warning("InitLego", "Not yet implemented !\n");}
b496f27c 276//
277 virtual void Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife);
829fb838 278 virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
a9ea1616 279 {Warning("Gspart", "Not yet implemented !\n");}
b496f27c 280
b496f27c 281 //
282 // Particle Properties
283 // -------------------
284 //
285 virtual Bool_t DefineParticle(int, const char*, TMCParticleType, double, double, double) {return kFALSE;}
286 virtual Bool_t DefineIon(const char*, int, int, int, double, double) {return kFALSE;}
287 virtual TString ParticleName(int pdg) const;
288 virtual Double_t ParticleMass(int pdg) const;
ece92b30 289 virtual Double_t ParticleMassFPC(int fpc) const;
b496f27c 290 virtual Double_t ParticleCharge(int pdg) const;
291 virtual Double_t ParticleLifeTime(int pdg) const;
292 virtual TMCParticleType ParticleMCType(int) const {return (TMCParticleType) 9;}
829fb838 293 //
b496f27c 294 // Control methods
829fb838 295 // ------------------------------------------------
296 //
297
298 virtual void Init();
299 virtual void InitPhysics();
300 virtual void FinishGeometry();
301 virtual void BuildPhysics();
302 virtual void ProcessEvent();
303 virtual Bool_t ProcessRun(Int_t nevent);
304
f450e9d0 305
306 //
307 // FLUKA Scoring specific methods
308 // ------------------------------
309 //
310 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what);
311 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what,
312 const char* det1, const char* det2, const char* det3);
829fb838 313 //
b496f27c 314 // New Getter and Setters
829fb838 315 // ------------------------------------------------
316 //
317 // - Core input file name
318 TString GetCoreInputFileName() const {return fCoreInputFileName;}
3b8c325d 319 void SetCoreInputFileName(const char* file = "coreFlukaVmc.inp") {fCoreInputFileName = file;}
829fb838 320
321 // - Input file name
322 TString GetInputFileName() const {return fInputFileName;}
3b8c325d 323 void SetInputFileName(const char* file = "FlukaVmc.inp") {fInputFileName = file;}
829fb838 324
829fb838 325 // - Verbosity level
326 Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
327 void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
328
329 // - Fluka Draw procedures identifiers
330 // bxdraw = 1 inside
331 // bxdraw = 11 entering
332 // bxdraw = 12 exiting
333 // eedraw = 2
334 // endraw = 3
335 // mgdraw = 4
336 // sodraw = 5
337 // usdraw = 6
a9ea1616 338 FlukaCallerCode_t GetCaller() const {return fCaller;}
339 void SetCaller(FlukaCallerCode_t l) {fCaller = l;}
829fb838 340
a9ea1616 341 FlukaProcessCode_t GetIcode() const {return fIcode;}
342 void SetIcode(FlukaProcessCode_t l) {fIcode = l;}
829fb838 343
344 Int_t GetMreg() const {return fCurrentFlukaRegion;}
a9ea1616 345 void SetMreg(Int_t l, Int_t lttc);
829fb838 346
347 Int_t GetNewreg() const {return fNewReg;}
a9ea1616 348 void SetNewreg(Int_t l, Int_t /*lttc*/) {fNewReg = l;}
829fb838 349
350 Double_t GetRull() const {return fRull;}
351 void SetRull(Double_t r) {fRull = r;}
352
353 Double_t GetXsco() const {return fXsco;}
354 void SetXsco(Double_t x) {fXsco = x;}
355
356 Double_t GetYsco() const {return fYsco;}
357 void SetYsco(Double_t y) {fYsco = y;}
358
359 Double_t GetZsco() const {return fZsco;}
360 void SetZsco(Double_t z) {fZsco = z;}
361
362 void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
363 Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
364
365 void SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
366 Int_t GetDummyBoundary() const {return fDummyBoundary;}
367 Bool_t IsDummyBoundary() const {return (fDummyBoundary==0)?kFALSE:kTRUE;}
368
7f13be31 369 void SetGeneratePemf(Bool_t flag = kTRUE) {fGeneratePemf = flag;}
829fb838 370 Bool_t IsGeneratePemf() const {return fGeneratePemf;}
371
372 void EnableField(Bool_t flag=kTRUE) {fFieldFlag = flag;}
373 Bool_t IsFieldEnabled() const {return fFieldFlag;}
374 void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
375 void SetTrackIsExiting() {fTrackIsExiting = kTRUE; fTrackIsEntering = kFALSE;}
376 void SetTrackIsInside() {fTrackIsExiting = kFALSE; fTrackIsEntering = kFALSE;}
7cad64b7 377 void SetTrackIsNew(Bool_t flag = kTRUE);
378
6f5667d1 379 Int_t GetMaterialIndex(Int_t idmat) const {return fMaterials[idmat];}
829fb838 380 TObjArray *GetFlukaMaterials();
ece92b30 381 virtual void SetRootGeometry() {;} // Dummy
a2f1f85d 382 virtual Int_t NofVolDaughters(const char* volName) const;
383 virtual const char* VolDaughterName(const char* volName, Int_t i) const;
384 virtual Int_t VolDaughterCopyNo(const char* volName, Int_t i) const;
385 virtual const char* CurrentVolPath();
386 virtual void ForceDecayTime(Float_t){;}
b496f27c 387 private:
8e5bf079 388 void PrintHeader();
78df7be0 389 void AddParticlesToPdgDataBase() const;
f2a98602 390 //
391 // Info about primary ionization electrons
392 Int_t GetNPrimaryElectrons();
393 Double_t GetPrimaryElectronKineticEnergy(Int_t i);
394 //
829fb838 395 TFluka(const TFluka &mc): TVirtualMC(mc) {;}
396 TFluka & operator=(const TFluka &) {return (*this);}
a9ea1616 397
398
829fb838 399
400 Int_t fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
b496f27c 401 Int_t fNEvent; //Current event number
3b8c325d 402 TString fInputFileName; //Name of the real input file
403 TString fCoreInputFileName; //Name of the input file
829fb838 404
a9ea1616 405 FlukaCallerCode_t fCaller; //Parameter to indicate who is the caller of the Fluka Draw
406 FlukaProcessCode_t fIcode; //Fluka Draw procedures formal parameter
829fb838 407 Int_t fNewReg; //Fluka Draw procedures formal parameter
408 Double_t fRull; //Fluka Draw procedures formal parameter
409 Double_t fXsco; //Fluka Draw procedures formal parameter
410 Double_t fYsco; //Fluka Draw procedures formal parameter
411 Double_t fZsco; //Fluka Draw procedures formal parameter
412 Bool_t fTrackIsEntering; // Flag for track entering
413 Bool_t fTrackIsExiting; // Flag for track exiting
414 Bool_t fTrackIsNew; // Flag for new track
415 Bool_t fFieldFlag; // Flag for magnetic field
416 Bool_t fGeneratePemf; // Flag for automatic .pemf generation
417 Int_t fDummyBoundary; // Flag for crossing dummy boundaries
bd3d5c8a 418 Bool_t fStopped; // Flag for stopping
b496f27c 419 Bool_t fStopEvent; // Flag for stopped event
420 Bool_t fStopRun; // Flag for stopped run
bd3d5c8a 421
b496f27c 422 //
829fb838 423 //Geometry through TGeo
b496f27c 424 //
425 Int_t* fMaterials; //!Array of indices
829fb838 426 Int_t fNVolumes; //!Current number of volumes
7b203b6e 427 Int_t fCurrentFlukaRegion; // Index of fluka region at each step
428 Int_t fNCerenkov; // Number of cerekov photons
829fb838 429 TFlukaMCGeometry *fGeom; // TGeo-FLUKA interface
430 TGeoMCGeometry *fMCGeo; // Interface to TGeo builder
431
1df5fa54 432 // SetProcess, SetCut and user Scoring dynamic storage
fb2cbbec 433 TObjArray* fUserConfig; // List of user physics configuration
1df5fa54 434 TObjArray* fUserScore; // List of user scoring options
435
829fb838 436 ClassDef(TFluka,1) //C++ interface to Fluka montecarlo
a2f1f85d 437
438
439 // Temporary implementation of new functions
440 // To be removed with the next release
829fb838 441};
a2f1f85d 442 inline Int_t TFluka::NofVolDaughters(const char* /*volName*/) const {
443 Warning("NofVolDaughters", "New function - not yet implemented.");
444 return 0;
445 }
446
447 inline const char* TFluka::VolDaughterName(const char* /*volName*/, Int_t /*i*/) const {
448 Warning("VolDaughterName", "New function - not yet implemented.");
449 return "";
450 }
451
452 inline Int_t TFluka::VolDaughterCopyNo(const char* /*volName*/, Int_t /*i*/) const {
453 Warning("VolDaughterCopyNo", "New function - not yet implemented.");
454 return 0;
455 }
456
d59acfe7 457
829fb838 458
459#endif //TFLUKA
460