/[PAMELA software]/PamVMC/src/PamVMCApplication.cxx~
ViewVC logotype

Contents of /PamVMC/src/PamVMCApplication.cxx~

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Fri Jun 12 18:39:29 2009 UTC (16 years, 6 months ago) by pam-rm2
Branch: MAIN
Changes since 1.1: +0 -0 lines
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

1 // $Id: PamVMCApplication.cxx,v 1.0 2007/06/01
2 //
3 // Geant4 ExampleN06 adapted to Virtual Monte Carlo
4 #include <cstdlib>
5 #include <string>
6 #include <TROOT.h>
7 #include <TInterpreter.h>
8 #include <TVirtualMC.h>
9 #include <Riostream.h>
10 #include <TGeoManager.h>
11 #include <TVirtualGeoTrack.h>
12
13 #include "PamVMCApplication.h"
14 #include "PamVMCStack.h"
15 #include "PamVMCDetectorConstruction.h"
16 #include "PamVMCPrimaryGenerator.h"
17
18 ClassImp(PamVMCApplication)
19
20 PamVMCApplication::PamVMCApplication(const char *name, const char *title)
21 : TVirtualMCApplication(name,title),
22 fEventNo(0),
23 fVerbose(0),
24 fStack(0),
25 fDetConstruction(0),
26 fPrimaryGenerator(0)
27 {
28 // Standard constructor
29
30 // Create a user stack
31 fStack = new PamVMCStack(10000);
32
33 // Create detector construction
34 fDetConstruction = new PamVMCDetectorConstruction();
35
36 // Create a primary generator
37 fPrimaryGenerator = new PamVMCPrimaryGenerator(fStack);
38 #ifdef PAMFIELD
39 // Load the PAMELA magnetic field
40
41 std::string pamcal=getenv("PAM_CALIB"); pamcal+="/trk-param/";
42 std::cout << "PAMELA env: " << pamcal << std::endl;
43 pamfield.LoadField(pamcal.c_str());
44 #endif
45 }
46
47
48 PamVMCApplication::PamVMCApplication()
49 : TVirtualMCApplication(),
50 fEventNo(0),
51 fVerbose(0),
52 fStack(0),
53 fDetConstruction(0),
54 fPrimaryGenerator(0)
55 {
56 // Default constructor
57 }
58
59 PamVMCApplication::~PamVMCApplication()
60 {
61 // Destructor
62
63 delete fStack;
64 delete fDetConstruction;
65 delete fPrimaryGenerator;
66 delete gMC;
67 gMC = 0;
68 }
69
70 //
71 // public methods
72 //
73
74 void PamVMCApplication::InitMC(const char* setup)
75 {
76 // Initialize MC.
77
78 fVerbose.InitMC();
79
80 gROOT->LoadMacro(setup);
81 gInterpreter->ProcessLine("Config()");
82 gMC->SetStack(fStack);
83 gMC->Init();
84 gMC->BuildPhysics();
85 }
86
87 void PamVMCApplication::RunMC(Int_t nofEvents)
88 {
89 // MC run.
90
91 fVerbose.RunMC(nofEvents);
92
93 gMC->ProcessRun(nofEvents);
94
95 //// fVerbose.FinishRun();
96 }
97
98 void PamVMCApplication::ConstructGeometry()
99 {
100 // Construct geometry using detector contruction class
101
102 fVerbose.ConstructGeometry();
103 fDetConstruction->ConstructGeometry();
104
105 }
106
107 void PamVMCApplication::InitGeometry()
108 {
109 // Initialize geometry
110
111 fVerbose.InitGeometry();
112 }
113
114
115 void PamVMCApplication::GeneratePrimaries()
116 {
117 // Fill the user stack (derived from TVirtualMCStack) with primary particles.
118
119 ///// fVerbose.GeneratePrimaries();
120
121 fPrimaryGenerator->GeneratePrimaries();
122 }
123
124 void PamVMCApplication::BeginEvent()
125 {
126 // User actions at beginning of event
127
128 ///// fVerbose.BeginEvent();
129
130 fEventNo++;
131 }
132
133 void PamVMCApplication::BeginPrimary()
134 {
135 // User actions at beginning of a primary track
136
137 //// fVerbose.BeginPrimary();
138 }
139
140 void PamVMCApplication::PreTrack()
141 {
142 // User actions at beginning of each track
143
144 ////// fVerbose.PreTrack();
145
146 }
147
148 void PamVMCApplication::Stepping()
149 {
150 // User actions at each step
151
152 ////// fVerbose.Stepping();
153 }
154
155 void PamVMCApplication::PostTrack()
156 {
157 // User actions after finishing of each track
158
159
160 ///// fVerbose.PostTrack();
161 }
162
163 void PamVMCApplication::FinishPrimary()
164 {
165 // User actions after finishing of a primary track
166
167 ///// fVerbose.FinishPrimary();
168 }
169
170 void PamVMCApplication::FinishEvent()
171 {
172 // User actions after finishing of an event
173
174
175 /////fVerbose.FinishEvent();
176
177
178
179 fStack->Reset();
180 }
181
182 void PamVMCApplication::Field(const Double_t* x, Double_t* b) const
183 {
184 // Uniform magnetic field
185
186 #ifdef PAMFIELD
187 b[0] = pamfield.GetBX((float *)x);
188 b[1] = pamfield.GetBY((float *)x);
189 b[2] = pamfield.GetBZ((float *)x);
190 #else
191 for (Int_t i=0; i<3; i++) b[i] = 0.0;
192 #endif
193 }

  ViewVC Help
Powered by ViewVC 1.1.23