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 
26 class TVirtualMC;
27 class TMCManager;
28 
29 class TVirtualMCApplication : public TNamed {
30 
31 public:
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)
67  virtual void ConstructSensitiveDetectors() {}
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 
141 protected:
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 
150 private:
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 
164 inline 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
TVirtualMCApplication::CloneForWorker
virtual TVirtualMCApplication * CloneForWorker() const
Clone MC application on worker.
Definition: TVirtualMCApplication.h:120
TVirtualMCApplication::Merge
virtual void Merge(TVirtualMCApplication *)
Merge the data accumulated on workers to the master if needed.
Definition: TVirtualMCApplication.h:139
TVirtualMCApplication::BeginRunOnWorker
virtual void BeginRunOnWorker()
Define actions at the beginning of the worker run if needed.
Definition: TVirtualMCApplication.h:135
TVirtualMCApplication::GeaneStepping
virtual void GeaneStepping()
Define action at each step for Geane.
Definition: TVirtualMCApplication.h:116
TVirtualMCApplication::TrackingZmax
virtual Double_t TrackingZmax() const
Define maximum z for tracking (optional)
Definition: TVirtualMCApplication.h:110
TVirtualMCApplication::GeneratePrimaries
virtual void GeneratePrimaries()=0
Generate primary particles.
TVirtualMCApplication::~TVirtualMCApplication
virtual ~TVirtualMCApplication()
Destructor.
Definition: TVirtualMCApplication.cxx:68
TVirtualMCApplication::fMC
TVirtualMC * fMC
The current transport engine in use.
Definition: TVirtualMCApplication.h:144
TMCThreadLocal
#define TMCThreadLocal
Definition: TMCtls.h:80
TVirtualMCApplication::PreTrack
virtual void PreTrack()=0
Define actions at the beginning of each track.
TNamed.h
TVirtualMCApplication::ConstructSensitiveDetectors
virtual void ConstructSensitiveDetectors()
Define sensitive detectors (optional)
Definition: TVirtualMCApplication.h:67
TVirtualMCApplication::TrackingRmax
virtual Double_t TrackingRmax() const
Define maximum radius for tracking (optional)
Definition: TVirtualMCApplication.h:107
TVirtualMCApplication::BeginEvent
virtual void BeginEvent()=0
Define actions at the beginning of the event.
TVirtualMCApplication::FinishPrimary
virtual void FinishPrimary()=0
Define actions at the end of the primary track.
TVirtualMCApplication::BeginWorkerRun
virtual void BeginWorkerRun() const
Const Define actions at the beginning of the worker run if needed - now deprecated Use new non-const ...
Definition: TVirtualMCApplication.h:127
TVirtualMCApplication::FinishEvent
virtual void FinishEvent()=0
Define actions at the end of the event.
TVirtualMCApplication::Register
void Register(TVirtualMC *mc)
Register the an engine.
Definition: TVirtualMCApplication.cxx:104
TVirtualMCApplication::AddParticles
virtual void AddParticles()
Add user defined particles (optional)
Definition: TVirtualMCApplication.h:74
x
Double_t x[n]
Definition: legend1.C:17
TVirtualMCApplication::fMCManager
TMCManager * fMCManager
Pointer to requested TMCManager which will only be instantiated by a call to RequestMCManager()
Definition: TVirtualMCApplication.h:148
TVirtualMCApplication::AddIons
virtual void AddIons()
Add user defined ions (optional)
Definition: TVirtualMCApplication.h:77
TVirtualMCApplication::PostTrack
virtual void PostTrack()=0
Define actions at the end of each track.
b
#define b(i)
Definition: RSha256.hxx:118
bool
TVirtualMCApplication::RequestMCManager
void RequestMCManager()
Request a TMCManager which is required if multiple engines should be run.
Definition: TVirtualMCApplication.cxx:91
TMCtls.h
TVirtualMCApplication::TVirtualMCApplication
TVirtualMCApplication()
Default constructor.
Definition: TVirtualMCApplication.cxx:56
TVirtualMCApplication::MisalignGeometry
virtual Bool_t MisalignGeometry()
Misalign user geometry (optional)
Definition: TVirtualMCApplication.h:61
TNamed
Definition: TNamed.h:29
TVirtualMCApplication::FinishRunOnWorker
virtual void FinishRunOnWorker()
Define actions at the end of the worker run if needed.
Definition: TVirtualMCApplication.h:137
TVirtualMCApplication::InitForWorker
virtual void InitForWorker() const
Const Initialize MC application on worker - now deprecated Use new non-const InitOnWorker() instead.
Definition: TVirtualMCApplication.h:124
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TVirtualMCApplication::BeginPrimary
virtual void BeginPrimary()=0
Define actions at the beginning of the primary track.
TVirtualMCApplication::ConstructGeometry
virtual void ConstructGeometry()=0
Construct user geometry.
TVirtualMCApplication::EndOfEvent
virtual void EndOfEvent()
Define actions at the end of the event before calling SD's end of the event.
Definition: TVirtualMCApplication.h:101
TMCManager
Definition: TMCManager.h:36
TVirtualMCApplication::fgInstance
static TMCThreadLocal TVirtualMCApplication * fgInstance
Singleton instance.
Definition: TVirtualMCApplication.h:154
Double_t
double Double_t
Definition: RtypesCore.h:59
TVirtualMCApplication::FinishWorkerRun
virtual void FinishWorkerRun() const
Const Define actions at the end of the worker run if needed - now deprecated Use new non-const Finish...
Definition: TVirtualMCApplication.h:130
TVirtualMCApplication::fLockMultiThreading
static Bool_t fLockMultiThreading
Forbid multithreading mode if multi run via global static flag.
Definition: TVirtualMCApplication.h:159
TVirtualMCApplication::Field
virtual void Field(const Double_t *x, Double_t *b) const
Calculate user field b at point x.
Definition: TVirtualMCApplication.h:164
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TVirtualMC
Definition: TVirtualMC.h:42
TVirtualMCApplication::InitGeometry
virtual void InitGeometry()=0
Initialize geometry (Usually used to define sensitive volumes IDs)
TVirtualMCApplication
Definition: TVirtualMCApplication.h:29
TVirtualMCApplication::Instance
static TVirtualMCApplication * Instance()
Static access method.
Definition: TVirtualMCApplication.cxx:81
TVirtualMCApplication::InitOnWorker
virtual void InitOnWorker()
Initialize MC application on worker.
Definition: TVirtualMCApplication.h:133
TVirtualMCApplication::Stepping
virtual void Stepping()=0
Define action at each step.
TVirtualMCApplication::GetMC
TVirtualMC * GetMC() const
Return the transport engine registered to this application.
Definition: TVirtualMCApplication.cxx:122
TVirtualMCApplication::ConstructOpGeometry
virtual void ConstructOpGeometry()
Define parameters for optical processes (optional)
Definition: TVirtualMCApplication.h:64
TMath.h