Implementation of the TVirtualMCApplication.
More...
#include <Ex02MCApplication.h>
Implementation of the TVirtualMCApplication.
- Date
- 21/04/2002
- Author
- I. Hrivnacova; IPN, Orsay
Definition at line 37 of file Ex02MCApplication.h.
◆ Ex02MCApplication() [1/3]
Ex02MCApplication::Ex02MCApplication |
( |
const char * | name, |
|
|
const char * | title ) |
Standard constructor
- Parameters
-
name | The MC application name |
title | The MC application description |
Definition at line 39 of file Ex02MCApplication.cxx.
40 : TVirtualMCApplication(name, title),
47{
48
49
50
51
52
53
54
55
56
57 fTrackerSD =
new Ex02TrackerSD(
"Tracker Chamber");
58
59 fStack =
new Ex02MCStack(100);
60
61 fMagField =
new Ex02MagField(20., 0., 0.);
62
63
64}
TVirtualMagField * fMagField
Magnetic field.
Bool_t fOldGeometry
Option for geometry definition.
TMCRootManager * fRootManager
Root manager.
Ex02MCStack * fStack
VMC stack.
Ex02DetectorConstruction fDetConstruction
Dector construction.
Ex02TrackerSD * fTrackerSD
Tracker SD.
◆ Ex02MCApplication() [2/3]
Ex02MCApplication::Ex02MCApplication |
( |
| ) |
|
Default constructor
Definition at line 94 of file Ex02MCApplication.cxx.
95 : TVirtualMCApplication(),
102{
103
104}
◆ ~Ex02MCApplication()
Ex02MCApplication::~Ex02MCApplication |
( |
| ) |
|
|
virtual |
◆ Ex02MCApplication() [3/3]
Copy constructor (for clonig on worker thread in MT mode).
- Parameters
-
origin | The source object (on master). |
Definition at line 67 of file Ex02MCApplication.cxx.
68 : TVirtualMCApplication(origin.GetName(), origin.GetTitle()),
75{
76
77
78
79
80
81
82
83
85
86 fStack =
new Ex02MCStack(100);
87
88 fMagField =
new Ex02MagField(20., 0., 0.);
89
90
91}
◆ InitMC()
void Ex02MCApplication::InitMC |
( |
const char * | setup | ) |
|
Initialize MC from Config.C macro The selection of the concrete MC is done in the macro.
- Parameters
-
setup | The name of the configuration macro |
Definition at line 141 of file Ex02MCApplication.cxx.
142{
143
144
145
146
147 if (TString(setup) != "") {
148 gROOT->LoadMacro(setup);
149 gInterpreter->ProcessLine("Config()");
150 if (!gMC) {
151 Fatal(
152 "InitMC", "Processing Config() has failed. (No MC is instantiated.)");
153 }
154 }
155
156
157#if ROOT_VERSION_CODE >= 336402
158
159 if (!gMC->IsMT()) {
160 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
161
162 }
163#else
164
165 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kWrite);
166
167#endif
168
169
172
173
174 gMC->Init();
175 gMC->BuildPhysics();
176
178}
void RegisterStack() const
◆ RunMC()
void Ex02MCApplication::RunMC |
( |
Int_t | nofEvents | ) |
|
Run MC.
- Parameters
-
nofEvents | Number of events to be processed |
Definition at line 181 of file Ex02MCApplication.cxx.
182{
183
184
185
186 gMC->ProcessRun(nofEvents);
188}
◆ FinishRun()
void Ex02MCApplication::FinishRun |
( |
| ) |
|
◆ CloneForWorker()
◆ InitOnWorker()
void Ex02MCApplication::InitOnWorker |
( |
| ) |
|
|
virtual |
◆ FinishRunOnWorker()
void Ex02MCApplication::FinishRunOnWorker |
( |
| ) |
|
|
virtual |
◆ ConstructGeometry()
void Ex02MCApplication::ConstructGeometry |
( |
| ) |
|
|
virtual |
Construct geometry using detector contruction class. The detector contruction class is using TGeo functions or TVirtualMC functions (if oldGeometry is selected)
Definition at line 236 of file Ex02MCApplication.cxx.
237{
238
239
240
241
242
243
245 cerr << "Selected MC does not support TGeo geometry" << endl;
246 cerr << "Exiting program" << endl;
247 exit(1);
248 }
249
251 cout << "Geometry will be defined via TGeo" << endl;
254 }
255 else {
256 cout << "Geometry will be defined via VMC" << endl;
257 Ex02DetectorConstructionOld detConstructionOld;
260 }
261}
void ConstructMaterials()
◆ InitGeometry()
void Ex02MCApplication::InitGeometry |
( |
| ) |
|
|
virtual |
◆ GeneratePrimaries()
void Ex02MCApplication::GeneratePrimaries |
( |
| ) |
|
|
virtual |
Fill the user stack (derived from TVirtualMCStack) with primary particles.
Definition at line 272 of file Ex02MCApplication.cxx.
273{
274
275
276
277 Int_t ntr;
278
279
280 Int_t toBeDone = 1;
281
282
283
284 Int_t pdg = kProton;
285
286
287 Double_t polx = 0.;
288 Double_t poly = 0.;
289 Double_t polz = 0.;
290
291
292 Double_t vx = 0.;
293 Double_t vy = 0.;
295 Double_t tof = 0.;
296
297
298 Double_t kinEnergy = 3.0;
299 Double_t mass = 0.9382723;
300 Double_t e = mass + kinEnergy;
301
302
303 Double_t px, py, pz;
304 px = 0.;
305 py = 0.;
306 pz = sqrt(e * e - mass * mass);
307
308
309 fStack->PushTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, tof, polx,
310 poly, polz, kPPrimary, ntr, 1., 0);
311}
◆ BeginEvent()
void Ex02MCApplication::BeginEvent |
( |
| ) |
|
|
virtual |
User actions at beginning of event. Nothing to be done this example
Definition at line 314 of file Ex02MCApplication.cxx.
315{
316
317
318
319 fStack->SetObjectNumber();
320}
◆ BeginPrimary()
void Ex02MCApplication::BeginPrimary |
( |
| ) |
|
|
virtual |
User actions at beginning of a primary track. Nothing to be done this example
Definition at line 323 of file Ex02MCApplication.cxx.
◆ PreTrack()
void Ex02MCApplication::PreTrack |
( |
| ) |
|
|
virtual |
User actions at beginning of each track. Nothing to be done this example
Definition at line 330 of file Ex02MCApplication.cxx.
◆ Stepping()
void Ex02MCApplication::Stepping |
( |
| ) |
|
|
virtual |
◆ PostTrack()
void Ex02MCApplication::PostTrack |
( |
| ) |
|
|
virtual |
◆ FinishPrimary()
void Ex02MCApplication::FinishPrimary |
( |
| ) |
|
|
virtual |
User actions after finishing of a primary track. Nothing to be done this example
Definition at line 352 of file Ex02MCApplication.cxx.
◆ FinishEvent()
void Ex02MCApplication::FinishEvent |
( |
| ) |
|
|
virtual |
User actions after finishing of an event Nothing to be done this example
Definition at line 359 of file Ex02MCApplication.cxx.
360{
361
362
363
364
365
366
367 if (gGeoManager && gGeoManager->GetListOfTracks() &&
368 gGeoManager->GetTrack(0) &&
369 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
370
371 gGeoManager->SetVisOption(0);
372 gGeoManager->SetTopVisible();
373 gGeoManager->DrawTracks("/*");
374 }
375
377
379
382}
◆ ReadEvent()
void Ex02MCApplication::ReadEvent |
( |
Int_t | i | ) |
|
Read i -th event and prints hits.
- Parameters
-
i | The number of event to be read |
Definition at line 385 of file Ex02MCApplication.cxx.
386{
387
388
389
391 fRootManager =
new TMCRootManager(GetName(), TMCRootManager::kRead);
392 }
393
397
400}
◆ SetOldGeometry()
void Ex02MCApplication::SetOldGeometry |
( |
Bool_t | oldGeometry = kTRUE | ) |
|
|
inline |
Switch on/off the old geometry definition (via VMC functions)
- Parameters
-
oldGeometry | If true, geometry definition via VMC functions |
Definition at line 89 of file Ex02MCApplication.h.
◆ RegisterStack()
void Ex02MCApplication::RegisterStack |
( |
| ) |
const |
|
private |
◆ fRootManager
TMCRootManager* Ex02MCApplication::fRootManager |
|
mutableprivate |
◆ fStack
◆ fDetConstruction
◆ fTrackerSD
◆ fMagField
◆ fOldGeometry
Bool_t Ex02MCApplication::fOldGeometry |
|
private |
The documentation for this class was generated from the following files: