Logo ROOT   6.14/05
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  /// Define sensitive detectors (optional)
55  virtual void ConstructSensitiveDetectors() {}
56 
57  /// Initialize geometry
58  /// (Usually used to define sensitive volumes IDs)
59  virtual void InitGeometry() = 0;
60 
61  /// Add user defined particles (optional)
62  virtual void AddParticles() {}
63 
64  /// Add user defined ions (optional)
65  virtual void AddIons() {}
66 
67  /// Generate primary particles
68  virtual void GeneratePrimaries() = 0;
69 
70  /// Define actions at the beginning of the event
71  virtual void BeginEvent() = 0;
72 
73  /// Define actions at the beginning of the primary track
74  virtual void BeginPrimary() = 0;
75 
76  /// Define actions at the beginning of each track
77  virtual void PreTrack() = 0;
78 
79  /// Define action at each step
80  virtual void Stepping() = 0;
81 
82  /// Define actions at the end of each track
83  virtual void PostTrack() = 0;
84 
85  /// Define actions at the end of the primary track
86  virtual void FinishPrimary() = 0;
87 
88  /// Define actions at the end of the event
89  virtual void FinishEvent() = 0;
90 
91  /// Define maximum radius for tracking (optional)
92  virtual Double_t TrackingRmax() const { return DBL_MAX; }
93 
94  /// Define maximum z for tracking (optional)
95  virtual Double_t TrackingZmax() const { return DBL_MAX; }
96 
97  /// Calculate user field \a b at point \a x
98  virtual void Field(const Double_t* x, Double_t* b) const;
99 
100  /// Define action at each step for Geane
101  virtual void GeaneStepping() {;}
102 
103  // Functions for multi-threading applications
104  /// Clone MC application on worker
105  virtual TVirtualMCApplication* CloneForWorker() const { return 0;}
106 
107  /// Const Initialize MC application on worker - now deprecated
108  /// Use new non-const InitOnWorker() instead
109  virtual void InitForWorker() const {}
110  /// Const Define actions at the beginning of the worker run if needed - now deprecated
111  /// Use new non-const BeginRunOnWorker() instead
112  virtual void BeginWorkerRun() const {}
113  /// Const Define actions at the end of the worker run if needed - now deprecated
114  /// Use new non-const FinishRunOnWorker() instead
115  virtual void FinishWorkerRun() const {}
116 
117  /// Initialize MC application on worker
118  virtual void InitOnWorker() {}
119  /// Define actions at the beginning of the worker run if needed
120  virtual void BeginRunOnWorker() {}
121  /// Define actions at the end of the worker run if needed
122  virtual void FinishRunOnWorker() {}
123  /// Merge the data accumulated on workers to the master if needed
124  virtual void Merge(TVirtualMCApplication* /*localMCApplication*/) {}
125 
126 private:
127  // static data members
128 #if !defined(__CINT__)
129  static TMCThreadLocal TVirtualMCApplication* fgInstance; ///< Singleton instance
130 #else
131  static TVirtualMCApplication* fgInstance; ///< Singleton instance
132 #endif
133 
134  ClassDef(TVirtualMCApplication,1) //Interface to MonteCarlo application
135 };
136 
137 inline void TVirtualMCApplication::Field(const Double_t* /*x*/, Double_t* b) const {
138  // No magnetic field
139  b[0] = 0; b[1] = 0; b[2] = 0;
140 }
141 
142 #endif //ROOT_TVirtualMCApplication
143 
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:320
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:88
#define TMCThreadLocal
Definition: TMCtls.h:80
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 ConstructSensitiveDetectors()
Define sensitive detectors (optional)
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.
char name[80]
Definition: TGX11.cxx:109