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