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"
21 class TFlukaMCGeometry;
24 class TFluka : public TVirtualMC {
27 TFluka(const char *title, Int_t verbosity = 0, Bool_t isRootGeometrySupported = 0);
32 // Methods for building/management of geometry
33 // ------------------------------------------------
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);
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,
66 virtual void Gstpar(Int_t itmed, const char *param, Double_t parval);
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,
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);
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 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov,
98 Float_t *absco, Float_t *effic, Float_t *rindex, Float_t *rfl);
99 virtual void SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov,
100 Double_t *absco, Double_t *effic, Double_t *rindex, Double_t *rfl);
103 // Functions for drawing
104 virtual void DrawOneSpec(const char* /*name*/)
105 {printf("WARNING: DrawOneSpec not yet implemented !\n");}
106 virtual void Gsatt(const char* name, const char* att, Int_t val);
107 virtual void Gdraw(const char*,Double_t /*theta = 30*/, Double_t /*phi = 30*/,
108 Double_t /*psi = 0*/, Double_t /*u0 = 10*/, Double_t /*v0 = 10*/,
109 Double_t /*ul = 0.01*/, Double_t /*vl = 0.01*/)
110 {printf("WARNING: Gdraw not yet implemented !\n");}
113 virtual void WriteEuclid(const char*, const char*, Int_t, Int_t);
116 virtual Int_t VolId(const Text_t* volName) const;
117 virtual const char* VolName(Int_t id) const;
118 virtual Int_t NofVolumes() const {return fNVolumes;}
119 virtual Int_t VolId2Mate(Int_t id) const;
121 // Methods for physics management
122 // ------------------------------------------------
125 // User configuration
126 virtual Bool_t SetProcess(const char* flagName, Int_t flagValue);
127 virtual void SetProcess(const char* flagName, Int_t flagValue, Int_t imed);
128 virtual Bool_t SetCut(const char* cutName, Double_t cutValue);
129 virtual void SetCut(const char* cutName, Double_t cutValue, Int_t imed);
130 virtual TObjArray* GetListOfUserConfigs() {return fUserConfig;}
131 virtual Double_t Xsec(char*, Double_t, Int_t, Int_t);
134 // Particle table usage
135 virtual Int_t IdFromPDG(Int_t id) const;
136 virtual Int_t PDGFromId(Int_t pdg) const;
137 virtual void DefineParticles()
138 {printf("WARNING: DefineParticles not yet implemented !\n");}
141 // methods for step management
142 // ------------------------------------------------
146 virtual void StopTrack();
147 virtual void ResetStoppingCondition() {fStopped = kFALSE;}
148 virtual Bool_t GetStoppingCondition() const {return fStopped;}
150 virtual void StopEvent() {fStopEvent = kTRUE;}
151 virtual void StopRun() {fStopEvent = kTRUE; fStopRun = kTRUE;}
152 virtual Bool_t EventIsStopped() const {return fStopEvent;}
153 virtual void SetStopEvent(Bool_t flag) {fStopEvent = flag;}
156 virtual void SetMaxStep (Double_t step);
157 virtual void SetMaxNStep(Int_t);
158 virtual void SetUserDecay(Int_t);
161 // Tracking volume(s)
162 virtual Int_t CurrentVolID(Int_t& copyNo) const;
163 virtual Int_t CurrentVolOffID(Int_t off, Int_t& copyNo) const;
164 virtual const char* CurrentVolName() const;
165 virtual const char* CurrentVolOffName(Int_t off) const;
166 virtual Int_t CurrentMaterial(Float_t &a, Float_t &z,
167 Float_t &dens, Float_t &radl, Float_t &absl) const;
168 virtual Int_t CurrentEvent() const {return fNEvent;}
170 virtual void Gmtod(Float_t* xm, Float_t* xd, Int_t iflag);
172 virtual void Gmtod(Double_t* xm, Double_t* xd, Int_t iflag);
174 virtual void Gdtom(Float_t* xd, Float_t* xm, Int_t iflag);
176 virtual void Gdtom(Double_t* xd, Double_t* xm, Int_t iflag);
178 virtual Double_t MaxStep() const;
179 virtual Int_t GetMaxNStep() const
180 {printf("WARNING: GetMaxNStep not yet implemented !\n"); return -1;}
181 virtual Int_t GetMedium() const;
184 // dynamic properties
185 virtual void TrackPosition(TLorentzVector& position) const;
186 virtual void TrackPosition(Double_t& x, Double_t& y, Double_t& z) const;
187 virtual void TrackMomentum(TLorentzVector& momentum) const;
188 virtual void TrackMomentum(Double_t& px, Double_t& py, Double_t& pz, Double_t& e) const;
189 virtual Double_t TrackStep() const;
190 virtual Double_t TrackLength() const;
191 virtual Double_t TrackTime() const;
192 virtual Double_t Edep() const;
194 virtual Int_t TrackPid() const;
195 virtual Double_t TrackCharge() const;
196 virtual Double_t TrackMass() const;
197 virtual Double_t Etot() const;
199 virtual Bool_t IsNewTrack() const;
200 virtual Bool_t IsTrackInside() const;
201 virtual Bool_t IsTrackEntering() const;
202 virtual Bool_t IsTrackExiting() const;
203 virtual Bool_t IsTrackOut() const;
204 virtual Bool_t IsTrackDisappeared() const;
205 virtual Bool_t IsTrackStop() const;
206 virtual Bool_t IsTrackAlive() const;
209 virtual Int_t NSecondaries() const;
210 virtual void SetNCerenkov(Int_t nc) {fNCerenkov = nc;}
212 virtual void GetSecondary(Int_t isec, Int_t& particleId,
213 TLorentzVector& position, TLorentzVector& momentum);
214 virtual Bool_t SecondariesAreOrdered() const {return kFALSE;}
215 virtual TMCProcess ProdProcess(Int_t iproc) const ;
216 virtual Int_t StepProcesses(TArrayI & proc) const;
218 // Geant3 specific methods
219 // !!! need to be transformed to common interface
221 virtual void Gdopt(const char*,const char*)
222 {printf("WARNING: Gdopt not yet implemented !\n");}
223 virtual void SetClipBox(const char*,Double_t=-9999,Double_t=0, Double_t=-9999,
224 Double_t=0,Double_t=-9999,Double_t=0)
225 {printf("WARNING: SetClipBox not yet implemented !\n");}
226 virtual void DefaultRange()
227 {printf("WARNING: DefaultRange not yet implemented !\n");}
228 virtual void Gdhead(Int_t, const char*, Double_t=0)
229 {printf("WARNING: Gdhead not yet implemented !\n");}
230 virtual void Gdman(Double_t, Double_t, const char*)
231 {printf("WARNING: Gdman not yet implemented !\n");}
232 virtual void SetColors()
233 {printf("WARNING: SetColors not yet implemented !\n");}
234 virtual void Gtreve()
235 {printf("WARNING: Gtreve not yet implemented !\n");}
236 virtual void GtreveRoot()
237 {printf("WARNING: GtreveRoot not yet implemented !\n");}
238 virtual void Gckmat(Int_t, char*)
239 {printf("WARNING: Gckmat not yet implemented !\n");}
240 virtual void InitLego()
241 {printf("WARNING: InitLego not yet implemented !\n");}
243 virtual void Gfpart(Int_t pdg, char* name, Int_t& type, Float_t& mass, Float_t& charge, Float_t& tlife);
244 virtual void Gspart(Int_t, const char*, Int_t, Double_t, Double_t, Double_t)
245 {printf("WARNING: Gspart not yet implemented !\n");}
248 // Particle Properties
249 // -------------------
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;}
260 // ------------------------------------------------
264 virtual void InitPhysics();
265 virtual void FinishGeometry();
266 virtual void BuildPhysics();
267 virtual void ProcessEvent();
268 virtual Bool_t ProcessRun(Int_t nevent);
272 // FLUKA Scoring specific methods
273 // ------------------------------
275 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what);
276 virtual void SetUserScoring(const char* option, Int_t npr,char* outfile, Float_t* what,
277 const char* det1, const char* det2, const char* det3);
279 // New Getter and Setters
280 // ------------------------------------------------
282 // - Core input file name
283 TString GetCoreInputFileName() const {return fCoreInputFileName;}
284 void SetCoreInputFileName(const char* file = "coreFlukaVmc.inp") {fCoreInputFileName = file;}
287 TString GetInputFileName() const {return fInputFileName;}
288 void SetInputFileName(const char* file = "FlukaVmc.inp") {fInputFileName = file;}
291 Int_t GetVerbosityLevel() const {return fVerbosityLevel;}
292 void SetVerbosityLevel(Int_t l) {fVerbosityLevel = l;}
294 // - Fluka Draw procedures identifiers
296 // bxdraw = 11 entering
297 // bxdraw = 12 exiting
303 Int_t GetCaller() const {return fCaller;}
304 void SetCaller(Int_t l) {fCaller = l;}
306 // - Fluka Draw procedures formal parameters
307 Int_t GetIcode() const {return fIcode;}
308 void SetIcode(Int_t l) {fIcode = l;}
309 // in the case of sodraw fIcode=0
311 Int_t GetMreg() const {return fCurrentFlukaRegion;}
312 void SetMreg(Int_t l);
314 Int_t GetNewreg() const {return fNewReg;}
315 void SetNewreg(Int_t l) {fNewReg = l;}
317 Double_t GetRull() const {return fRull;}
318 void SetRull(Double_t r) {fRull = r;}
320 Double_t GetXsco() const {return fXsco;}
321 void SetXsco(Double_t x) {fXsco = x;}
323 Double_t GetYsco() const {return fYsco;}
324 void SetYsco(Double_t y) {fYsco = y;}
326 Double_t GetZsco() const {return fZsco;}
327 void SetZsco(Double_t z) {fZsco = z;}
329 void SetCurrentFlukaRegion(Int_t reg) {fCurrentFlukaRegion=reg;}
330 Int_t GetCurrentFlukaRegion() const {return fCurrentFlukaRegion;}
332 void SetDummyBoundary(Int_t mode) {fDummyBoundary = mode;}
333 Int_t GetDummyBoundary() const {return fDummyBoundary;}
334 Bool_t IsDummyBoundary() const {return (fDummyBoundary==0)?kFALSE:kTRUE;}
336 void SetGeneratePemf(Bool_t flag = kTRUE) {fGeneratePemf = flag;}
337 Bool_t IsGeneratePemf() const {return fGeneratePemf;}
339 void EnableField(Bool_t flag=kTRUE) {fFieldFlag = flag;}
340 Bool_t IsFieldEnabled() const {return fFieldFlag;}
341 void SetTrackIsEntering(){fTrackIsEntering = kTRUE; fTrackIsExiting = kFALSE;}
342 void SetTrackIsExiting() {fTrackIsExiting = kTRUE; fTrackIsEntering = kFALSE;}
343 void SetTrackIsInside() {fTrackIsExiting = kFALSE; fTrackIsEntering = kFALSE;}
344 void SetTrackIsNew(Bool_t flag = kTRUE);
346 Int_t GetMaterialIndex(Int_t idmat) const {return fMaterials[idmat];}
347 TObjArray *GetFlukaMaterials();
350 virtual void SetRootGeometry() {;}
351 virtual Int_t NofVolDaughters(const char* volName) const;
352 virtual const char* VolDaughterName(const char* volName, Int_t i) const;
353 virtual Int_t VolDaughterCopyNo(const char* volName, Int_t i) const;
354 virtual const char* CurrentVolPath();
355 virtual void ForceDecayTime(Float_t){;}
358 TFluka(const TFluka &mc): TVirtualMC(mc) {;}
359 TFluka & operator=(const TFluka &) {return (*this);}
362 Int_t fVerbosityLevel; //Verbosity level (0 lowest - 3 highest)
363 Int_t fNEvent; //Current event number
364 TString fInputFileName; //Name of the real input file
365 TString fCoreInputFileName; //Name of the input file
367 Int_t fCaller; //Parameter to indicate who is the caller of the Fluka Draw
368 Int_t fIcode; //Fluka Draw procedures formal parameter
369 Int_t fNewReg; //Fluka Draw procedures formal parameter
370 Double_t fRull; //Fluka Draw procedures formal parameter
371 Double_t fXsco; //Fluka Draw procedures formal parameter
372 Double_t fYsco; //Fluka Draw procedures formal parameter
373 Double_t fZsco; //Fluka Draw procedures formal parameter
374 Bool_t fTrackIsEntering; // Flag for track entering
375 Bool_t fTrackIsExiting; // Flag for track exiting
376 Bool_t fTrackIsNew; // Flag for new track
377 Bool_t fFieldFlag; // Flag for magnetic field
378 Bool_t fGeneratePemf; // Flag for automatic .pemf generation
379 Int_t fDummyBoundary; // Flag for crossing dummy boundaries
380 Bool_t fStopped; // Flag for stopping
381 Bool_t fStopEvent; // Flag for stopped event
382 Bool_t fStopRun; // Flag for stopped run
385 //Geometry through TGeo
387 Int_t* fMaterials; //!Array of indices
388 Int_t fNVolumes; //!Current number of volumes
389 Int_t fCurrentFlukaRegion; // Index of fluka region at each step
390 Int_t fNCerenkov; // Number of cerekov photons
391 TFlukaMCGeometry *fGeom; // TGeo-FLUKA interface
392 TGeoMCGeometry *fMCGeo; // Interface to TGeo builder
394 // SetProcess, SetCut and user Scoring dynamic storage
395 TObjArray* fUserConfig; // List of user physics configuration
396 TObjArray* fUserScore; // List of user scoring options
398 ClassDef(TFluka,1) //C++ interface to Fluka montecarlo
401 // Temporary implementation of new functions
402 // To be removed with the next release
404 inline Int_t TFluka::NofVolDaughters(const char* /*volName*/) const {
405 Warning("NofVolDaughters", "New function - not yet implemented.");
409 inline const char* TFluka::VolDaughterName(const char* /*volName*/, Int_t /*i*/) const {
410 Warning("VolDaughterName", "New function - not yet implemented.");
414 inline Int_t TFluka::VolDaughterCopyNo(const char* /*volName*/, Int_t /*i*/) const {
415 Warning("VolDaughterCopyNo", "New function - not yet implemented.");
419 inline const char* TFluka::CurrentVolPath() {
420 Warning("CurrentVolPath", "New function - not yet implemented.");