Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TVirtualMC.h
Go to the documentation of this file.
1 // @(#)root/vmc:$Name: $:$Id$
2 // Authors: Ivana Hrivnacova, Rene Brun, Federico Carminati 13/04/2002
3 
4 /*************************************************************************
5  * Copyright (C) 2006, Rene Brun and Fons Rademakers. *
6  * Copyright (C) 2002, ALICE Experiment at CERN. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 #ifndef ROOT_TVirtualMC
14 #define ROOT_TVirtualMC
15 
16 ///////////////////////////////////////////////////////////////////////////////
17 // //
18 // //
19 // Abstract Monte Carlo interface //
20 // //
21 // //
22 ///////////////////////////////////////////////////////////////////////////////
23 
24 #include "TMCProcess.h"
25 #include "TMCParticleType.h"
26 #include "TMCOptical.h"
27 #include "TMCtls.h"
28 #include "TVirtualMCApplication.h"
29 #include "TVirtualMCStack.h"
30 #include "TMCManagerStack.h"
31 #include "TVirtualMCDecayer.h"
32 #include "TVirtualMagField.h"
33 #include "TRandom.h"
34 #include "TString.h"
35 
36 class TLorentzVector;
37 class TGeoHMatrix;
38 class TArrayI;
39 class TArrayD;
40 class TVirtualMCSensitiveDetector;
41 
42 class TVirtualMC : public TNamed {
43 
44  // To have access to private methods
45  friend class TMCManager;
46 
47 public:
48  /// Standard constructor
49  ///
50  /// isRootGeometrySupported = True if implementation of TVirtualMC
51  /// supports geometry defined with TGeo
52  TVirtualMC(const char *name, const char *title, Bool_t isRootGeometrySupported = kFALSE);
53 
54  /// Default constructor
55  TVirtualMC();
56 
57  /// Destructor
58  virtual ~TVirtualMC();
59 
60  /// Static access method
61  static TVirtualMC *GetMC();
62 
63  //
64  // ------------------------------------------------
65  // methods for building/management of geometry
66  // ------------------------------------------------
67  //
68 
69  /// Info about supporting geometry defined via Root
70  virtual Bool_t IsRootGeometrySupported() const = 0;
71 
72  //
73  // functions from GCONS
74  // ------------------------------------------------
75  //
76 
77  /// Define a material
78  /// - kmat number assigned to the material
79  /// - name material name
80  /// - a atomic mass in au
81  /// - z atomic number
82  /// - dens density in g/cm3
83  /// - absl absorption length in cm;
84  /// if >=0 it is ignored and the program
85  /// calculates it, if <0. -absl is taken
86  /// - radl radiation length in cm
87  /// if >=0 it is ignored and the program
88  /// calculates it, if <0. -radl is taken
89  /// - buf pointer to an array of user words
90  /// - nwbuf number of user words
91  virtual void Material(Int_t &kmat, const char *name, Double_t a, Double_t z, Double_t dens, Double_t radl,
92  Double_t absl, Float_t *buf, Int_t nwbuf) = 0;
93 
94  /// The same as previous but in double precision
95  virtual void Material(Int_t &kmat, const char *name, Double_t a, Double_t z, Double_t dens, Double_t radl,
96  Double_t absl, Double_t *buf, Int_t nwbuf) = 0;
97 
98  /// Define a mixture or a compound
99  /// with a number kmat composed by the basic nlmat materials defined
100  /// by arrays a, z and wmat
101  ///
102  /// If nlmat > 0 then wmat contains the proportion by
103  /// weights of each basic material in the mixture.
104  ///
105  /// If nlmat < 0 then wmat contains the number of atoms
106  /// of a given kind into the molecule of the compound.
107  /// In this case, wmat in output is changed to relative
108  /// weights.
109  virtual void
110  Mixture(Int_t &kmat, const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat) = 0;
111 
112  /// The same as previous but in double precision
113  virtual void
114  Mixture(Int_t &kmat, const char *name, Double_t *a, Double_t *z, Double_t dens, Int_t nlmat, Double_t *wmat) = 0;
115 
116  /// Define a medium.
117  /// - kmed tracking medium number assigned
118  /// - name tracking medium name
119  /// - nmat material number
120  /// - isvol sensitive volume flag
121  /// - ifield magnetic field:
122  /// - ifield = 0 if no magnetic field;
123  /// - ifield = -1 if user decision in guswim;
124  /// - ifield = 1 if tracking performed with g3rkuta;
125  /// - ifield = 2 if tracking performed with g3helix;
126  /// - ifield = 3 if tracking performed with g3helx3.
127  /// - fieldm max. field value (kilogauss)
128  /// - tmaxfd max. angle due to field (deg/step)
129  /// - stemax max. step allowed
130  /// - deemax max. fraction of energy lost in a step
131  /// - epsil tracking precision (cm)
132  /// - stmin min. step due to continuous processes (cm)
133  /// - ubuf pointer to an array of user words
134  /// - nbuf number of user words
135  virtual void Medium(Int_t &kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
136  Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin, Float_t *ubuf,
137  Int_t nbuf) = 0;
138 
139  /// The same as previous but in double precision
140  virtual void Medium(Int_t &kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
141  Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin,
142  Double_t *ubuf, Int_t nbuf) = 0;
143 
144  /// Define a rotation matrix
145  /// - krot rotation matrix number assigned
146  /// - thetaX polar angle for axis X
147  /// - phiX azimuthal angle for axis X
148  /// - thetaY polar angle for axis Y
149  /// - phiY azimuthal angle for axis Y
150  /// - thetaZ polar angle for axis Z
151  /// - phiZ azimuthal angle for axis Z
152  virtual void Matrix(Int_t &krot, Double_t thetaX, Double_t phiX, Double_t thetaY, Double_t phiY, Double_t thetaZ,
153  Double_t phiZ) = 0;
154 
155  /// Change the value of cut or mechanism param
156  /// to a new value parval for tracking medium itmed.
157  /// In Geant3, the data structure JTMED contains the standard tracking
158  /// parameters (CUTS and flags to control the physics processes) which
159  /// are used by default for all tracking media.
160  /// It is possible to redefine individually with this function any of these
161  /// parameters for a given tracking medium.
162  /// - itmed tracking medium number
163  /// - param is a character string (variable name)
164  /// - parval must be given as a floating point.
165  virtual void Gstpar(Int_t itmed, const char *param, Double_t parval) = 0;
166 
167  //
168  // functions from GGEOM
169  // ------------------------------------------------
170  //
171 
172  /// Create a new volume
173  /// - name Volume name
174  /// - shape Volume type
175  /// - nmed Tracking medium number
176  /// - np Number of shape parameters
177  /// - upar Vector containing shape parameters
178  virtual Int_t Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t np) = 0;
179 
180  /// The same as previous but in double precision
181  virtual Int_t Gsvolu(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t np) = 0;
182 
183  /// Create a new volume by dividing an existing one.
184  /// It divides a previously defined volume
185  /// - name Volume name
186  /// - mother Mother volume name
187  /// - ndiv Number of divisions
188  /// - iaxis Axis value:
189  /// X,Y,Z of CAXIS will be translated to 1,2,3 for IAXIS.
190  virtual void Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis) = 0;
191 
192  /// Create a new volume by dividing an existing one.
193  /// Divide mother into ndiv divisions called name
194  /// along axis iaxis starting at coordinate value c0i.
195  /// The new volume created will be medium number numed.
196  virtual void Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed) = 0;
197 
198  /// Create a new volume by dividing an existing one
199  /// Divide mother into divisions called name along
200  /// axis iaxis in steps of step. If not exactly divisible
201  /// will make as many as possible and will center them
202  /// with respect to the mother. Divisions will have medium
203  /// number numed. If numed is 0, numed of mother is taken.
204  /// ndvmx is the expected maximum number of divisions
205  /// (If 0, no protection tests are performed in Geant3)
206  virtual void Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx) = 0;
207 
208  /// Create a new volume by dividing an existing one
209  /// Divides mother into divisions called name along
210  /// axis iaxis starting at coordinate value c0 with step
211  /// size step.
212  /// The new volume created will have medium number numed.
213  /// If numed is 0, numed of mother is taken.
214  /// ndvmx is the expected maximum number of divisions
215  /// (If 0, no protection tests are performed in Geant3)
216  virtual void
217  Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx) = 0;
218 
219  /// Flag volume name whose contents will have to be ordered
220  /// along axis iax, by setting the search flag to -iax
221  /// (Geant3 only)
222  virtual void Gsord(const char *name, Int_t iax) = 0;
223 
224  /// Position a volume into an existing one.
225  /// It positions a previously defined volume in the mother.
226  /// - name Volume name
227  /// - nr Copy number of the volume
228  /// - mother Mother volume name
229  /// - x X coord. of the volume in mother ref. sys.
230  /// - y Y coord. of the volume in mother ref. sys.
231  /// - z Z coord. of the volume in mother ref. sys.
232  /// - irot Rotation matrix number w.r.t. mother ref. sys.
233  /// - konly ONLY/MANY flag
234  virtual void Gspos(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
235  const char *konly = "ONLY") = 0;
236 
237  /// Place a copy of generic volume name with user number
238  /// nr inside mother, with its parameters upar(1..np)
239  virtual void Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
240  const char *konly, Float_t *upar, Int_t np) = 0;
241 
242  /// The same as previous but in double precision
243  virtual void Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
244  const char *konly, Double_t *upar, Int_t np) = 0;
245 
246  /// Helper function for resolving MANY.
247  /// Specify the ONLY volume that overlaps with the
248  /// specified MANY and has to be substracted.
249  /// (Geant4 only)
250  virtual void Gsbool(const char *onlyVolName, const char *manyVolName) = 0;
251 
252  /// Define the tables for UV photon tracking in medium itmed.
253  /// Please note that it is the user's responsibility to
254  /// provide all the coefficients:
255  /// - itmed Tracking medium number
256  /// - npckov Number of bins of each table
257  /// - ppckov Value of photon momentum (in GeV)
258  /// - absco Absorption coefficients
259  /// - dielectric: absorption length in cm
260  /// - metals : absorption fraction (0<=x<=1)
261  /// - effic Detection efficiency for UV photons
262  /// - rindex Refraction index (if=0 metal)
263  virtual void
264  SetCerenkov(Int_t itmed, Int_t npckov, Float_t *ppckov, Float_t *absco, Float_t *effic, Float_t *rindex) = 0;
265 
266  /// The same as previous but in double precision
267  virtual void
268  SetCerenkov(Int_t itmed, Int_t npckov, Double_t *ppckov, Double_t *absco, Double_t *effic, Double_t *rindex) = 0;
269 
270  //
271  // functions for definition of surfaces
272  // and material properties for optical physics
273  // ------------------------------------------------
274  //
275 
276  /// Define the optical surface
277  /// - name surface name
278  /// - model selection of model (see #EMCOpSurfaceModel values)
279  /// - surfaceType surface type (see #EMCOpSurfaceType values)
280  /// - surfaceFinish surface quality (see #EMCOpSurfaceType values)
281  /// - sigmaAlpha an unified model surface parameter
282  /// (Geant4 only)
283  virtual void DefineOpSurface(const char *name, EMCOpSurfaceModel model, EMCOpSurfaceType surfaceType,
284  EMCOpSurfaceFinish surfaceFinish, Double_t sigmaAlpha) = 0;
285 
286  /// Define the optical surface border
287  /// - name border surface name
288  /// - vol1Name first volume name
289  /// - vol1CopyNo first volume copy number
290  /// - vol2Name second volume name
291  /// - vol2CopyNo second volume copy number
292  /// - opSurfaceName name of optical surface which this border belongs to
293  /// (Geant4 only)
294  virtual void SetBorderSurface(const char *name, const char *vol1Name, int vol1CopyNo, const char *vol2Name,
295  int vol2CopyNo, const char *opSurfaceName) = 0;
296 
297  /// Define the optical skin surface
298  /// - name skin surface name
299  /// - volName volume name
300  /// - opSurfaceName name of optical surface which this border belongs to
301  /// (Geant4 only)
302  virtual void SetSkinSurface(const char *name, const char *volName, const char *opSurfaceName) = 0;
303 
304  /// Define material property via a table of values
305  /// - itmed tracking medium id
306  /// - propertyName property name
307  /// - np number of bins of the table
308  /// - pp value of photon momentum (in GeV)
309  /// - values property values
310  /// (Geant4 only)
311  virtual void
312  SetMaterialProperty(Int_t itmed, const char *propertyName, Int_t np, Double_t *pp, Double_t *values) = 0;
313 
314  /// Define material property via a value
315  /// - itmed tracking medium id
316  /// - propertyName property name
317  /// - value property value
318  /// (Geant4 only)
319  virtual void SetMaterialProperty(Int_t itmed, const char *propertyName, Double_t value) = 0;
320 
321  /// Define optical surface property via a table of values
322  /// - surfaceName optical surface name
323  /// - propertyName property name
324  /// - np number of bins of the table
325  /// - pp value of photon momentum (in GeV)
326  /// - values property values
327  /// (Geant4 only)
328  virtual void
329  SetMaterialProperty(const char *surfaceName, const char *propertyName, Int_t np, Double_t *pp, Double_t *values) = 0;
330 
331  //
332  // functions for access to geometry
333  // ------------------------------------------------
334  //
335 
336  /// Return the transformation matrix between the volume specified by
337  /// the path volumePath and the top or master volume.
338  virtual Bool_t GetTransformation(const TString &volumePath, TGeoHMatrix &matrix) = 0;
339 
340  /// Return the name of the shape (shapeType) and its parameters par
341  /// for the volume specified by the path volumePath .
342  virtual Bool_t GetShape(const TString &volumePath, TString &shapeType, TArrayD &par) = 0;
343 
344  /// Return the material parameters for the material specified by
345  /// the material Id
346  virtual Bool_t GetMaterial(Int_t imat, TString &name, Double_t &a, Double_t &z, Double_t &density, Double_t &radl,
347  Double_t &inter, TArrayD &par) = 0;
348 
349  /// Return the material parameters for the volume specified by
350  /// the volumeName.
351  virtual Bool_t GetMaterial(const TString &volumeName, TString &name, Int_t &imat, Double_t &a, Double_t &z,
352  Double_t &density, Double_t &radl, Double_t &inter, TArrayD &par) = 0;
353 
354  /// Return the medium parameters for the volume specified by the
355  /// volumeName.
356  virtual Bool_t GetMedium(const TString &volumeName, TString &name, Int_t &imed, Int_t &nmat, Int_t &isvol,
357  Int_t &ifield, Double_t &fieldm, Double_t &tmaxfd, Double_t &stemax, Double_t &deemax,
358  Double_t &epsil, Double_t &stmin, TArrayD &par) = 0;
359 
360  /// Write out the geometry of the detector in EUCLID file format
361  /// - filnam file name - will be with the extension .euc *
362  /// - topvol volume name of the starting node
363  /// - number copy number of topvol (relevant for gsposp)
364  /// - nlevel number of levels in the tree structure
365  /// to be written out, starting from topvol
366  /// (Geant3 only)
367  /// Deprecated
368  virtual void WriteEuclid(const char *filnam, const char *topvol, Int_t number, Int_t nlevel) = 0;
369 
370  /// Set geometry from Root (built via TGeo)
371  virtual void SetRootGeometry() = 0;
372 
373  /// Activate the parameters defined in tracking media
374  /// (DEEMAX, STMIN, STEMAX), which are, be default, ignored.
375  /// In Geant4 case, only STEMAX is taken into account.
376  /// In FLUKA, all tracking media parameters are ignored.
377  virtual void SetUserParameters(Bool_t isUserParameters) = 0;
378 
379  //
380  // get methods
381  // ------------------------------------------------
382  //
383 
384  /// Return the unique numeric identifier for volume name volName
385  virtual Int_t VolId(const char *volName) const = 0;
386 
387  /// Return the volume name for a given volume identifier id
388  virtual const char *VolName(Int_t id) const = 0;
389 
390  /// Return the unique numeric identifier for medium name mediumName
391  virtual Int_t MediumId(const char *mediumName) const = 0;
392 
393  /// Return total number of volumes in the geometry
394  virtual Int_t NofVolumes() const = 0;
395 
396  /// Return material number for a given volume id
397  virtual Int_t VolId2Mate(Int_t id) const = 0;
398 
399  /// Return number of daughters of the volume specified by volName
400  virtual Int_t NofVolDaughters(const char *volName) const = 0;
401 
402  /// Return the name of i-th daughter of the volume specified by volName
403  virtual const char *VolDaughterName(const char *volName, Int_t i) const = 0;
404 
405  /// Return the copyNo of i-th daughter of the volume specified by volName
406  virtual Int_t VolDaughterCopyNo(const char *volName, Int_t i) const = 0;
407 
408  //
409  // ------------------------------------------------
410  // methods for sensitive detectors
411  // ------------------------------------------------
412  //
413 
414  /// Set a sensitive detector to a volume
415  /// - volName - the volume name
416  /// - sd - the user sensitive detector
417  virtual void SetSensitiveDetector(const TString &volName, TVirtualMCSensitiveDetector *sd);
418 
419  /// Get a sensitive detector of a volume
420  /// - volName - the volume name
421  virtual TVirtualMCSensitiveDetector *GetSensitiveDetector(const TString &volName) const;
422 
423  /// The scoring option:
424  /// if true, scoring is performed only via user defined sensitive detectors and
425  /// MCApplication::Stepping is not called
426  virtual void SetExclusiveSDScoring(Bool_t exclusiveSDScoring);
427 
428  //
429  // ------------------------------------------------
430  // methods for physics management
431  // ------------------------------------------------
432  //
433 
434  //
435  // set methods
436  // ------------------------------------------------
437  //
438 
439  /// Set transport cuts for particles
440  virtual Bool_t SetCut(const char *cutName, Double_t cutValue) = 0;
441 
442  /// Set process control
443  virtual Bool_t SetProcess(const char *flagName, Int_t flagValue) = 0;
444 
445  /// Set a user defined particle
446  /// Function is ignored if particle with specified pdg
447  /// already exists and error report is printed.
448  /// - pdg PDG encoding
449  /// - name particle name
450  /// - mcType VMC Particle type
451  /// - mass mass [GeV]
452  /// - charge charge [eplus]
453  /// - lifetime time of life [s]
454  /// - pType particle type as in Geant4
455  /// - width width [GeV]
456  /// - iSpin spin
457  /// - iParity parity
458  /// - iConjugation conjugation
459  /// - iIsospin isospin
460  /// - iIsospinZ isospin - #rd component
461  /// - gParity gParity
462  /// - lepton lepton number
463  /// - baryon baryon number
464  /// - stable stability
465  /// - shortlived is shorlived?
466  /// - subType particle subType as in Geant4
467  /// - antiEncoding anti encoding
468  /// - magMoment magnetic moment
469  /// - excitation excitation energy [GeV]
470  virtual Bool_t DefineParticle(Int_t pdg, const char *name, TMCParticleType mcType, Double_t mass, Double_t charge,
471  Double_t lifetime) = 0;
472 
473  /// Set a user defined particle
474  /// Function is ignored if particle with specified pdg
475  /// already exists and error report is printed.
476  /// - pdg PDG encoding
477  /// - name particle name
478  /// - mcType VMC Particle type
479  /// - mass mass [GeV]
480  /// - charge charge [eplus]
481  /// - lifetime time of life [s]
482  /// - pType particle type as in Geant4
483  /// - width width [GeV]
484  /// - iSpin spin
485  /// - iParity parity
486  /// - iConjugation conjugation
487  /// - iIsospin isospin
488  /// - iIsospinZ isospin - #rd component
489  /// - gParity gParity
490  /// - lepton lepton number
491  /// - baryon baryon number
492  /// - stable stability
493  /// - shortlived is shorlived?
494  /// - subType particle subType as in Geant4
495  /// - antiEncoding anti encoding
496  /// - magMoment magnetic moment
497  /// - excitation excitation energy [GeV]
498  virtual Bool_t DefineParticle(Int_t pdg, const char *name, TMCParticleType mcType, Double_t mass, Double_t charge,
499  Double_t lifetime, const TString &pType, Double_t width, Int_t iSpin, Int_t iParity,
500  Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity, Int_t lepton,
501  Int_t baryon, Bool_t stable, Bool_t shortlived = kFALSE, const TString &subType = "",
502  Int_t antiEncoding = 0, Double_t magMoment = 0.0, Double_t excitation = 0.0) = 0;
503 
504  /// Set a user defined ion.
505  /// - name ion name
506  /// - Z atomic number
507  /// - A atomic mass
508  /// - Q charge [eplus}
509  /// - excitation excitation energy [GeV]
510  /// - mass mass [GeV] (if not specified by user, approximative
511  /// mass is calculated)
512  virtual Bool_t DefineIon(const char *name, Int_t Z, Int_t A, Int_t Q, Double_t excEnergy, Double_t mass = 0.) = 0;
513 
514  /// Set a user phase space decay for a particle
515  /// - pdg particle PDG encoding
516  /// - bratios the array with branching ratios (in %)
517  /// - mode[6][3] the array with daughters particles PDG codes for each
518  /// decay channel
519  virtual Bool_t SetDecayMode(Int_t pdg, Float_t bratio[6], Int_t mode[6][3]) = 0;
520 
521  /// Calculate X-sections
522  /// (Geant3 only)
523  /// Deprecated
524  virtual Double_t Xsec(char *, Double_t, Int_t, Int_t) = 0;
525 
526  //
527  // particle table usage
528  // ------------------------------------------------
529  //
530 
531  /// Return MC specific code from a PDG and pseudo ENDF code (pdg)
532  virtual Int_t IdFromPDG(Int_t pdg) const = 0;
533 
534  /// Return PDG code and pseudo ENDF code from MC specific code (id)
535  virtual Int_t PDGFromId(Int_t id) const = 0;
536 
537  //
538  // get methods
539  // ------------------------------------------------
540  //
541 
542  /// Return name of the particle specified by pdg.
543  virtual TString ParticleName(Int_t pdg) const = 0;
544 
545  /// Return mass of the particle specified by pdg.
546  virtual Double_t ParticleMass(Int_t pdg) const = 0;
547 
548  /// Return charge (in e units) of the particle specified by pdg.
549  virtual Double_t ParticleCharge(Int_t pdg) const = 0;
550 
551  /// Return life time of the particle specified by pdg.
552  virtual Double_t ParticleLifeTime(Int_t pdg) const = 0;
553 
554  /// Return VMC type of the particle specified by pdg.
555  virtual TMCParticleType ParticleMCType(Int_t pdg) const = 0;
556  //
557  // ------------------------------------------------
558  // methods for step management
559  // ------------------------------------------------
560  //
561 
562  //
563  // action methods
564  // ------------------------------------------------
565  //
566 
567  /// Stop the transport of the current particle and skip to the next
568  virtual void StopTrack() = 0;
569 
570  /// Stop simulation of the current event and skip to the next
571  virtual void StopEvent() = 0;
572 
573  /// Stop simulation of the current event and set the abort run flag to true
574  virtual void StopRun() = 0;
575 
576  //
577  // set methods
578  // ------------------------------------------------
579  //
580 
581  /// Set the maximum step allowed till the particle is in the current medium
582  virtual void SetMaxStep(Double_t) = 0;
583 
584  /// Set the maximum number of steps till the particle is in the current medium
585  virtual void SetMaxNStep(Int_t) = 0;
586 
587  /// Force the decays of particles to be done with Pythia
588  /// and not with the Geant routines.
589  virtual void SetUserDecay(Int_t pdg) = 0;
590 
591  /// Force the decay time of the current particle
592  virtual void ForceDecayTime(Float_t) = 0;
593 
594  //
595  // tracking volume(s)
596  // ------------------------------------------------
597  //
598 
599  /// Return the current volume ID and copy number
600  virtual Int_t CurrentVolID(Int_t &copyNo) const = 0;
601 
602  /// Return the current volume off upward in the geometrical tree
603  /// ID and copy number
604  virtual Int_t CurrentVolOffID(Int_t off, Int_t &copyNo) const = 0;
605 
606  /// Return the current volume name
607  virtual const char *CurrentVolName() const = 0;
608 
609  /// Return the current volume off upward in the geometrical tree
610  /// name and copy number'
611  /// if name=0 no name is returned
612  virtual const char *CurrentVolOffName(Int_t off) const = 0;
613 
614  /// Return the path in geometry tree for the current volume
615  virtual const char *CurrentVolPath() = 0;
616 
617  /// If track is on a geometry boundary, fill the normal vector of the crossing
618  /// volume surface and return true, return false otherwise
619  virtual Bool_t CurrentBoundaryNormal(Double_t &x, Double_t &y, Double_t &z) const = 0;
620 
621  /// Return the parameters of the current material during transport
622  virtual Int_t CurrentMaterial(Float_t &a, Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl) const = 0;
623 
624  //// Return the number of the current medium
625  virtual Int_t CurrentMedium() const = 0;
626  // new function (to replace GetMedium() const)
627 
628  /// Return the number of the current event
629  virtual Int_t CurrentEvent() const = 0;
630 
631  /// Computes coordinates xd in daughter reference system
632  /// from known coordinates xm in mother reference system.
633  /// - xm coordinates in mother reference system (input)
634  /// - xd coordinates in daughter reference system (output)
635  /// - iflag
636  /// - IFLAG = 1 convert coordinates
637  /// - IFLAG = 2 convert direction cosines
638  virtual void Gmtod(Float_t *xm, Float_t *xd, Int_t iflag) = 0;
639 
640  /// The same as previous but in double precision
641  virtual void Gmtod(Double_t *xm, Double_t *xd, Int_t iflag) = 0;
642 
643  /// Computes coordinates xm in mother reference system
644  /// from known coordinates xd in daughter reference system.
645  /// - xd coordinates in daughter reference system (input)
646  /// - xm coordinates in mother reference system (output)
647  /// - iflag
648  /// - IFLAG = 1 convert coordinates
649  /// - IFLAG = 2 convert direction cosines
650  virtual void Gdtom(Float_t *xd, Float_t *xm, Int_t iflag) = 0;
651 
652  /// The same as previous but in double precision
653  virtual void Gdtom(Double_t *xd, Double_t *xm, Int_t iflag) = 0;
654 
655  /// Return the maximum step length in the current medium
656  virtual Double_t MaxStep() const = 0;
657 
658  /// Return the maximum number of steps allowed in the current medium
659  virtual Int_t GetMaxNStep() const = 0;
660 
661  //
662  // get methods
663  // tracking particle
664  // dynamic properties
665  // ------------------------------------------------
666  //
667 
668  /// Return the current position in the master reference frame of the
669  /// track being transported
670  virtual void TrackPosition(TLorentzVector &position) const = 0;
671 
672  /// Only return spatial coordinates (as double)
673  virtual void TrackPosition(Double_t &x, Double_t &y, Double_t &z) const = 0;
674 
675  /// Only return spatial coordinates (as float)
676  virtual void TrackPosition(Float_t &x, Float_t &y, Float_t &z) const = 0;
677 
678  /// Return the direction and the momentum (GeV/c) of the track
679  /// currently being transported
680  virtual void TrackMomentum(TLorentzVector &momentum) const = 0;
681 
682  /// Return the direction and the momentum (GeV/c) of the track
683  /// currently being transported (as double)
684  virtual void TrackMomentum(Double_t &px, Double_t &py, Double_t &pz, Double_t &etot) const = 0;
685 
686  /// Return the direction and the momentum (GeV/c) of the track
687  /// currently being transported (as float)
688  virtual void TrackMomentum(Float_t &px, Float_t &py, Float_t &pz, Float_t &etot) const = 0;
689 
690  /// Return the length in centimeters of the current step (in cm)
691  virtual Double_t TrackStep() const = 0;
692 
693  /// Return the length of the current track from its origin (in cm)
694  virtual Double_t TrackLength() const = 0;
695 
696  /// Return the current time of flight of the track being transported
697  virtual Double_t TrackTime() const = 0;
698 
699  /// Return the energy lost in the current step
700  virtual Double_t Edep() const = 0;
701 
702  /// Return the non-ionising energy lost (NIEL) in the current step
703  virtual Double_t NIELEdep() const;
704 
705  /// Return the current step number
706  virtual Int_t StepNumber() const;
707 
708  /// Get the current weight
709  virtual Double_t TrackWeight() const;
710 
711  /// Get the current polarization
712  virtual void TrackPolarization(Double_t &polX, Double_t &polY, Double_t &polZ) const;
713 
714  /// Get the current polarization
715  virtual void TrackPolarization(TVector3 &pol) const;
716 
717  //
718  // get methods
719  // tracking particle
720  // static properties
721  // ------------------------------------------------
722  //
723 
724  /// Return the PDG of the particle transported
725  virtual Int_t TrackPid() const = 0;
726 
727  /// Return the charge of the track currently transported
728  virtual Double_t TrackCharge() const = 0;
729 
730  /// Return the mass of the track currently transported
731  virtual Double_t TrackMass() const = 0;
732 
733  /// Return the total energy of the current track
734  virtual Double_t Etot() const = 0;
735 
736  //
737  // get methods - track status
738  // ------------------------------------------------
739  //
740 
741  /// Return true when the track performs the first step
742  virtual Bool_t IsNewTrack() const = 0;
743 
744  /// Return true if the track is not at the boundary of the current volume
745  virtual Bool_t IsTrackInside() const = 0;
746 
747  /// Return true if this is the first step of the track in the current volume
748  virtual Bool_t IsTrackEntering() const = 0;
749 
750  /// Return true if this is the last step of the track in the current volume
751  virtual Bool_t IsTrackExiting() const = 0;
752 
753  /// Return true if the track is out of the setup
754  virtual Bool_t IsTrackOut() const = 0;
755 
756  /// Return true if the current particle has disappeared
757  /// either because it decayed or because it underwent
758  /// an inelastic collision
759  virtual Bool_t IsTrackDisappeared() const = 0;
760 
761  /// Return true if the track energy has fallen below the threshold
762  virtual Bool_t IsTrackStop() const = 0;
763 
764  /// Return true if the current particle is alive and will continue to be
765  /// transported
766  virtual Bool_t IsTrackAlive() const = 0;
767 
768  //
769  // get methods - secondaries
770  // ------------------------------------------------
771  //
772 
773  /// Return the number of secondary particles generated in the current step
774  virtual Int_t NSecondaries() const = 0;
775 
776  /// Return the parameters of the secondary track number isec produced
777  /// in the current step
778  virtual void GetSecondary(Int_t isec, Int_t &particleId, TLorentzVector &position, TLorentzVector &momentum) = 0;
779 
780  /// Return the VMC code of the process that has produced the secondary
781  /// particles in the current step
782  virtual TMCProcess ProdProcess(Int_t isec) const = 0;
783 
784  /// Return the array of the VMC code of the processes active in the current
785  /// step
786  virtual Int_t StepProcesses(TArrayI &proc) const = 0;
787 
788  /// Return the information about the transport order needed by the stack
789  virtual Bool_t SecondariesAreOrdered() const = 0;
790 
791  //
792  // ------------------------------------------------
793  // Control methods
794  // ------------------------------------------------
795  //
796 
797  /// Initialize MC
798  virtual void Init() = 0;
799 
800  /// Initialize MC physics
801  virtual void BuildPhysics() = 0;
802 
803  /// Process one event
804  virtual void ProcessEvent(Int_t eventId);
805 
806  /// Process one event (backward-compatibility)
807  virtual void ProcessEvent();
808 
809  /// Process one run and return true if run has finished successfully,
810  /// return false in other cases (run aborted by user)
811  virtual Bool_t ProcessRun(Int_t nevent) = 0;
812 
813  /// Additional cleanup after a run can be done here (optional)
814  virtual void TerminateRun() {}
815 
816  /// Set switches for lego transport
817  virtual void InitLego() = 0;
818 
819  /// (In)Activate collecting TGeo tracks
820  virtual void SetCollectTracks(Bool_t collectTracks) = 0;
821 
822  /// Return the info if collecting tracks is activated
823  virtual Bool_t IsCollectTracks() const = 0;
824 
825  /// Return the info if multi-threading is supported/activated
826  virtual Bool_t IsMT() const { return kFALSE; }
827 
828  //
829  // ------------------------------------------------
830  // Set methods
831  // ------------------------------------------------
832  //
833 
834  /// Set the particle stack
835  virtual void SetStack(TVirtualMCStack *stack);
836 
837  /// Set the external decayer
838  virtual void SetExternalDecayer(TVirtualMCDecayer *decayer);
839 
840  /// Set the random number generator
841  virtual void SetRandom(TRandom *random);
842 
843  /// Set the magnetic field
844  virtual void SetMagField(TVirtualMagField *field);
845 
846  //
847  // ------------------------------------------------
848  // Get methods
849  // ------------------------------------------------
850  //
851 
852  /// Return the particle stack
853  TVirtualMCStack *GetStack() const { return fStack; }
854 
855  /// Return the particle stack managed by the TMCManager (if any)
856  TMCManagerStack *GetManagerStack() const { return fManagerStack; }
857 
858  /// Return the external decayer
859  TVirtualMCDecayer *GetDecayer() const { return fDecayer; }
860 
861  /// Return the random number generator
862  TRandom *GetRandom() const { return fRandom; }
863 
864  /// Return the magnetic field
865  TVirtualMagField *GetMagField() const { return fMagField; }
866 
867  /// Return the VMC's ID
868  Int_t GetId() const { return fId; }
869 
870 private:
871  /// Set the VMC id
872  void SetId(UInt_t id);
873 
874  /// Set container holding additional information for transported TParticles
875  void SetManagerStack(TMCManagerStack *stack);
876 
877  /// An interruptible event can be paused and resumed at any time. It must not
878  /// call TVirtualMCApplication::BeginEvent() and ::FinishEvent()
879  /// Further, when tracks are popped from the TVirtualMCStack it must be
880  /// checked whether these are new tracks or whether they have been
881  /// transported up to their current point.
882  virtual void ProcessEvent(Int_t eventId, Bool_t isInterruptible);
883 
884  /// That triggers stopping the transport of the current track without dispatching
885  /// to common routines like TVirtualMCApplication::PostTrack() etc.
886  virtual void InterruptTrack();
887 
888  // Private, no copying.
889  TVirtualMC(const TVirtualMC &mc);
890  TVirtualMC &operator=(const TVirtualMC &);
891 
892 protected:
893  TVirtualMCApplication *fApplication; //!< User MC application
894 
895 private:
896 #if !defined(__CINT__)
897  static TMCThreadLocal TVirtualMC *fgMC; ///< Static TVirtualMC pointer
898 #else
899  static TVirtualMC *fgMC; ///< Static TVirtualMC pointer
900 #endif
901 
902 private:
903  Int_t fId; //!< Unique identification of this VMC
904  // (don't use TObject::SetUniqueId since this
905  // is used to uniquely identify TObjects in
906  // in general)
907  // An ID is given by the running TVirtualMCApp
908  // and not by the user.
909  TVirtualMCStack *fStack; //!< Particles stack
910  TMCManagerStack *fManagerStack; //!< Stack handled by the TMCManager
911  TVirtualMCDecayer *fDecayer; //!< External decayer
912  TRandom *fRandom; //!< Random number generator
913  TVirtualMagField *fMagField; //!< Magnetic field
914 
915  ClassDef(TVirtualMC, 1) // Interface to Monte Carlo
916 };
917 
918 // inline functions (with temorary implementation)
919 
920 inline void TVirtualMC::SetSensitiveDetector(const TString & /*volName*/, TVirtualMCSensitiveDetector * /*sd*/)
921 {
922  /// Set a sensitive detector to a volume
923  /// - volName - the volume name
924  /// - sd - the user sensitive detector
925 
926  Warning("SetSensitiveDetector(...)", "New function - not yet implemented.");
927 }
928 
929 inline TVirtualMCSensitiveDetector *TVirtualMC::GetSensitiveDetector(const TString & /*volName*/) const
930 {
931  /// Get a sensitive detector of a volume
932  /// - volName - the volume name
933 
934  Warning("GetSensitiveDetector()", "New function - not yet implemented.");
935 
936  return 0;
937 }
938 
939 inline void TVirtualMC::SetExclusiveSDScoring(Bool_t /*exclusiveSDScoring*/)
940 {
941  /// The scoring option:
942  /// if true, scoring is performed only via user defined sensitive detectors and
943  /// MCApplication::Stepping is not called
944 
945  Warning("SetExclusiveSDScoring(...)", "New function - not yet implemented.");
946 }
947 
948 inline Double_t TVirtualMC::NIELEdep() const
949 {
950  /// Return the non-ionising energy lost (NIEL) in the current step
951 
952  Warning("NIELEdep()", "New function - not yet implemented.");
953 
954  return 0.;
955 }
956 
957 #define gMC (TVirtualMC::GetMC())
958 
959 #endif // ROOT_TVirtualMC