Logo ROOT  
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 #include "TError.h"
15 
16 /** \class TVirtualMC
17  \ingroup vmc
18 
19 Abstract Monte Carlo interface
20 
21 Virtual MC provides a virtual interface to Monte Carlo.
22 It enables the user to build a virtual Monte Carlo application
23 independent of any actual underlying Monte Carlo implementation itself.
24 
25 A user will have to implement a class derived from the abstract
26 Monte Carlo application class, and provide functions like
27 ConstructGeometry(), BeginEvent(), FinishEvent(), ... .
28 The concrete Monte Carlo (Geant3, Geant4) is selected at run time -
29 when processing a ROOT macro where the concrete Monte Carlo is instantiated.
30 */
31 
33 ////////////////////////////////////////////////////////////////////////////////
34 ///
35 /// Standard constructor
36 ///
37 
38 TVirtualMC::TVirtualMC(const char *name, const char *title, Bool_t /*isRootGeometrySupported*/)
39  : TNamed(name, title), fApplication(nullptr), fId(0), fStack(nullptr), fManagerStack(nullptr), fDecayer(nullptr),
40  fRandom(nullptr), fMagField(nullptr)
41 {
43 
44  if (fApplication) {
45  fApplication->Register(this);
46  } else {
47  ::Fatal("TVirtualMC::TVirtualMC", "No user MC application is defined.");
48  }
49  fgMC = this;
50  fRandom = gRandom;
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 ///
55 /// Default constructor
56 ///
57 
59  : TNamed(), fApplication(nullptr), fId(0), fStack(nullptr), fManagerStack(nullptr), fDecayer(nullptr),
60  fRandom(nullptr), fMagField(nullptr)
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 ///
66 /// Destructor
67 ///
68 
70 {
71  fgMC = nullptr;
72 }
73 
74 //
75 // methods
76 //
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 ///
80 /// Static access method
81 ///
82 
84 {
85  return fgMC;
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 ///
90 /// Set particles stack.
91 ///
92 
94 {
95  fStack = stack;
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 ///
100 /// Set external decayer.
101 ///
102 
104 {
105  fDecayer = decayer;
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 ///
110 /// Set random number generator.
111 ///
112 
114 {
115  gRandom = random;
116  fRandom = random;
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 ///
121 /// Set magnetic field.
122 ///
123 
125 {
126  fMagField = field;
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 ///
131 /// Process one event (backwards compatibility)
132 ///
133 
135 {
136  Warning("ProcessEvent", "Not implemented.");
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 ///
141 /// Process one event (backwards compatibility)
142 ///
143 
145 {
146  ProcessEvent(eventId, kFALSE);
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 ///
151 /// Return the current step number
152 ///
153 
155 {
156  Warning("StepNumber", "Not implemented.");
157  return 0;
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 ///
162 /// Get the current weight
163 ///
164 
166 {
167  Warning("Weight", "Not implemented.");
168  return 1.;
169 }
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 ///
173 /// Get the current polarization
174 ///
175 
177 {
178  Warning("Polarization", "Not implemented.");
179  polX = 0.;
180  polY = 0.;
181  polZ = 0.;
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 ///
186 /// Get the current polarization
187 ///
188 
190 {
191  Warning("Polarization", "Not implemented.");
192  pol[0] = 0.;
193  pol[1] = 0.;
194  pol[2] = 0.;
195 }
196 
197 ////////////////////////////////////////////////////////////////////////////////
198 ///
199 /// Set the VMC id
200 ///
201 
203 {
204  fId = id;
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 ///
209 /// Set container holding additional information for transported TParticles
210 ///
212 {
213  fManagerStack = stack;
214 }
215 
216 ////////////////////////////////////////////////////////////////////////////////
217 ///
218 /// An interruptible event can be paused and resumed at any time. It must not
219 /// call TVirtualMCApplication::BeginEvent() and ::FinishEvent()
220 /// Further, when tracks are popped from the TVirtualMCStack it must be
221 /// checked whether these are new tracks or whether they have been
222 /// transported up to their current point.
223 ///
224 
225 void TVirtualMC::ProcessEvent(Int_t eventId, Bool_t isInterruptible)
226 {
227  const char *interruptibleText = isInterruptible ? "interruptible" : "non-interruptible";
228  Warning("ProcessInterruptibleEvent", "Process %s event %i. Not implemented.", interruptibleText, eventId);
229 }
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 ///
233 /// That triggers stopping the transport of the current track without dispatching
234 /// to common routines like TVirtualMCApplication::PostTrack() etc.
235 ///
236 
238 {
239  Warning("InterruptTrack", "Not implemented.");
240 }
TVirtualMC::TVirtualMC
TVirtualMC()
Default constructor.
Definition: TVirtualMC.cxx:58
TVirtualMC.h
TVector3
TVector3 is a general three vector class, which can be used for the description of different vectors ...
Definition: TVector3.h:22
TVirtualMC::SetExternalDecayer
virtual void SetExternalDecayer(TVirtualMCDecayer *decayer)
Set the external decayer.
Definition: TVirtualMC.cxx:103
TMCThreadLocal
#define TMCThreadLocal
Definition: TMCtls.h:80
TVirtualMC::SetStack
virtual void SetStack(TVirtualMCStack *stack)
Set the particle stack.
Definition: TVirtualMC.cxx:93
TVirtualMC::TrackPolarization
virtual void TrackPolarization(Double_t &polX, Double_t &polY, Double_t &polZ) const
Get the current polarization.
Definition: TVirtualMC.cxx:176
TObject::Fatal
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:918
TVirtualMCApplication::Register
void Register(TVirtualMC *mc)
Register the an engine.
Definition: TVirtualMCApplication.cxx:104
TVirtualMC::StepNumber
virtual Int_t StepNumber() const
Return the current step number.
Definition: TVirtualMC.cxx:154
TVirtualMagField
Abstract class for magnetic field.
Definition: TVirtualMagField.h:17
TVirtualMC::SetMagField
virtual void SetMagField(TVirtualMagField *field)
Set the magnetic field.
Definition: TVirtualMC.cxx:124
TVirtualMC::ProcessEvent
virtual void ProcessEvent()
Process one event (backward-compatibility)
Definition: TVirtualMC.cxx:134
bool
TVirtualMC::SetRandom
virtual void SetRandom(TRandom *random)
Set the random number generator.
Definition: TVirtualMC.cxx:113
id
XFontStruct * id
Definition: TGX11.cxx:109
TMCManagerStack
Concrete implementation of particles stack used by the TMCManager.
Definition: TMCManagerStack.h:35
TVirtualMC::fgMC
static TMCThreadLocal TVirtualMC * fgMC
Static TVirtualMC pointer.
Definition: TVirtualMC.h:897
TVirtualMC::fStack
TVirtualMCStack * fStack
Particles stack.
Definition: TVirtualMC.h:909
TVirtualMC::fDecayer
TVirtualMCDecayer * fDecayer
External decayer.
Definition: TVirtualMC.h:911
TVirtualMC::InterruptTrack
virtual void InterruptTrack()
That triggers stopping the transport of the current track without dispatching to common routines like...
Definition: TVirtualMC.cxx:237
TRandom
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TVirtualMC::fId
Int_t fId
Unique identification of this VMC.
Definition: TVirtualMC.h:903
gRandom
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
TVirtualMC::GetMC
static TVirtualMC * GetMC()
Static access method.
Definition: TVirtualMC.cxx:83
TVirtualMCStack
Interface to a user defined particles stack.
Definition: TVirtualMCStack.h:26
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:876
unsigned int
TVirtualMC::~TVirtualMC
virtual ~TVirtualMC()
Destructor.
Definition: TVirtualMC.cxx:69
Double_t
double Double_t
Definition: RtypesCore.h:59
TVirtualMC::fRandom
TRandom * fRandom
Random number generator.
Definition: TVirtualMC.h:912
TVirtualMC::fManagerStack
TMCManagerStack * fManagerStack
Stack handled by the TMCManager.
Definition: TVirtualMC.h:910
TVirtualMC::fMagField
TVirtualMagField * fMagField
Magnetic field.
Definition: TVirtualMC.h:913
name
char name[80]
Definition: TGX11.cxx:110
TVirtualMC
Abstract Monte Carlo interface.
Definition: TVirtualMC.h:42
TVirtualMC::TrackWeight
virtual Double_t TrackWeight() const
Get the current weight.
Definition: TVirtualMC.cxx:165
TVirtualMCApplication::Instance
static TVirtualMCApplication * Instance()
Static access method.
Definition: TVirtualMCApplication.cxx:81
TVirtualMC::fApplication
TVirtualMCApplication * fApplication
User MC application.
Definition: TVirtualMC.h:893
TVirtualMC::SetManagerStack
void SetManagerStack(TMCManagerStack *stack)
Set container holding additional information for transported TParticles.
Definition: TVirtualMC.cxx:211
TVirtualMC::SetId
void SetId(UInt_t id)
Set the VMC id.
Definition: TVirtualMC.cxx:202
TVirtualMCDecayer
Abstract base class for particle decays.
Definition: TVirtualMCDecayer.h:23
int
TError.h