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 "TFlukaCodes.h"
21 class TFlukaMCGeometry;
24 class TFluka : public TVirtualMC {
27 TFluka(const char *title, Int_t verbosity = 0, Bool_t isRootGeometrySupported = 0);
30 virtual Bool_t IsRootGeometrySupported() const { return kTRUE;}
33 // Methods for building/management of geometry
34 // ------------------------------------------------
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);
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,
67 virtual void Gstpar(Int_t itmed, const char *param, Double_t parval);
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,
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);
94 // functions for access to geometry
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,
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);
106 // Returns the material parameters for the volume specified by
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);
113 // Returns the medium parameters for the volume specified by the
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,
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);
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);
132 // Functions for drawing
133 virtual void DrawOneSpec(const char* /*name*/)
134 {Warning("DrawOneSpec", "Not yet implemented !\n");}
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*/)
139 {Warning("Gdraw", "Not yet implemented !\n");}
142 virtual void WriteEuclid(const char*, const char*, Int_t, Int_t);
145 Int_t GetDummyRegion() const;
146 Int_t GetDummyLattice() const;
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;
152 // Methods for physics management
153 // ------------------------------------------------
156 // User configuration
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);
161 virtual TObjArray* GetListOfUserConfigs() {return fUserConfig;}
162 virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
165 // Particle table usage
166 virtual Int_t IdFromPDG(Int_t id) const;
167 virtual Int_t PDGFromId(Int_t pdg) const;
168 virtual void DefineParticles()
169 {Warning("DefineParticles", "Not yet implemented !\n");}
172 // methods for step management
173 // ------------------------------------------------
177 virtual void StopTrack();
178 virtual void ResetStoppingCondition() {fStopped = kFALSE;}
179 virtual Bool_t GetStoppingCondition() const {return fStopped;}
181 virtual void StopEvent() {fStopEvent = kTRUE;}
182 virtual void StopRun() {fStopEvent = kTRUE; fStopRun = kTRUE;}
183 virtual Bool_t EventIsStopped() const {return fStopEvent;}
184 virtual void SetStopEvent(Bool_t flag) {fStopEvent = flag;}
187 virtual void SetMaxStep (Double_t step);
188 virtual void SetMaxNStep(Int_t);
189 virtual void SetUserDecay(Int_t);
192 // Tracking volume(s)
193 virtual Int_t CurrentVolID(Int_t& copyNo) const;
194 virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const;
195 virtual const char* CurrentVolName() const;
196 virtual const char* CurrentVolOffName(Int_t off) const;
197 virtual Int_t CurrentMaterial(Float_t &a, Float_t &z,
198 Float_t &dens, Float_t &radl, Float_t &absl) const;
199 virtual Int_t CurrentEvent() const {return fNEvent;}
201 virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
203 virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
205 virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
207 virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
209 virtual Double_t MaxStep() const;
210 virtual Int_t GetMaxNStep() const
211 {Warning("GetMaxNStep", "Not yet implemented !\n"); return -1;}
212 virtual Int_t GetMedium() const;
213 virtual Int_t CurrentMedium() const {return GetMedium();}
216 // dynamic properties
217 virtual void TrackPosition(TLorentzVector& position) const;
218 virtual void TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
219 virtual void TrackMomentum(TLorentzVector& momentum) const;
220 virtual void TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const;
221 virtual Double_t TrackStep() const;
222 virtual Double_t TrackLength() const;
223 virtual Double_t TrackTime() const;
224 virtual Double_t Edep() const;
226 virtual Int_t CorrectFlukaId() const;
227 virtual Int_t TrackPid() const;
228 virtual Double_t TrackCharge() const;
229 virtual Double_t TrackMass() const;
230 virtual Double_t Etot() const;
232 virtual Bool_t IsNewTrack() const;
233 virtual Bool_t IsTrackInside() const;
234 virtual Bool_t IsTrackEntering() const;
235 virtual Bool_t IsTrackExiting() const;
236 virtual Bool_t IsTrackOut() const;
237 virtual Bool_t IsTrackDisappeared() const;
238 virtual Bool_t IsTrackStop() const;
239 virtual Bool_t IsTrackAlive() const;
242 virtual Int_t NSecondaries() const;
243 virtual void SetNCerenkov(Int_t nc) {fNCerenkov = nc;}
245 virtual void GetSecondary(Int_t isec, Int_t& particleId,
246 TLorentzVector& position, TLorentzVector& momentum);
247 virtual Bool_t SecondariesAreOrdered() const {return kFALSE;}
248 virtual TMCProcess ProdProcess(Int_t iproc) const ;
249 virtual Int_t StepProcesses(TArrayI & proc) const;
251 // Geant3 specific methods
252 // !!! need to be transformed to common interface
254 virtual void Gdopt(const char*,const char*)
255 {Warning("Gdopt", "Not yet implemented !\n");}
256 virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
257 Double_t=0,Double_t=-9999,Double_t=0)
258 {Warning("SetClipBox", "Not yet implemented !\n");}
259 virtual void DefaultRange()
260 {Warning("DefaultRange", "Not yet implemented !\n");}
261 virtual void Gdhead(Int_t, const char*, Double_t=0)
262 {Warning("Gdhead", "Not yet implemented !\n");}
263 virtual void Gdman(Double_t, Double_t, const char*)
264 {Warning("Gdman", "Not yet implemented !\n");}
265 virtual void SetColors()
266 {Warning("SetColors", "Not yet implemented !\n");}
267 virtual void Gtreve()
268 {Warning("Gtreve", "Not yet implemented !\n");}
269 virtual void GtreveRoot()
270 {Warning("GtreveRoot", "Not yet implemented !\n");}
271 virtual void Gckmat(Int_t, char*)
272 {Warning("Gckmat", "Not yet implemented !\n");}
273 virtual void InitLego()
274 {Warning("InitLego", "Not yet implemented !\n");}
276 virtual void Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife);
277 virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
278 {Warning("Gspart", "Not yet implemented !\n");}
281 // Particle Properties
282 // -------------------
284 virtual Bool_t DefineParticle(int, const char*, TMCParticleType, double, double, double) {return kFALSE;}
285 virtual Bool_t DefineIon(const char*, int, int, int, double, double) {return kFALSE;}
286 virtual TString ParticleName(int pdg) const;
287 virtual Double_t ParticleMass(int pdg) const;
288 virtual Double_t ParticleMassFPC(int fpc) const;
289 virtual Double_t ParticleCharge(int pdg) const;
290 virtual Double_t ParticleLifeTime(int pdg) const;
291 virtual TMCParticleType ParticleMCType(int) const {return (TMCParticleType) 9;}
294 // ------------------------------------------------
298 virtual void InitPhysics();
299 virtual void FinishGeometry();
300 virtual void BuildPhysics();
301 virtual void ProcessEvent();
302 virtual Bool_t ProcessRun(Int_t nevent);
306 // FLUKA Scoring specific methods
307 // ------------------------------
309 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what);
310 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what,
311 const char* det1, const char* det2, const char* det3);
313 // New Getter and Setters
314 // ------------------------------------------------
316 // - Core input file name
317 TString GetCoreInputFileName() const {return fCoreInputFileName;}
318 void SetCoreInputFileName(const char* file = "coreFlukaVmc.inp") {fCoreInputFileName = file;}
321 TString GetInputFileName() const {return fInputFileName;}
322 void SetInputFileName(const char* file = "FlukaVmc.inp") {fInputFileName = file;}
325 Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
326 void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
328 // - Fluka Draw procedures identifiers
330 // bxdraw = 11 entering
331 // bxdraw = 12 exiting
337 FlukaCallerCode_t GetCaller() const {return fCaller;}
338 void SetCaller(FlukaCallerCode_t l) {fCaller = l;}
340 FlukaProcessCode_t GetIcode() const {return fIcode;}
341 void SetIcode(FlukaProcessCode_t l) {fIcode = l;}
343 Int_t GetMreg() const {return fCurrentFlukaRegion;}
344 void SetMreg(Int_t l, Int_t lttc);
346 Int_t GetNewreg() const {return fNewReg;}
347 void SetNewreg(Int_t l, Int_t /*lttc*/) {fNewReg = l;}
349 Double_t GetRull() const {return fRull;}
350 void SetRull(Double_t r) {fRull = r;}
352 Double_t GetXsco() const {return fXsco;}
353 void SetXsco(Double_t x) {fXsco = x;}
355 Double_t GetYsco() const {return fYsco;}
356 void SetYsco(Double_t y) {fYsco = y;}
358 Double_t GetZsco() const {return fZsco;}
359 void SetZsco(Double_t z) {fZsco = z;}
361 void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
362 Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
364 void SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
365 Int_t GetDummyBoundary() const {return fDummyBoundary;}
366 Bool_t IsDummyBoundary() const {return (fDummyBoundary==0)?kFALSE:kTRUE;}
368 void SetGeneratePemf(Bool_t flag = kTRUE) {fGeneratePemf = flag;}
369 Bool_t IsGeneratePemf() const {return fGeneratePemf;}
371 void EnableField(Bool_t flag=kTRUE) {fFieldFlag = flag;}
372 Bool_t IsFieldEnabled() const {return fFieldFlag;}
373 void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
374 void SetTrackIsExiting() {fTrackIsExiting = kTRUE; fTrackIsEntering = kFALSE;}
375 void SetTrackIsInside() {fTrackIsExiting = kFALSE; fTrackIsEntering = kFALSE;}
376 void SetTrackIsNew(Bool_t flag = kTRUE);
378 Int_t GetMaterialIndex(Int_t idmat) const {return fMaterials[idmat];}
379 TObjArray *GetFlukaMaterials();
380 virtual void SetRootGeometry() {;} // Dummy
381 virtual Int_t NofVolDaughters(const char* volName) const;
382 virtual const char* VolDaughterName(const char* volName, Int_t i) const;
383 virtual Int_t VolDaughterCopyNo(const char* volName, Int_t i) const;
384 virtual const char* CurrentVolPath();
385 virtual void ForceDecayTime(Float_t){;}
388 void AddParticlesToPdgDataBase() const;
389 TFluka(const TFluka &mc): TVirtualMC(mc) {;}
390 TFluka & operator=(const TFluka &) {return (*this);}
394 Int_t fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
395 Int_t fNEvent; //Current event number
396 TString fInputFileName; //Name of the real input file
397 TString fCoreInputFileName; //Name of the input file
399 FlukaCallerCode_t fCaller; //Parameter to indicate who is the caller of the Fluka Draw
400 FlukaProcessCode_t fIcode; //Fluka Draw procedures formal parameter
401 Int_t fNewReg; //Fluka Draw procedures formal parameter
402 Double_t fRull; //Fluka Draw procedures formal parameter
403 Double_t fXsco; //Fluka Draw procedures formal parameter
404 Double_t fYsco; //Fluka Draw procedures formal parameter
405 Double_t fZsco; //Fluka Draw procedures formal parameter
406 Bool_t fTrackIsEntering; // Flag for track entering
407 Bool_t fTrackIsExiting; // Flag for track exiting
408 Bool_t fTrackIsNew; // Flag for new track
409 Bool_t fFieldFlag; // Flag for magnetic field
410 Bool_t fGeneratePemf; // Flag for automatic .pemf generation
411 Int_t fDummyBoundary; // Flag for crossing dummy boundaries
412 Bool_t fStopped; // Flag for stopping
413 Bool_t fStopEvent; // Flag for stopped event
414 Bool_t fStopRun; // Flag for stopped run
417 //Geometry through TGeo
419 Int_t* fMaterials; //!Array of indices
420 Int_t fNVolumes; //!Current number of volumes
421 Int_t fCurrentFlukaRegion; // Index of fluka region at each step
422 Int_t fNCerenkov; // Number of cerekov photons
423 TFlukaMCGeometry *fGeom; // TGeo-FLUKA interface
424 TGeoMCGeometry *fMCGeo; // Interface to TGeo builder
426 // SetProcess, SetCut and user Scoring dynamic storage
427 TObjArray* fUserConfig; // List of user physics configuration
428 TObjArray* fUserScore; // List of user scoring options
430 ClassDef(TFluka,1) //C++ interface to Fluka montecarlo
433 // Temporary implementation of new functions
434 // To be removed with the next release
436 inline Int_t TFluka::NofVolDaughters(const char* /*volName*/) const {
437 Warning("NofVolDaughters", "New function - not yet implemented.");
441 inline const char* TFluka::VolDaughterName(const char* /*volName*/, Int_t /*i*/) const {
442 Warning("VolDaughterName", "New function - not yet implemented.");
446 inline Int_t TFluka::VolDaughterCopyNo(const char* /*volName*/, Int_t /*i*/) const {
447 Warning("VolDaughterCopyNo", "New function - not yet implemented.");