Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
32 TMCThreadLocal TVirtualMC *TVirtualMC::fgMC = nullptr;
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 {
42  fApplication = TVirtualMCApplication::Instance();
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 
58 TVirtualMC::TVirtualMC()
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 
69 TVirtualMC::~TVirtualMC()
70 {
71  fgMC = nullptr;
72 }
73 
74 //
75 // methods
76 //
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 ///
80 /// Static access method
81 ///
82 
83 TVirtualMC *TVirtualMC::GetMC()
84 {
85  return fgMC;
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 ///
90 /// Set particles stack.
91 ///
92 
93 void TVirtualMC::SetStack(TVirtualMCStack *stack)
94 {
95  fStack = stack;
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 ///
100 /// Set external decayer.
101 ///
102 
103 void TVirtualMC::SetExternalDecayer(TVirtualMCDecayer *decayer)
104 {
105  fDecayer = decayer;
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 ///
110 /// Set random number generator.
111 ///
112 
113 void TVirtualMC::SetRandom(TRandom *random)
114 {
115  gRandom = random;
116  fRandom = random;
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 ///
121 /// Set magnetic field.
122 ///
123 
124 void TVirtualMC::SetMagField(TVirtualMagField *field)
125 {
126  fMagField = field;
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 ///
131 /// Process one event (backwards compatibility)
132 ///
133 
134 void TVirtualMC::ProcessEvent()
135 {
136  Warning("ProcessEvent", "Not implemented.");
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 ///
141 /// Process one event (backwards compatibility)
142 ///
143 
144 void TVirtualMC::ProcessEvent(Int_t eventId)
145 {
146  ProcessEvent(eventId, kFALSE);
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 ///
151 /// Return the current step number
152 ///
153 
154 Int_t TVirtualMC::StepNumber() const
155 {
156  Warning("StepNumber", "Not implemented.");
157  return 0;
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 ///
162 /// Get the current weight
163 ///
164 
165 Double_t TVirtualMC::TrackWeight() const
166 {
167  Warning("Weight", "Not implemented.");
168  return 1.;
169 }
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 ///
173 /// Get the current polarization
174 ///
175 
176 void TVirtualMC::TrackPolarization(Double_t &polX, Double_t &polY, Double_t &polZ) const
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 
189 void TVirtualMC::TrackPolarization(TVector3 &pol) const
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 
202 void TVirtualMC::SetId(UInt_t id)
203 {
204  fId = id;
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 ///
209 /// Set container holding additional information for transported TParticles
210 ///
211 void TVirtualMC::SetManagerStack(TMCManagerStack *stack)
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 
237 void TVirtualMC::InterruptTrack()
238 {
239  Warning("InterruptTrack", "Not implemented.");
240 }