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
19Abstract Monte Carlo interface
20
21Virtual MC provides a virtual interface to Monte Carlo.
22It enables the user to build a virtual Monte Carlo application
23independent of any actual underlying Monte Carlo implementation itself.
24
25A user will have to implement a class derived from the abstract
26Monte Carlo application class, and provide functions like
27ConstructGeometry(), BeginEvent(), FinishEvent(), ... .
28The concrete Monte Carlo (Geant3, Geant4) is selected at run time -
29when processing a ROOT macro where the concrete Monte Carlo is instantiated.
30*/
31
33////////////////////////////////////////////////////////////////////////////////
34///
35/// Standard constructor
36///
37
38TVirtualMC::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) {
46 } else {
47 ::Fatal("TVirtualMC::TVirtualMC", "No user MC application is defined.");
48 }
49 fgMC = this;
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
225void 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}
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
#define TMCThreadLocal
Definition: TMCtls.h:80
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
Concrete implementation of particles stack used by the TMCManager.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:908
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
TVector3 is a general three vector class, which can be used for the description of different vectors ...
Definition: TVector3.h:22
void Register(TVirtualMC *mc)
Register the an engine.
static TVirtualMCApplication * Instance()
Static access method.
Abstract base class for particle decays.
Interface to a user defined particles stack.
Abstract Monte Carlo interface.
Definition: TVirtualMC.h:42
TVirtualMC()
Default constructor.
Definition: TVirtualMC.cxx:58
TRandom * fRandom
Random number generator.
Definition: TVirtualMC.h:912
virtual void TrackPolarization(Double_t &polX, Double_t &polY, Double_t &polZ) const
Get the current polarization.
Definition: TVirtualMC.cxx:176
virtual Int_t StepNumber() const
Return the current step number.
Definition: TVirtualMC.cxx:154
virtual void InterruptTrack()
That triggers stopping the transport of the current track without dispatching to common routines like...
Definition: TVirtualMC.cxx:237
static TVirtualMC * GetMC()
Static access method.
Definition: TVirtualMC.cxx:83
TMCManagerStack * fManagerStack
Stack handled by the TMCManager.
Definition: TVirtualMC.h:910
virtual void ProcessEvent()
Process one event (backward-compatibility)
Definition: TVirtualMC.cxx:134
virtual void SetRandom(TRandom *random)
Set the random number generator.
Definition: TVirtualMC.cxx:113
void SetId(UInt_t id)
Set the VMC id.
Definition: TVirtualMC.cxx:202
Int_t fId
Unique identification of this VMC.
Definition: TVirtualMC.h:903
virtual void SetStack(TVirtualMCStack *stack)
Set the particle stack.
Definition: TVirtualMC.cxx:93
void SetManagerStack(TMCManagerStack *stack)
Set container holding additional information for transported TParticles.
Definition: TVirtualMC.cxx:211
virtual Double_t TrackWeight() const
Get the current weight.
Definition: TVirtualMC.cxx:165
TVirtualMagField * fMagField
Magnetic field.
Definition: TVirtualMC.h:913
static TMCThreadLocal TVirtualMC * fgMC
Static TVirtualMC pointer.
Definition: TVirtualMC.h:897
TVirtualMCApplication * fApplication
User MC application.
Definition: TVirtualMC.h:893
virtual void SetExternalDecayer(TVirtualMCDecayer *decayer)
Set the external decayer.
Definition: TVirtualMC.cxx:103
virtual void SetMagField(TVirtualMagField *field)
Set the magnetic field.
Definition: TVirtualMC.cxx:124
virtual ~TVirtualMC()
Destructor.
Definition: TVirtualMC.cxx:69
TVirtualMCStack * fStack
Particles stack.
Definition: TVirtualMC.h:909
TVirtualMCDecayer * fDecayer
External decayer.
Definition: TVirtualMC.h:911
Abstract class for magnetic field.