3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ///////////////////////////////////////////////////////////////////////////////
11 // FLUKA implementation of the VirtualMC Interface //
14 ///////////////////////////////////////////////////////////////////////////////
17 #include "TVirtualMC.h"
18 #include "TMCOptical.h"
19 #include "TFlukaCodes.h"
20 #include "TFlukaMCGeometry.h"
24 //class TFlukaMCGeometry;
27 class TFluka : public TVirtualMC {
30 TFluka(const char *title, Int_t verbosity = 0, Bool_t isRootGeometrySupported = 0);
33 virtual Bool_t IsRootGeometrySupported() const { return kTRUE;}
35 Int_t GetNstep() { return fGeom->GetNstep(); } // to be removed
38 // Methods for building/management of geometry
39 // ------------------------------------------------
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);
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,
72 virtual void Gstpar(Int_t itmed, const char *param, Double_t parval);
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,
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);
99 // functions for access to geometry
101 // Return the Transformation matrix between the volume specified by
102 // the path volumePath and the top or master volume.
103 virtual Bool_t GetTransformation(const TString& volumePath,
104 TGeoHMatrix& matrix);
106 // Return the name of the shape and its parameters for the volume
107 // specified by the volume name.
108 virtual Bool_t GetShape(const TString& volumePath,
109 TString& shapeType, TArrayD& par);
111 // Returns the material parameters for the volume specified by
113 virtual Bool_t GetMaterial(const TString& volumeName,
114 TString& name, Int_t& imat,
115 Double_t& a, Double_t& z, Double_t& density,
116 Double_t& radl, Double_t& inter, TArrayD& par);
118 // Returns the medium parameters for the volume specified by the
120 virtual Bool_t GetMedium(const TString& volumeName,
121 TString& name, Int_t& imed,
122 Int_t& nmat, Int_t& isvol, Int_t& ifield,
123 Double_t& fieldm, Double_t& tmaxfd, Double_t& stemax,
124 Double_t& deemax, Double_t& epsil, Double_t& stmin,
127 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
128 Float_t *absco, Float_t *effic, Float_t *rindex);
129 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
130 Double_t *absco, Double_t *effic, Double_t *rindex);
131 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
132 Float_t *absco, Float_t *effic, Float_t *rindex, Float_t *rfl);
133 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
134 Double_t *absco, Double_t *effic, Double_t *rindex, Double_t *rfl);
137 virtual void DefineOpSurface(const char* name, EMCOpSurfaceModel model, EMCOpSurfaceType surface,
138 EMCOpSurfaceFinish surfaceFinish, Double_t sigmaAlpha);
140 virtual void SetBorderSurface(const char* name, const char* vol1Name, int vol1CopyNo, const char* vol2Name, int vol2CopyNo,
141 const char* opSurfaceName);
144 virtual void SetSkinSurface(const char* name, const char* volName, const char* opSurfaceName);
146 virtual void SetMaterialProperty(Int_t itmed, const char* propertyName, Int_t np, Double_t* pp, Double_t* values);
148 virtual void SetMaterialProperty(Int_t itmed, const char* propertyName, Double_t value);
150 virtual void SetMaterialProperty(const char* surfaceName, const char* propertyName, Int_t np, Double_t* pp, Double_t* values);
152 // Functions for drawing
153 virtual void DrawOneSpec(const char* /*name*/)
154 {Warning("DrawOneSpec", "Not yet implemented !\n");}
155 virtual void Gsatt(const char* name, const char* att, Int_t val);
156 virtual void Gdraw(const char*,Double_t /*theta = 30*/, Double_t /*phi = 30*/,
157 Double_t /*psi = 0*/, Double_t /*u0 = 10*/, Double_t /*v0 = 10*/,
158 Double_t /*ul = 0.01*/, Double_t /*vl = 0.01*/)
159 {Warning("Gdraw", "Not yet implemented !\n");}
162 virtual void WriteEuclid(const char*, const char*, Int_t, Int_t);
165 Int_t GetDummyRegion() const;
166 Int_t GetDummyLattice() const;
167 virtual Int_t VolId(const Text_t* volName) const;
168 virtual const char* VolName(Int_t id) const;
169 virtual Int_t NofVolumes() const {return fNVolumes;}
170 virtual Int_t VolId2Mate(Int_t id) const;
172 // Methods for physics management
173 // ------------------------------------------------
176 // User configuration
177 virtual Bool_t SetProcess(const char* flagName, Int_t flagValue);
178 virtual void SetProcess(const char* flagName, Int_t flagValue, Int_t imed);
179 virtual Bool_t SetCut(const char* cutName, Double_t cutValue);
180 virtual void SetCut(const char* cutName, Double_t cutValue, Int_t imed);
181 virtual void SetModelParameter(const char* parName, Double_t parValue, Int_t imed);
182 virtual TObjArray* GetListOfUserConfigs() {return fUserConfig;}
183 virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
186 // Particle table usage
187 virtual Int_t IdFromPDG(Int_t id) const;
188 virtual Int_t PDGFromId(Int_t pdg) const;
189 virtual void DefineParticles()
190 {Warning("DefineParticles", "Not yet implemented !\n");}
193 // methods for step management
194 // ------------------------------------------------
198 virtual void StopTrack();
199 virtual void ResetStoppingCondition() {fStopped = kFALSE;}
200 virtual Bool_t GetStoppingCondition() const {return fStopped;}
202 virtual void StopEvent() {fStopEvent = kTRUE;}
203 virtual void StopRun() {fStopEvent = kTRUE; fStopRun = kTRUE;}
204 virtual Bool_t EventIsStopped() const {return fStopEvent;}
205 virtual void SetStopEvent(Bool_t flag) {fStopEvent = flag;}
208 virtual void SetMaxStep (Double_t step);
209 virtual void SetMaxNStep(Int_t);
210 virtual void SetUserDecay(Int_t);
213 // Tracking volume(s)
214 virtual Int_t CurrentVolID(Int_t& copyNo) const;
215 virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const;
216 virtual const char* CurrentVolName() const;
217 virtual const char* CurrentVolOffName(Int_t off) const;
218 virtual Int_t CurrentMaterial(Float_t &a, Float_t &z,
219 Float_t &dens, Float_t &radl, Float_t &absl) const;
220 virtual Int_t CurrentEvent() const {return fNEvent;}
222 virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
224 virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
226 virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
228 virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
230 virtual Double_t MaxStep() const;
231 virtual Int_t GetMaxNStep() const
232 {Warning("GetMaxNStep", "Not yet implemented !\n"); return -1;}
233 virtual Int_t GetMedium() const;
234 virtual Int_t CurrentMedium() const {return GetMedium();}
237 // dynamic properties
238 virtual void TrackPosition(TLorentzVector& position) const;
239 virtual void TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
240 virtual void TrackMomentum(TLorentzVector& momentum) const;
241 virtual void TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const;
242 virtual Double_t TrackStep() const;
243 virtual Double_t TrackLength() const;
244 virtual Double_t TrackTime() const;
245 virtual Double_t Edep() const;
247 virtual Int_t CorrectFlukaId() const;
248 virtual Int_t TrackPid() const;
249 virtual Double_t TrackCharge() const;
250 virtual Double_t TrackMass() const;
251 virtual Double_t Etot() const;
253 virtual Bool_t IsNewTrack() const;
254 virtual Bool_t IsTrackInside() const;
255 virtual Bool_t IsTrackEntering() const;
256 virtual Bool_t IsTrackExiting() const;
257 virtual Bool_t IsTrackOut() const;
258 virtual Bool_t IsTrackDisappeared() const;
259 virtual Bool_t IsTrackStop() const;
260 virtual Bool_t IsTrackAlive() const;
263 virtual Int_t NSecondaries() const;
264 virtual void SetNCerenkov(Int_t nc) {fNCerenkov = nc;}
266 virtual void GetSecondary(Int_t isec, Int_t& particleId,
267 TLorentzVector& position, TLorentzVector& momentum);
268 virtual Bool_t SecondariesAreOrdered() const {return kFALSE;}
269 virtual TMCProcess ProdProcess(Int_t iproc) const ;
270 virtual Int_t StepProcesses(TArrayI & proc) const;
272 // Geant3 specific methods
273 // !!! need to be transformed to common interface
275 virtual void Gdopt(const char*,const char*)
276 {Warning("Gdopt", "Not yet implemented !\n");}
277 virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
278 Double_t=0,Double_t=-9999,Double_t=0)
279 {Warning("SetClipBox", "Not yet implemented !\n");}
280 virtual void DefaultRange()
281 {Warning("DefaultRange", "Not yet implemented !\n");}
282 virtual void Gdhead(Int_t, const char*, Double_t=0)
283 {Warning("Gdhead", "Not yet implemented !\n");}
284 virtual void Gdman(Double_t, Double_t, const char*)
285 {Warning("Gdman", "Not yet implemented !\n");}
286 virtual void SetColors()
287 {Warning("SetColors", "Not yet implemented !\n");}
288 virtual void Gtreve()
289 {Warning("Gtreve", "Not yet implemented !\n");}
290 virtual void GtreveRoot()
291 {Warning("GtreveRoot", "Not yet implemented !\n");}
292 virtual void Gckmat(Int_t, char*)
293 {Warning("Gckmat", "Not yet implemented !\n");}
294 virtual void InitLego()
295 {Warning("InitLego", "Not yet implemented !\n");}
297 virtual void Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife);
298 virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
299 {Warning("Gspart", "Not yet implemented !\n");}
302 // Particle Properties
303 // -------------------
305 virtual Bool_t DefineParticle(int, const char*, TMCParticleType, double, double, double) {return kFALSE;}
306 virtual Bool_t DefineIon(const char*, int, int, int, double, double) {return kFALSE;}
307 virtual TString ParticleName(int pdg) const;
308 virtual Double_t ParticleMass(int pdg) const;
309 virtual Double_t ParticleMassFPC(int fpc) const;
310 virtual Double_t ParticleCharge(int pdg) const;
311 virtual Double_t ParticleLifeTime(int pdg) const;
312 virtual TMCParticleType ParticleMCType(int) const {return (TMCParticleType) 9;}
315 // ------------------------------------------------
319 virtual void InitPhysics();
320 virtual void FinishGeometry();
321 virtual void BuildPhysics();
322 virtual void ProcessEvent();
323 virtual Bool_t ProcessRun(Int_t nevent);
327 // FLUKA Scoring specific methods
328 // ------------------------------
330 virtual void SetUserScoring(const char* option, const char* sdum, Int_t npr,char* outfile, Float_t* what);
331 virtual void SetUserScoring(const char* option, const char* sdum, Int_t npr,char* outfile, Float_t* what,
332 const char* det1, const char* det2, const char* det3);
334 // New Getter and Setters
335 // ------------------------------------------------
337 // - Core input file name
338 TString GetCoreInputFileName() const {return fCoreInputFileName;}
339 void SetCoreInputFileName(const char* file = "coreFlukaVmc.inp") {fCoreInputFileName = file;}
342 TString GetInputFileName() const {return fInputFileName;}
343 void SetInputFileName(const char* file = "FlukaVmc.inp") {fInputFileName = file;}
346 Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
347 void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
350 // - Fluka Draw procedures identifiers, see TFlukaCodes.h
352 FlukaCallerCode_t GetCaller() const {return fCaller;}
353 FlukaProcessCode_t GetIcode() const {return fIcode;}
354 Int_t GetMreg() const {return fCurrentFlukaRegion;}
355 Int_t GetNewreg() const {return fNewReg;}
356 Double_t GetRull() const {return fRull;}
357 Double_t GetXsco() const {return fXsco;}
358 Double_t GetYsco() const {return fYsco;}
359 Double_t GetZsco() const {return fZsco;}
360 Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
361 // - Fluka Draw Setters
362 void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
363 void SetCaller(FlukaCallerCode_t l) {fCaller = l;}
364 void SetIcode(FlukaProcessCode_t l) {fIcode = l;}
365 void SetMreg(Int_t l, Int_t lttc);
366 void SetNewreg(Int_t l, Int_t /*lttc*/) {fNewReg = l;}
367 void SetRull(Double_t r) {fRull = r;}
368 void SetXsco(Double_t x) {fXsco = x;}
369 void SetYsco(Double_t y) {fYsco = y;}
370 void SetZsco(Double_t z) {fZsco = z;}
372 void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
373 void SetTrackIsExiting() {fTrackIsExiting = kTRUE; fTrackIsEntering = kFALSE;}
374 void SetTrackIsInside() {fTrackIsExiting = kFALSE; fTrackIsEntering = kFALSE;}
375 void SetTrackIsNew(Bool_t flag = kTRUE);
377 void SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
378 Int_t GetDummyBoundary() const {return fDummyBoundary;}
379 Bool_t IsDummyBoundary() const {return (fDummyBoundary==0)?kFALSE:kTRUE;}
382 void SetGeneratePemf(Bool_t flag = kTRUE) {fGeneratePemf = flag;}
383 Bool_t IsGeneratePemf() const {return fGeneratePemf;}
385 void EnableField(Bool_t flag=kTRUE) {fFieldFlag = flag;}
386 Bool_t IsFieldEnabled() const {return fFieldFlag;}
388 Int_t GetMaterialIndex(Int_t idmat) const {return fMaterials[idmat];}
390 TObjArray * GetFlukaMaterials();
391 virtual void SetRootGeometry() {;} // Dummy
392 virtual Int_t NofVolDaughters(const char* volName) const;
393 virtual const char* VolDaughterName(const char* volName, Int_t i) const;
394 virtual Int_t VolDaughterCopyNo(const char* volName, Int_t i) const;
395 virtual const char* CurrentVolPath();
396 virtual void ForceDecayTime(Float_t){;}
398 // Info about primary ionization electrons
399 Int_t GetNPrimaryElectrons();
400 Double_t GetPrimaryElectronKineticEnergy(Int_t i) const;
401 void GetPrimaryElectronPosition(Int_t i, Double_t& x, Double_t& y, Double_t& z) const;
402 void SetCurrentPrimaryElectronIndex(Int_t i) {fPrimaryElectronIndex = i;}
406 // Copy constructor and operator= declared but not implemented (-Weff++ flag)
407 TFluka(const TFluka &mc); //: TVirtualMC(mc) {;}
408 TFluka & operator=(const TFluka &); // {return (*this);}
411 void AddParticlesToPdgDataBase() const;
414 Int_t fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
415 Int_t fNEvent; //Current event number
416 TString fInputFileName; //Name of the real input file
417 TString fCoreInputFileName; //Name of the input file
419 FlukaCallerCode_t fCaller; // Parameter to indicate who is the caller of the Fluka Draw
420 FlukaProcessCode_t fIcode; // Fluka Draw procedures formal parameter
421 Int_t fNewReg; // Fluka Draw procedures formal parameter
422 Double_t fRull; // Fluka Draw procedures formal parameter
423 Double_t fXsco; // Fluka Draw procedures formal parameter
424 Double_t fYsco; // Fluka Draw procedures formal parameter
425 Double_t fZsco; // Fluka Draw procedures formal parameter
426 Bool_t fTrackIsEntering; // Flag for track entering
427 Bool_t fTrackIsExiting; // Flag for track exiting
428 Bool_t fTrackIsNew; // Flag for new track
429 Bool_t fFieldFlag; // Flag for magnetic field
430 Bool_t fGeneratePemf; // Flag for automatic .pemf generation
431 Int_t fDummyBoundary; // Flag for crossing dummy boundaries
432 Bool_t fStopped; // Flag for stopping
433 Bool_t fStopEvent; // Flag for stopped event
434 Bool_t fStopRun; // Flag for stopped run
435 Int_t fPrimaryElectronIndex; // Primary electron Index
438 //Geometry through TGeo
440 Int_t* fMaterials; //!Array of indices
441 Int_t fNVolumes; //!Current number of volumes
442 Int_t fCurrentFlukaRegion; // Index of fluka region at each step
443 Int_t fNCerenkov; // Number of cerekov photons
444 TFlukaMCGeometry *fGeom; // TGeo-FLUKA interface
445 TGeoMCGeometry *fMCGeo; // Interface to TGeo builder
447 // SetProcess, SetCut and user Scoring dynamic storage
448 TObjArray* fUserConfig; // List of user physics configuration
449 TObjArray* fUserScore; // List of user scoring options
452 ClassDef(TFluka,1) //C++ interface to Fluka montecarlo
455 // Temporary implementation of new functions
456 // To be removed with the next release
458 inline Int_t TFluka::NofVolDaughters(const char* /*volName*/) const {
459 Warning("NofVolDaughters", "New function - not yet implemented.");
463 inline const char* TFluka::VolDaughterName(const char* /*volName*/, Int_t /*i*/) const {
464 Warning("VolDaughterName", "New function - not yet implemented.");
468 inline Int_t TFluka::VolDaughterCopyNo(const char* /*volName*/, Int_t /*i*/) const {
469 Warning("VolDaughterCopyNo", "New function - not yet implemented.");
474 inline void TFluka::DefineOpSurface(const char* /*name*/, EMCOpSurfaceModel /*model*/, EMCOpSurfaceType /*surface*/,
475 EMCOpSurfaceFinish /*surfaceFinish*/, Double_t /*sigmaAlpha*/)
477 Warning("DefineOpSurface", "New function - not yet implemented.");
481 inline void TFluka::SetBorderSurface(const char* /*name*/, const char* /*vol1Name*/, int /*vol1CopyNo*/, const char* /*vol2Name*/,
482 int /*vol2CopyNo*/, const char* /*opSurfaceName*/)
484 Warning("SetBorderSurface", "New function - not yet implemented.");
488 inline void TFluka::SetSkinSurface(const char* /*name*/, const char* /*volName*/, const char* /*opSurfaceName*/)
490 Warning("SetSkinSurface", "New function - not yet implemented.");
494 inline void TFluka::SetMaterialProperty(Int_t /*itmed*/, const char* /*propertyName*/, Int_t /*np*/, Double_t* /*pp*/, Double_t* /*values*/)
496 Warning("SetMaterialProperty", "New function - not yet implemented.");
500 inline void TFluka::SetMaterialProperty(Int_t /*itmed*/, const char* /*propertyName*/, Double_t /*value*/)
502 Warning("SetMaterialProperty", "New function - not yet implemented.");
506 inline void TFluka::SetMaterialProperty(const char* /*surfaceName*/, const char* /*propertyName*/, Int_t /*np*/,
507 Double_t* /*pp*/, Double_t* /*values*/)
509 Warning("SetMaterialProperty", "New function - not yet implemented.");