Logo ROOT   6.10/09
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 TVirtualMCApplication : public TNamed {
27 
28 public:
29  /// Standard constructor
30  TVirtualMCApplication(const char *name, const char *title);
31 
32  /// Default constructor
34 
35  /// Destructor
36  virtual ~TVirtualMCApplication();
37 
38  /// Static access method
40 
41  //
42  // methods
43  //
44 
45  /// Construct user geometry
46  virtual void ConstructGeometry() = 0;
47 
48  /// Misalign user geometry (optional)
49  virtual Bool_t MisalignGeometry() {return kFALSE;}
50 
51  /// Define parameters for optical processes (optional)
52  virtual void ConstructOpGeometry() {}
53 
54  /// Initialize geometry
55  /// (Usually used to define sensitive volumes IDs)
56  virtual void InitGeometry() = 0;
57 
58  /// Add user defined particles (optional)
59  virtual void AddParticles() {}
60 
61  /// Add user defined ions (optional)
62  virtual void AddIons() {}
63 
64  /// Generate primary particles
65  virtual void GeneratePrimaries() = 0;
66 
67  /// Define actions at the beginning of the event
68  virtual void BeginEvent() = 0;
69 
70  /// Define actions at the beginning of the primary track
71  virtual void BeginPrimary() = 0;
72 
73  /// Define actions at the beginning of each track
74  virtual void PreTrack() = 0;
75 
76  /// Define action at each step
77  virtual void Stepping() = 0;
78 
79  /// Define actions at the end of each track
80  virtual void PostTrack() = 0;
81 
82  /// Define actions at the end of the primary track
83  virtual void FinishPrimary() = 0;
84 
85  /// Define actions at the end of the event
86  virtual void FinishEvent() = 0;
87 
88  /// Define maximum radius for tracking (optional)
89  virtual Double_t TrackingRmax() const { return DBL_MAX; }
90 
91  /// Define maximum z for tracking (optional)
92  virtual Double_t TrackingZmax() const { return DBL_MAX; }
93 
94  /// Calculate user field \a b at point \a x
95  virtual void Field(const Double_t* x, Double_t* b) const;
96 
97  /// Define action at each step for Geane
98  virtual void GeaneStepping() {;}
99 
100  // Functions for multi-threading applications
101  /// Clone MC application on worker
102  virtual TVirtualMCApplication* CloneForWorker() const { return 0;}
103 
104  /// Const Initialize MC application on worker - now deprecated
105  /// Use new non-const InitOnWorker() instead
106  virtual void InitForWorker() const {}
107  /// Const Define actions at the beginning of the worker run if needed - now deprecated
108  /// Use new non-const BeginRunOnWorker() instead
109  virtual void BeginWorkerRun() const {}
110  /// Const Define actions at the end of the worker run if needed - now deprecated
111  /// Use new non-const FinishRunOnWorker() instead
112  virtual void FinishWorkerRun() const {}
113 
114  /// Initialize MC application on worker
115  virtual void InitOnWorker() {}
116  /// Define actions at the beginning of the worker run if needed
117  virtual void BeginRunOnWorker() {}
118  /// Define actions at the end of the worker run if needed
119  virtual void FinishRunOnWorker() {}
120  /// Merge the data accumulated on workers to the master if needed
121  virtual void Merge(TVirtualMCApplication* /*localMCApplication*/) {}
122 
123 private:
124  // static data members
125 #if !defined(__CINT__)
126  static TMCThreadLocal TVirtualMCApplication* fgInstance; ///< Singleton instance
127 #else
128  static TVirtualMCApplication* fgInstance; ///< Singleton instance
129 #endif
130 
131  ClassDef(TVirtualMCApplication,1) //Interface to MonteCarlo application
132 };
133 
134 inline void TVirtualMCApplication::Field(const Double_t* /*x*/, Double_t* b) const {
135  // No magnetic field
136  b[0] = 0; b[1] = 0; b[2] = 0;
137 }
138 
139 #endif //ROOT_TVirtualMCApplication
140 
static TMCThreadLocal TVirtualMCApplication * fgInstance
Singleton instance.
virtual void BeginEvent()=0
Define actions at the beginning of the event.
virtual void ConstructOpGeometry()
Define parameters for optical processes (optional)
virtual void ConstructGeometry()=0
Construct user geometry.
virtual void PreTrack()=0
Define actions at the beginning of each track.
bool Bool_t
Definition: RtypesCore.h:59
virtual void Field(const Double_t *x, Double_t *b) const
Calculate user field b at point x.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual ~TVirtualMCApplication()
Destructor.
virtual TVirtualMCApplication * CloneForWorker() const
Clone MC application on worker.
virtual void PostTrack()=0
Define actions at the end of each track.
virtual void Merge(TVirtualMCApplication *)
Merge the data accumulated on workers to the master if needed.
virtual void Stepping()=0
Define action at each step.
virtual Double_t TrackingRmax() const
Define maximum radius for tracking (optional)
virtual void FinishRunOnWorker()
Define actions at the end of the worker run if needed.
virtual void FinishPrimary()=0
Define actions at the end of the primary track.
virtual void InitForWorker() const
Const Initialize MC application on worker - now deprecated Use new non-const InitOnWorker() instead...
virtual void BeginRunOnWorker()
Define actions at the beginning of the worker run if needed.
virtual Double_t TrackingZmax() const
Define maximum z for tracking (optional)
Interface to a user Monte Carlo application.
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define TMCThreadLocal
Definition: TMCtls.h:57
double Double_t
Definition: RtypesCore.h:55
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 GeaneStepping()
Define action at each step for Geane.
virtual void InitGeometry()=0
Initialize geometry (Usually used to define sensitive volumes IDs)
virtual void InitOnWorker()
Initialize MC application on worker.
virtual void GeneratePrimaries()=0
Generate primary particles.
virtual void BeginWorkerRun() const
Const Define actions at the beginning of the worker run if needed - now deprecated Use new non-const ...
virtual Bool_t MisalignGeometry()
Misalign user geometry (optional)
virtual void FinishEvent()=0
Define actions at the end of the event.
static TVirtualMCApplication * Instance()
Static access method.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual void AddIons()
Add user defined ions (optional)
virtual void BeginPrimary()=0
Define actions at the beginning of the primary track.
virtual void AddParticles()
Add user defined particles (optional)
TVirtualMCApplication()
Default constructor.