Logo ROOT  
Reference Guide
TVirtualMCApplication.h
Go to the documentation of this file.
1// @(#)root/vmc:$Id$
2// Author: Ivana Hrivnacova, 23/03/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#ifndef ROOT_TVirtualMCApplication
14#define ROOT_TVirtualMCApplication
15//
16// Class TVirtualMCApplication
17// ---------------------------
18// Interface to a user Monte Carlo application.
19//
20
21#include "TNamed.h"
22#include "TMath.h"
23
24#include "TMCtls.h"
25
26class TVirtualMC;
27class TMCManager;
28
30
31public:
32 /// Standard constructor
33 TVirtualMCApplication(const char *name, const char *title);
34
35 /// Default constructor
37
38 /// Destructor
39 virtual ~TVirtualMCApplication();
40
41 /// Static access method
43
44 //
45 // methods
46 //
47
48 /// Request a TMCManager which is required if multiple engines should be run
49 void RequestMCManager();
50
51 /// Register the an engine.
52 void Register(TVirtualMC *mc);
53
54 /// Return the transport engine registered to this application
55 TVirtualMC *GetMC() const;
56
57 /// Construct user geometry
58 virtual void ConstructGeometry() = 0;
59
60 /// Misalign user geometry (optional)
61 virtual Bool_t MisalignGeometry() { return kFALSE; }
62
63 /// Define parameters for optical processes (optional)
64 virtual void ConstructOpGeometry() {}
65
66 /// Define sensitive detectors (optional)
68
69 /// Initialize geometry
70 /// (Usually used to define sensitive volumes IDs)
71 virtual void InitGeometry() = 0;
72
73 /// Add user defined particles (optional)
74 virtual void AddParticles() {}
75
76 /// Add user defined ions (optional)
77 virtual void AddIons() {}
78
79 /// Generate primary particles
80 virtual void GeneratePrimaries() = 0;
81
82 /// Define actions at the beginning of the event
83 virtual void BeginEvent() = 0;
84
85 /// Define actions at the beginning of the primary track
86 virtual void BeginPrimary() = 0;
87
88 /// Define actions at the beginning of each track
89 virtual void PreTrack() = 0;
90
91 /// Define action at each step
92 virtual void Stepping() = 0;
93
94 /// Define actions at the end of each track
95 virtual void PostTrack() = 0;
96
97 /// Define actions at the end of the primary track
98 virtual void FinishPrimary() = 0;
99
100 /// Define actions at the end of the event before calling SD's end of the event
101 virtual void EndOfEvent() {}
102
103 /// Define actions at the end of the event
104 virtual void FinishEvent() = 0;
105
106 /// Define maximum radius for tracking (optional)
107 virtual Double_t TrackingRmax() const { return DBL_MAX; }
108
109 /// Define maximum z for tracking (optional)
110 virtual Double_t TrackingZmax() const { return DBL_MAX; }
111
112 /// Calculate user field \a b at point \a x
113 virtual void Field(const Double_t *x, Double_t *b) const;
114
115 /// Define action at each step for Geane
116 virtual void GeaneStepping() { ; }
117
118 // Functions for multi-threading applications
119 /// Clone MC application on worker
120 virtual TVirtualMCApplication *CloneForWorker() const { return 0; }
121
122 /// Const Initialize MC application on worker - now deprecated
123 /// Use new non-const InitOnWorker() instead
124 virtual void InitForWorker() const {}
125 /// Const Define actions at the beginning of the worker run if needed - now deprecated
126 /// Use new non-const BeginRunOnWorker() instead
127 virtual void BeginWorkerRun() const {}
128 /// Const Define actions at the end of the worker run if needed - now deprecated
129 /// Use new non-const FinishRunOnWorker() instead
130 virtual void FinishWorkerRun() const {}
131
132 /// Initialize MC application on worker
133 virtual void InitOnWorker() {}
134 /// Define actions at the beginning of the worker run if needed
135 virtual void BeginRunOnWorker() {}
136 /// Define actions at the end of the worker run if needed
137 virtual void FinishRunOnWorker() {}
138 /// Merge the data accumulated on workers to the master if needed
139 virtual void Merge(TVirtualMCApplication * /*localMCApplication*/) {}
140
141protected:
142 /// The current transport engine in use. In case of a multi-run the TMCManager
143 /// will update this whenever the engine changes.
145
146 /// Pointer to requested TMCManager which will only be instantiated by a call
147 /// to RequestMCManager()
149
150private:
151 // static data members
152#if !defined(__CINT__)
154 *fgInstance; ///< Singleton instance
155#else
156 static TVirtualMCApplication *fgInstance; ///< Singleton instance
157#endif
158 /// Forbid multithreading mode if multi run via global static flag
160
161 ClassDef(TVirtualMCApplication, 1) // Interface to MonteCarlo application
162};
163
164inline void TVirtualMCApplication::Field(const Double_t * /*x*/, Double_t *b) const
165{
166 // No magnetic field
167 b[0] = 0;
168 b[1] = 0;
169 b[2] = 0;
170}
171
172#endif // ROOT_TVirtualMCApplication
#define b(i)
Definition: RSha256.hxx:100
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
#define ClassDef(name, id)
Definition: Rtypes.h:322
char name[80]
Definition: TGX11.cxx:109
#define TMCThreadLocal
Definition: TMCtls.h:80
Singleton manager class for handling and steering a run with multiple TVirtualMC engines sharing even...
Definition: TMCManager.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Interface to a user Monte Carlo application.
TVirtualMCApplication()
Default constructor.
virtual ~TVirtualMCApplication()
Destructor.
TMCManager * fMCManager
Pointer to requested TMCManager which will only be instantiated by a call to RequestMCManager()
virtual void FinishWorkerRun() const
Const Define actions at the end of the worker run if needed - now deprecated Use new non-const Finish...
virtual void ConstructSensitiveDetectors()
Define sensitive detectors (optional)
virtual void InitGeometry()=0
Initialize geometry (Usually used to define sensitive volumes IDs)
virtual void BeginWorkerRun() const
Const Define actions at the beginning of the worker run if needed - now deprecated Use new non-const ...
virtual void Merge(TVirtualMCApplication *)
Merge the data accumulated on workers to the master if needed.
virtual void GeneratePrimaries()=0
Generate primary particles.
virtual void ConstructGeometry()=0
Construct user geometry.
void Register(TVirtualMC *mc)
Register the an engine.
TVirtualMC * GetMC() const
Return the transport engine registered to this application.
virtual void FinishPrimary()=0
Define actions at the end of the primary track.
virtual Double_t TrackingZmax() const
Define maximum z for tracking (optional)
virtual void FinishRunOnWorker()
Define actions at the end of the worker run if needed.
virtual TVirtualMCApplication * CloneForWorker() const
Clone MC application on worker.
virtual Bool_t MisalignGeometry()
Misalign user geometry (optional)
virtual void PostTrack()=0
Define actions at the end of each track.
virtual void GeaneStepping()
Define action at each step for Geane.
virtual void ConstructOpGeometry()
Define parameters for optical processes (optional)
virtual void AddParticles()
Add user defined particles (optional)
virtual void InitForWorker() const
Const Initialize MC application on worker - now deprecated Use new non-const InitOnWorker() instead.
static TMCThreadLocal TVirtualMCApplication * fgInstance
Singleton instance.
void RequestMCManager()
Request a TMCManager which is required if multiple engines should be run.
virtual void Field(const Double_t *x, Double_t *b) const
Calculate user field b at point x.
static Bool_t fLockMultiThreading
Forbid multithreading mode if multi run via global static flag.
virtual void AddIons()
Add user defined ions (optional)
virtual void BeginRunOnWorker()
Define actions at the beginning of the worker run if needed.
virtual void Stepping()=0
Define action at each step.
virtual void BeginPrimary()=0
Define actions at the beginning of the primary track.
static TVirtualMCApplication * Instance()
Static access method.
virtual void BeginEvent()=0
Define actions at the beginning of the event.
TVirtualMC * fMC
The current transport engine in use.
virtual Double_t TrackingRmax() const
Define maximum radius for tracking (optional)
virtual void EndOfEvent()
Define actions at the end of the event before calling SD's end of the event.
virtual void PreTrack()=0
Define actions at the beginning of each track.
virtual void InitOnWorker()
Initialize MC application on worker.
virtual void FinishEvent()=0
Define actions at the end of the event.
Abstract Monte Carlo interface.
Definition: TVirtualMC.h:42
Double_t x[n]
Definition: legend1.C:17