forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TVirtualMC.cxx
141 lines (113 loc) · 3.34 KB
/
TVirtualMC.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// @(#)root/vmc:$Id$
// Authors: Ivana Hrivnacova, Rene Brun , Federico Carminati 13/04/2002
/*************************************************************************
* Copyright (C) 2006, Rene Brun and Fons Rademakers. *
* Copyright (C) 2002, ALICE Experiment at CERN. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TVirtualMC.h"
/** \class TVirtualMC
\ingroup vmc
Abstract Monte Carlo interface
Virtual MC provides a virtual interface to Monte Carlo.
It enables the user to build a virtual Monte Carlo application
independent of any actual underlying Monte Carlo implementation itself.
A user will have to implement a class derived from the abstract
Monte Carlo application class, and provide functions like
ConstructGeometry(), BeginEvent(), FinishEvent(), ... .
The concrete Monte Carlo (Geant3, Geant4) is selected at run time -
when processing a ROOT macro where the concrete Monte Carlo is instantiated.
*/
ClassImp(TVirtualMC);
TMCThreadLocal TVirtualMC* TVirtualMC::fgMC=0;
////////////////////////////////////////////////////////////////////////////////
///
/// Standard constructor
///
TVirtualMC::TVirtualMC(const char *name, const char *title,
Bool_t /*isRootGeometrySupported*/)
: TNamed(name,title),
fApplication(0),
fStack(0),
fDecayer(0),
fRandom(0),
fMagField(0)
{
if(fgMC) {
Warning("TVirtualMC","Cannot initialise twice MonteCarlo class");
} else {
fgMC=this;
fApplication = TVirtualMCApplication::Instance();
if (!fApplication) {
Error("TVirtualMC", "No user MC application is defined.");
}
fRandom = gRandom;
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// Default constructor
///
TVirtualMC::TVirtualMC()
: TNamed(),
fApplication(0),
fStack(0),
fDecayer(0),
fRandom(0),
fMagField(0)
{
}
////////////////////////////////////////////////////////////////////////////////
///
/// Destructor
///
TVirtualMC::~TVirtualMC()
{
fgMC=0;
}
//
// methods
//
////////////////////////////////////////////////////////////////////////////////
///
/// Static access method
///
TVirtualMC* TVirtualMC::GetMC() {
return fgMC;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Set particles stack.
///
void TVirtualMC::SetStack(TVirtualMCStack* stack)
{
fStack = stack;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Set external decayer.
///
void TVirtualMC::SetExternalDecayer(TVirtualMCDecayer* decayer)
{
fDecayer = decayer;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Set random number generator.
///
void TVirtualMC::SetRandom(TRandom* random)
{
gRandom = random;
fRandom = random;
}
////////////////////////////////////////////////////////////////////////////////
///
/// Set magnetic field.
///
void TVirtualMC::SetMagField(TVirtualMagField* field)
{
fMagField = field;
}