Logo ROOT   6.08/07
Reference Guide
TVirtualMC.cxx
Go to the documentation of this file.
1 // @(#)root/vmc:$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 #include "TVirtualMC.h"
14 
15 /** \class TVirtualMC
16  \ingroup vmc
17 
18 Abstract Monte Carlo interface
19 
20 Virtual MC provides a virtual interface to Monte Carlo.
21 It enables the user to build a virtual Monte Carlo application
22 independent of any actual underlying Monte Carlo implementation itself.
23 
24 A user will have to implement a class derived from the abstract
25 Monte Carlo application class, and provide functions like
26 ConstructGeometry(), BeginEvent(), FinishEvent(), ... .
27 The concrete Monte Carlo (Geant3, Geant4) is selected at run time -
28 when processing a ROOT macro where the concrete Monte Carlo is instantiated.
29 */
30 
32 
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 ///
37 /// Standard constructor
38 ///
39 
40 TVirtualMC::TVirtualMC(const char *name, const char *title,
41  Bool_t /*isRootGeometrySupported*/)
42  : TNamed(name,title),
43  fApplication(0),
44  fStack(0),
45  fDecayer(0),
46  fRandom(0),
47  fMagField(0)
48 {
49  if(fgMC) {
50  Warning("TVirtualMC","Cannot initialise twice MonteCarlo class");
51  } else {
52  fgMC=this;
53 
55 
56  if (!fApplication) {
57  Error("TVirtualMC", "No user MC application is defined.");
58  }
59 
60  fRandom = gRandom;
61  }
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 ///
66 /// Default constructor
67 ///
68 
70  : TNamed(),
71  fApplication(0),
72  fStack(0),
73  fDecayer(0),
74  fRandom(0),
75  fMagField(0)
76 {
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 ///
81 /// Destructor
82 ///
83 
85 {
86  fgMC=0;
87 }
88 
89 //
90 // methods
91 //
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 ///
95 /// Static access method
96 ///
97 
99  return fgMC;
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 ///
104 /// Set particles stack.
105 ///
106 
108 {
109  fStack = stack;
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 ///
114 /// Set external decayer.
115 ///
116 
118 {
119  fDecayer = decayer;
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 ///
124 /// Set random number generator.
125 ///
126 
128 {
129  gRandom = random;
130  fRandom = random;
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 ///
135 /// Set magnetic field.
136 ///
137 
139 {
140  fMagField = field;
141 }
static TMCThreadLocal TVirtualMC * fgMC
Monte Carlo singleton instance.
Definition: TVirtualMC.h:868
TVirtualMCStack * fStack
Particles stack.
Definition: TVirtualMC.h:873
TRandom * fRandom
Random number generator.
Definition: TVirtualMC.h:875
TVirtualMCDecayer * fDecayer
External decayer.
Definition: TVirtualMC.h:874
bool Bool_t
Definition: RtypesCore.h:59
Abstract base class for particle decays.
virtual ~TVirtualMC()
Destructor.
Definition: TVirtualMC.cxx:84
TVirtualMC()
Default constructor.
Definition: TVirtualMC.cxx:69
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TVirtualMCApplication * fApplication
User MC application.
Definition: TVirtualMC.h:861
TVirtualMagField * fMagField
Magnetic field.
Definition: TVirtualMC.h:876
Interface to a user defined particles stack.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
R__EXTERN TRandom * gRandom
Definition: TRandom.h:66
#define TMCThreadLocal
Definition: TMCtls.h:59
virtual void SetMagField(TVirtualMagField *field)
Set the magnetic field.
Definition: TVirtualMC.cxx:138
#define ClassImp(name)
Definition: Rtypes.h:279
Abstract Monte Carlo interface.
Definition: TVirtualMC.h:41
virtual void SetRandom(TRandom *random)
Set the random number generator.
Definition: TVirtualMC.cxx:127
Abstract class for magnetic field.
virtual void SetExternalDecayer(TVirtualMCDecayer *decayer)
Set the external decayer.
Definition: TVirtualMC.cxx:117
virtual void SetStack(TVirtualMCStack *stack)
Set the particle stack.
Definition: TVirtualMC.cxx:107
static TVirtualMCApplication * Instance()
Static access method.
static TVirtualMC * GetMC()
Static access method.
Definition: TVirtualMC.cxx:98
char name[80]
Definition: TGX11.cxx:109
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911