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

Contents of /PamCAL/PamVMC/src/PamVMCApplication.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Mon Nov 12 10:10:17 2007 UTC (17 years, 1 month ago) by nikolas
Branch: MAIN
CVS Tags: HEAD
More basic files added

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/field_param-0/";
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