VMC Examples Version 6.8
Loading...
Searching...
No Matches
Ex03cMCApplication Class Reference

Implementation of the TVirtualMCApplication. More...

#include <Ex03cMCApplication.h>

Inheritance diagram for Ex03cMCApplication:

Public Member Functions

 Ex03cMCApplication (const char *name, const char *title, Bool_t isMulti=kFALSE, Bool_t splitSimulation=kFALSE)
 Ex03cMCApplication ()
virtual ~Ex03cMCApplication ()
void InitMC (const char *setup)
void InitMC (std::initializer_list< const char * > setupMacros)
void InitMC ()
void RunMC (Int_t nofEvents)
void FinishRun ()
void ReadEvent (Int_t i)
virtual TVirtualMCApplicationCloneForWorker () const
virtual void InitOnWorker ()
virtual void FinishRunOnWorker ()
virtual void ConstructGeometry ()
virtual void InitGeometry ()
virtual void AddParticles ()
virtual void AddIons ()
virtual void GeneratePrimaries ()
virtual void BeginEvent ()
virtual void BeginPrimary ()
virtual void PreTrack ()
virtual void Stepping ()
virtual void PostTrack ()
virtual void FinishPrimary ()
virtual void FinishEvent ()
void SetPrintModulo (Int_t value)
void SetVerboseLevel (Int_t verboseLevel)
void SetControls (Bool_t isConstrols)
void SetField (Double_t bz)
void SetDebug (Int_t debug)
 Set debug option for multiple run.
Ex03cDetectorConstructionGetDetectorConstruction () const
Ex03cCalorimeterSDGetCalorimeterSD () const
Ex03PrimaryGeneratorGetPrimaryGenerator () const
void SetOldGeometry (Bool_t oldGeometry=kTRUE)

Private Member Functions

 Ex03cMCApplication (const Ex03cMCApplication &origin)
void RegisterStack () const

Private Attributes

TMCRootManager * fRootManager
 Root manager.
Int_t fPrintModulo
 The event modulus number to be printed.
Int_t fEventNo
 Event counter.
TMCVerbose fVerbose
 VMC verbose helper.
Ex03cMCStackfStack
 VMC stack.
Ex03cDetectorConstructionfDetConstruction
 Dector construction.
Ex03cCalorimeterSDfCalorimeterSD
 Calorimeter SD.
Ex03PrimaryGeneratorfPrimaryGenerator
 Primary generator.
TGeoUniformMagField * fMagField
 Magnetic field.
Bool_t fOldGeometry
 Option for geometry definition.
Bool_t fIsControls
 Option to activate special controls.
Bool_t fIsMaster
 If is on master thread.
Bool_t fIsMultiRun
 Flag if having multiple engines.
Bool_t fSplitSimulation
 Split geometry given user criteria.
Int_t fG3Id
 engine ID of Geant3
Int_t fG4Id
 engine ID of Geant4
Int_t fDebug
 debug option for multiple run

Detailed Description

Implementation of the TVirtualMCApplication.

A variant of the Ex03MCApplication class updated for multiple engine runs.

Date
21/08/2019
Author
Benedikt Volkel, CERN

Definition at line 45 of file Ex03cMCApplication.h.

Constructor & Destructor Documentation

◆ Ex03cMCApplication() [1/3]

Ex03cMCApplication::Ex03cMCApplication ( const char * name,
const char * title,
Bool_t isMulti = kFALSE,
Bool_t splitSimulation = kFALSE )

Standard constructor

Parameters
nameThe MC application name
titleThe MC application description

Definition at line 48 of file Ex03cMCApplication.cxx.

50 : TVirtualMCApplication(name, title),
51 fRootManager(0),
52 fPrintModulo(1),
53 fEventNo(0),
54 fVerbose(0),
55 fStack(0),
59 fMagField(0),
60 fOldGeometry(kFALSE),
61 fIsControls(kFALSE),
62 fIsMaster(kTRUE),
63 fIsMultiRun(isMulti),
64 fSplitSimulation(splitSimulation),
65 fG3Id(-1),
66 fG4Id(-1),
67 fDebug(0)
68{
69 /// Standard constructor
70 /// \param name The MC application name
71 /// \param title The MC application description
72
73 if (splitSimulation && !isMulti) {
74 Fatal("Ex03cMCApplication",
75 "Cannot split simulation between engines without \"isMulti\" being "
76 "switched on");
77 }
78
79 cout << "--------------------------------------------------------------"
80 << endl;
81 cout << " VMC Example E03c: new version with multiple engines" << endl;
82 cout << "--------------------------------------------------------------"
83 << endl;
84
85 // Create a user stack
86 fStack = new Ex03cMCStack(1000);
87
88 // Create detector construction
89 fDetConstruction = new Ex03cDetectorConstruction();
90
91 // Create a calorimeter SD
92 fCalorimeterSD = new Ex03cCalorimeterSD("Calorimeter", fDetConstruction);
93
94 // Create a primary generator
95 fPrimaryGenerator = new Ex03PrimaryGenerator(fStack);
96
97 // Constant magnetic field (in kiloGauss)
98 fMagField = new TGeoUniformMagField();
99
100 if (isMulti) {
101 RequestMCManager();
102 fMCManager->SetUserStack(fStack);
103 }
104}
TGeoUniformMagField * fMagField
Magnetic field.
TMCRootManager * fRootManager
Root manager.
Ex03PrimaryGenerator * fPrimaryGenerator
Primary generator.
Ex03cDetectorConstruction * fDetConstruction
Dector construction.
Int_t fG3Id
engine ID of Geant3
TMCVerbose fVerbose
VMC verbose helper.
Ex03cCalorimeterSD * fCalorimeterSD
Calorimeter SD.
Bool_t fOldGeometry
Option for geometry definition.
Bool_t fIsControls
Option to activate special controls.
Int_t fPrintModulo
The event modulus number to be printed.
Bool_t fIsMultiRun
Flag if having multiple engines.
Bool_t fIsMaster
If is on master thread.
Bool_t fSplitSimulation
Split geometry given user criteria.
Ex03cMCStack * fStack
VMC stack.
Int_t fEventNo
Event counter.
Int_t fG4Id
engine ID of Geant4
Int_t fDebug
debug option for multiple run

◆ Ex03cMCApplication() [2/3]

Ex03cMCApplication::Ex03cMCApplication ( )

Default constructor

Definition at line 147 of file Ex03cMCApplication.cxx.

148 : TVirtualMCApplication(),
149 fRootManager(0),
150 fPrintModulo(1),
151 fEventNo(0),
152 fStack(0),
156 fMagField(0),
157 fOldGeometry(kFALSE),
158 fIsControls(kFALSE),
159 fIsMaster(kTRUE),
160 fIsMultiRun(kFALSE),
161 fSplitSimulation(kFALSE),
162 fG3Id(-1),
163 fG4Id(-1),
164 fDebug(0)
165{
166 /// Default constructor
167}

◆ ~Ex03cMCApplication()

Ex03cMCApplication::~Ex03cMCApplication ( )
virtual

Destructor

Definition at line 170 of file Ex03cMCApplication.cxx.

171{
172 /// Destructor
173
174 // cout << "Ex03cMCApplication::~Ex03cMCApplication " << this << endl;
175
176 delete fRootManager;
177 delete fStack;
178 if (fIsMaster) delete fDetConstruction;
179 delete fCalorimeterSD;
180 delete fPrimaryGenerator;
181 delete fMagField;
182 if (!fIsMultiRun) {
183 delete fMC;
184 }
185
186 // cout << "Done Ex03cMCApplication::~Ex03cMCApplication " << this << endl;
187}

◆ Ex03cMCApplication() [3/3]

Ex03cMCApplication::Ex03cMCApplication ( const Ex03cMCApplication & origin)
private

Copy constructor for cloning application on workers (in multithreading mode)

Parameters
originThe source MC application

Definition at line 107 of file Ex03cMCApplication.cxx.

108 : TVirtualMCApplication(origin.GetName(), origin.GetTitle()),
109 fRootManager(0),
111 fEventNo(0),
112 fVerbose(origin.fVerbose),
113 fStack(0),
117 fMagField(0),
119 fIsControls(origin.fIsControls),
120 fIsMaster(kFALSE),
121 fIsMultiRun(origin.fIsMultiRun),
123 fG3Id(origin.fG3Id),
124 fG4Id(origin.fG4Id),
125 fDebug(origin.fDebug)
126{
127 /// Copy constructor for cloning application on workers (in multithreading
128 /// mode) \param origin The source MC application
129
130 // Create new user stack
131 fStack = new Ex03cMCStack(1000);
132
133 // Create a calorimeter SD
135 new Ex03cCalorimeterSD(*(origin.fCalorimeterSD), fDetConstruction);
136
137 // Create a primary generator
139 new Ex03PrimaryGenerator(*(origin.fPrimaryGenerator), fStack);
140
141 // Constant magnetic field (in kiloGauss)
142 fMagField = new TGeoUniformMagField(origin.fMagField->GetFieldValue()[0],
143 origin.fMagField->GetFieldValue()[1], origin.fMagField->GetFieldValue()[2]);
144}

Member Function Documentation

◆ InitMC() [1/3]

void Ex03cMCApplication::InitMC ( const char * setup)

Initialize MC. The selection (and creation) of the concrete MC is done in the macro. If no macro is provided, the MC must be created before calling this function.

Parameters
setupThe name of the configuration macro.

Definition at line 209 of file Ex03cMCApplication.cxx.

210{
211 /// Initialize MC.
212 /// The selection (and creation) of the concrete MC is done in the macro.
213 /// If no macro is provided, the MC must be created before calling this
214 /// function. \param setup The name of the configuration macro.
215
216 fVerbose.InitMC();
217
218 if (TString(setup) != "") {
219 gROOT->LoadMacro(setup);
220 gInterpreter->ProcessLine("Config()");
221 if (!fMC) {
222 Fatal(
223 "InitMC", "Processing Config() has failed. (No MC is instantiated.)");
224 }
225 }
226
227// MT support available from root v 5.34/18
228#if ROOT_VERSION_CODE >= 336402
229 // Create Root manager
230 if (!fMC->IsMT()) {
231 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kWrite);
232 // fRootManager->SetDebug(true);
233 }
234#else
235 // Create Root manager
236 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kWrite);
237// fRootManager->SetDebug(true);
238#endif
239
240 fMC->SetStack(fStack);
241 fMC->SetRootGeometry();
242 fMC->SetMagField(fMagField);
243 fMC->Init();
244 fMC->BuildPhysics();
245
247
248 if (fDebug > 0) {
249 Info("InitMC", "Single run initialised");
250 }
251}

◆ InitMC() [2/3]

void Ex03cMCApplication::InitMC ( std::initializer_list< const char * > setupMacros)

Initialize MC. New function for initialization with multiple engines.

Parameters
setupMacrosThe names of the configuration macros.

Definition at line 254 of file Ex03cMCApplication.cxx.

255{
256 /// Initialize MC.
257 /// New function for initialization with multiple engines.
258 /// \param setupMacros The names of the configuration macros.
259
260 fVerbose.InitMC();
261
262 if (!fIsMultiRun) {
263 Fatal("InitMC",
264 "Initialisation of multiple engines not supported in single run");
265 }
266
267 if (setupMacros.size() > 0) {
268 for (const char* setup : setupMacros) {
269 gROOT->LoadMacro(setup);
270 gInterpreter->ProcessLine("Config()");
271 if (!fMC) {
272 Fatal(
273 "InitMC", "Processing Config() has failed. (No MC is instantiated.)");
274 }
275 // gInterpreter->UnloadAllSharedLibraryMaps();
276 gInterpreter->UnloadFile(setup);
277 }
278 }
279
280 InitMC();
281}

◆ InitMC() [3/3]

void Ex03cMCApplication::InitMC ( )

Initialize MC. New function for initialization with multiple engines. The MCs must be created before calling this function.

Definition at line 284 of file Ex03cMCApplication.cxx.

285{
286 /// Initialize MC.
287 /// New function for initialization with multiple engines.
288 /// The MCs must be created before calling this function.
289
290 if (!fIsMultiRun) {
291 Fatal("InitMC",
292 "Initialisation of multiple engines not supported in single run");
293 }
294
295// MT support available from root v 5.34/18
296#if ROOT_VERSION_CODE >= 336402
297 // Create Root manager
298 if (!fMC->IsMT()) {
299 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kWrite);
300 // fRootManager->SetDebug(true);
301 }
302#else
303 // Create Root manager
304 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kWrite);
305// fRootManager->SetDebug(true);
306#endif
307
308 fMCManager->Init([this](TVirtualMC* mc) {
309 mc->SetRootGeometry();
310 mc->SetMagField(this->fMagField);
311 mc->Init();
312 mc->BuildPhysics();
313 });
315
316 fG3Id = fMCManager->GetEngineId("TGeant3TGeo");
317 fG4Id = fMCManager->GetEngineId("TGeant4");
318 if (fDebug > 0) {
319 Info("InitMC", "Multi run initialised");
320 std::cout << "Engine IDs\n"
321 << "TGeant3TGeo: " << fG3Id << "\n"
322 << "TGeant4: " << fG4Id << std::endl;
323 }
324}

◆ RunMC()

void Ex03cMCApplication::RunMC ( Int_t nofEvents)

Run MC.

Parameters
nofEventsNumber of events to be processed

Definition at line 327 of file Ex03cMCApplication.cxx.

328{
329 /// Run MC.
330 /// \param nofEvents Number of events to be processed
331
332 fVerbose.RunMC(nofEvents);
333
334 // Prepare a timer
335 TTimer timer;
336
337 if (!fIsMultiRun) {
338 if (fDebug > 0) {
339 Info("RunMC", "Start single run");
340 std::cout << "Simulation entirely done with engine " << fMC->GetName()
341 << std::endl;
342 timer.Start();
343 }
344 fMC->ProcessRun(nofEvents);
345 }
346 else {
347 if (fDebug > 0) {
348 Info("RunMC", "Start multi run");
349 if (fSplitSimulation) {
350 std::cout << "GAPX simulated with engine "
351 << fMCManager->GetEngine(0)->GetName() << "\n"
352 << "ABSO simulated with engine "
353 << fMCManager->GetEngine(1)->GetName() << std::endl;
354 }
355 else {
356 std::cout << "Simulation entirely done with engine "
357 << fMCManager->GetCurrentEngine()->GetName() << std::endl;
358 }
359 timer.Start();
360 }
361 fMCManager->Run(nofEvents);
362 }
363 if (fDebug > 0) {
364 timer.Stop();
365 Info("RunMC", "Transport finished.");
366 timer.Print();
367 }
368 FinishRun();
369}

◆ FinishRun()

void Ex03cMCApplication::FinishRun ( )

Finish MC run.

Definition at line 372 of file Ex03cMCApplication.cxx.

373{
374 /// Finish MC run.
375
376 fVerbose.FinishRun();
377 // cout << "Ex03cMCApplication::FinishRun: " << endl;
378 if (fRootManager) {
379 fRootManager->WriteAll();
380 fRootManager->Close();
381 }
382}

◆ ReadEvent()

void Ex03cMCApplication::ReadEvent ( Int_t i)

Read i -th event and prints hits.

Parameters
iThe number of event to be read

Definition at line 419 of file Ex03cMCApplication.cxx.

420{
421 /// Read \em i -th event and prints hits.
422 /// \param i The number of event to be read
423
424 if ( ! fRootManager ) {
425 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kRead);
426 }
427
428 fCalorimeterSD->Register();
430 fRootManager->ReadEvent(i);
431}

◆ CloneForWorker()

TVirtualMCApplication * Ex03cMCApplication::CloneForWorker ( ) const
virtual

Definition at line 385 of file Ex03cMCApplication.cxx.

386{
387 return new Ex03cMCApplication(*this);
388}

◆ InitOnWorker()

void Ex03cMCApplication::InitOnWorker ( )
virtual

Definition at line 391 of file Ex03cMCApplication.cxx.

392{
393 // cout << "Ex03cMCApplication::InitForWorker " << this << endl;
394
395 // Create Root manager
396 Int_t threadRank = 1;
397 // The real thread rank will be set in MCRootManager
398 fRootManager = new TMCRootManager(GetName(), TMCRootManager::kWrite, threadRank);
399 // fRootManager->SetDebug(true);
400
401 // Set data to MC
402 fMC->SetStack(fStack);
403 fMC->SetMagField(fMagField);
404
406}

◆ FinishRunOnWorker()

void Ex03cMCApplication::FinishRunOnWorker ( )
virtual

Definition at line 409 of file Ex03cMCApplication.cxx.

410{
411 // cout << "Ex03cMCApplication::FinishWorkerRun: " << endl;
412 if (fRootManager) {
413 fRootManager->WriteAll();
414 fRootManager->Close();
415 }
416}

◆ ConstructGeometry()

void Ex03cMCApplication::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 434 of file Ex03cMCApplication.cxx.

435{
436 /// Construct geometry using detector contruction class.
437 /// The detector contruction class is using TGeo functions or
438 /// TVirtualMC functions (if oldGeometry is selected)
439
440 fVerbose.ConstructGeometry();
441
442 if (fOldGeometry) {
443 Fatal("ConstructGeometry", "Cannot run with old geomtry");
444 }
445 fDetConstruction->ConstructMaterials();
446 fDetConstruction->ConstructGeometry();
447 // TGeoManager::Import("geometry.root");
448 // fMC->SetRootGeometry();
449}

◆ InitGeometry()

void Ex03cMCApplication::InitGeometry ( )
virtual

Initialize geometry

Definition at line 452 of file Ex03cMCApplication.cxx.

453{
454 /// Initialize geometry
455
456 fVerbose.InitGeometry();
457
458 fDetConstruction->SetCuts();
459
460 if (fIsControls) fDetConstruction->SetControls();
461
462 fCalorimeterSD->Initialize();
463}

◆ AddParticles()

void Ex03cMCApplication::AddParticles ( )
virtual

Example of user defined particle with user defined decay mode

Definition at line 466 of file Ex03cMCApplication.cxx.

467{
468 /// Example of user defined particle with user defined decay mode
469
470 fVerbose.AddParticles();
471
472 // Define the 2 body phase space decay for He5
473 Int_t mode[6][3];
474 Float_t bratio[6];
475
476 for (Int_t kz = 0; kz < 6; kz++) {
477 bratio[kz] = 0.;
478 mode[kz][0] = 0;
479 mode[kz][1] = 0;
480 mode[kz][2] = 0;
481 }
482 bratio[0] = 100.;
483 mode[0][0] = kNeutron; // neutron (2112)
484 mode[0][1] = 1000020040; // alpha
485
486 // Overwrite a decay mode already defined in MCs
487 // Kaon Short: 310 normally decays in two modes
488 // pi+, pi- 68.61 %
489 // pi0, pi0 31.39 %
490 // and we force only the mode pi0, pi0
491
492 Int_t mode2[6][3];
493 Float_t bratio2[6];
494
495 for (Int_t kz = 0; kz < 6; kz++) {
496 bratio2[kz] = 0.;
497 mode2[kz][0] = 0;
498 mode2[kz][1] = 0;
499 mode2[kz][2] = 0;
500 }
501 bratio2[0] = 100.;
502 mode2[0][0] = kPi0; // pi0 (111)
503 mode2[0][1] = kPi0; // pi0 (111)
504
505 // Define particle
506 fMC->DefineParticle(1000020050, "He5", kPTHadron, 5.03427, 2.0, 0.002, "Ion",
507 0.0, 0, 1, 0, 0, 0, 0, 0, 5, kFALSE);
508 fMC->SetDecayMode(1000020050, bratio, mode);
509 fMC->SetDecayMode(kK0Short, bratio2, mode2);
510}

◆ AddIons()

void Ex03cMCApplication::AddIons ( )
virtual

Example of user defined ion

Definition at line 513 of file Ex03cMCApplication.cxx.

514{
515 /// Example of user defined ion
516
517 fVerbose.AddIons();
518 fMC->DefineIon("MyIon", 34, 70, 12, 0.);
519}

◆ GeneratePrimaries()

void Ex03cMCApplication::GeneratePrimaries ( )
virtual

Fill the user stack (derived from TVirtualMCStack) with primary particles.

Definition at line 522 of file Ex03cMCApplication.cxx.

523{
524 /// Fill the user stack (derived from TVirtualMCStack) with primary particles.
525
526 fVerbose.GeneratePrimaries();
527
528 TVector3 origin(fDetConstruction->GetWorldSizeX(),
529 fDetConstruction->GetCalorSizeYZ(), fDetConstruction->GetCalorSizeYZ());
530
531 fPrimaryGenerator->GeneratePrimaries(origin);
532}

◆ BeginEvent()

void Ex03cMCApplication::BeginEvent ( )
virtual

User actions at beginning of event

Definition at line 535 of file Ex03cMCApplication.cxx.

536{
537 /// User actions at beginning of event
538
539 fVerbose.BeginEvent();
540
541 // Clear TGeo tracks (if filled)
542 if (!fIsMultiRun && TString(fMC->GetName()) == "TGeant3TGeo" &&
543 gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
544 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
545
546 gGeoManager->ClearTracks();
547 // if (gPad) gPad->Clear();
548 }
549
550 fEventNo++;
551 if (fEventNo % fPrintModulo == 0) {
552 cout << "\n---> Begin of event: " << fEventNo << endl;
553 // ??? How to do this in VMC
554 // HepRandom::showEngineStatus();
555 }
556}

◆ BeginPrimary()

void Ex03cMCApplication::BeginPrimary ( )
virtual

User actions at beginning of a primary track. If test for user defined decay is activated, the primary track ID is printed on the screen.

Definition at line 559 of file Ex03cMCApplication.cxx.

560{
561 /// User actions at beginning of a primary track.
562 /// If test for user defined decay is activated,
563 /// the primary track ID is printed on the screen.
564
565 fVerbose.BeginPrimary();
566
567 if (fPrimaryGenerator->GetUserDecay()) {
568 cout << " Primary track ID = " << fStack->GetCurrentTrackNumber() << endl;
569 }
570}

◆ PreTrack()

void Ex03cMCApplication::PreTrack ( )
virtual

User actions at beginning of each track If test for user defined decay is activated, the decay products of the primary track (K0Short) are printed on the screen.

Definition at line 573 of file Ex03cMCApplication.cxx.

574{
575 /// User actions at beginning of each track
576 /// If test for user defined decay is activated,
577 /// the decay products of the primary track (K0Short)
578 /// are printed on the screen.
579
580 fVerbose.PreTrack();
581
582 // print info about K0Short decay products
583 if (fPrimaryGenerator->GetUserDecay()) {
584 Int_t parentID = fStack->GetCurrentParentTrackNumber();
585
586 if (parentID >= 0 &&
587 fStack->GetParticle(parentID)->GetPdgCode() == kK0Short &&
588 fStack->GetCurrentTrack()->GetUniqueID() == kPDecay) {
589 // The production process is saved as TParticle unique ID
590 // via Ex03cMCStack
591
592 cout << " Current track " << fStack->GetCurrentTrack()->GetName()
593 << " is a decay product of Parent ID = "
594 << fStack->GetCurrentParentTrackNumber() << endl;
595 }
596 }
597}

◆ Stepping()

void Ex03cMCApplication::Stepping ( )
virtual

User actions at each step

Definition at line 600 of file Ex03cMCApplication.cxx.

601{
602 /// User actions at each step
603
604 fVerbose.Stepping();
605
606 fCalorimeterSD->ProcessHits();
607
608 TLorentzVector pos;
609 TLorentzVector mom;
610
611 fMC->TrackPosition(pos);
612 fMC->TrackMomentum(mom);
613
614 if (fDebug > 1) {
615 std::cout << "Current engine " << fMC->GetName() << "\n"
616 << "Track ID=" << fStack->GetCurrentTrackNumber() << "\n"
617 << "Momentum\n"
618 << "E=" << mom.T() << ", Px=" << mom.X() << ", Py=" << mom.Y()
619 << ", Pz=" << mom.Z() << std::endl;
620 }
621
622 // Now transfer track
623 if (fSplitSimulation) {
624 Int_t targetId = -1;
625 if (fMC->GetId() == 0 && strcmp(fMC->CurrentVolName(), "ABSO") == 0) {
626 targetId = 1;
627 }
628 else if (fMC->GetId() == 1 && strcmp(fMC->CurrentVolName(), "GAPX") == 0) {
629 targetId = 0;
630 }
631 if (targetId > -1) {
632 if (fDebug > 1) {
633 Info("Stepping", "Transfer track");
634 }
635 fMCManager->TransferTrack(targetId);
636 }
637 }
638}

◆ PostTrack()

void Ex03cMCApplication::PostTrack ( )
virtual

User actions after finishing of each track

Definition at line 641 of file Ex03cMCApplication.cxx.

642{
643 /// User actions after finishing of each track
644 fVerbose.PostTrack();
645}

◆ FinishPrimary()

void Ex03cMCApplication::FinishPrimary ( )
virtual

User actions after finishing of a primary track

Definition at line 648 of file Ex03cMCApplication.cxx.

649{
650 /// User actions after finishing of a primary track
651
652 fVerbose.FinishPrimary();
653
654 if (fPrimaryGenerator->GetUserDecay()) {
655 cout << endl;
656 }
657}

◆ FinishEvent()

void Ex03cMCApplication::FinishEvent ( )
virtual

User actions after finishing of an event

Definition at line 660 of file Ex03cMCApplication.cxx.

661{
662 /// User actions after finishing of an event
663
664 fVerbose.FinishEvent();
665
666 // Geant3 + TGeo
667 // (use TGeo functions for visualization)
668 if (!fIsMultiRun && TString(fMC->GetName()) == "TGeant3TGeo") {
669
670 // Draw volume
671 gGeoManager->SetVisOption(0);
672 gGeoManager->SetTopVisible();
673 gGeoManager->GetTopVolume()->Draw();
674
675 // Draw tracks (if filled)
676 // Available when this feature is activated via
677 // fMC->SetCollectTracks(kTRUE);
678 if (gGeoManager->GetListOfTracks() && gGeoManager->GetTrack(0) &&
679 ((TVirtualGeoTrack*)gGeoManager->GetTrack(0))->HasPoints()) {
680
681 gGeoManager->DrawTracks("/*"); // this means all tracks
682 }
683 }
684
685 fRootManager->Fill();
686
687 if (fEventNo % fPrintModulo == 0) fCalorimeterSD->PrintTotal();
688
689 fCalorimeterSD->EndOfEvent();
690
691 fStack->Reset();
692}

◆ SetPrintModulo()

void Ex03cMCApplication::SetPrintModulo ( Int_t value)
inline

Set the event modulus number to be printed

Parameters
valueThe new event modulus number value

Definition at line 127 of file Ex03cMCApplication.h.

128{
129 fPrintModulo = value;
130}

◆ SetVerboseLevel()

void Ex03cMCApplication::SetVerboseLevel ( Int_t verboseLevel)
inline

Set verbosity

Parameters
verboseLevelThe new verbose level value

Definition at line 134 of file Ex03cMCApplication.h.

135{
136 fVerbose.SetLevel(verboseLevel);
137}

◆ SetControls()

void Ex03cMCApplication::SetControls ( Bool_t isControls)
inline

Switch on/off special process controls

Parameters
isControlsIf true, special process controls setting is activated

Definition at line 177 of file Ex03cMCApplication.h.

178{
179 fIsControls = isControls;
180}

◆ SetField()

void Ex03cMCApplication::SetField ( Double_t bz)
inline

Set magnetic field

Parameters
bzThe new field value in z

Definition at line 141 of file Ex03cMCApplication.h.

142{
143 fMagField->SetFieldValue(0., 0., bz);
144}

◆ SetDebug()

void Ex03cMCApplication::SetDebug ( Int_t debug)
inline

Set debug option for multiple run.

Definition at line 147 of file Ex03cMCApplication.h.

147{ fDebug = debug; }

◆ GetDetectorConstruction()

Ex03cDetectorConstruction * Ex03cMCApplication::GetDetectorConstruction ( ) const
inline
Returns
The detector construction

Definition at line 151 of file Ex03cMCApplication.h.

152{
153 return fDetConstruction;
154}

◆ GetCalorimeterSD()

Ex03cCalorimeterSD * Ex03cMCApplication::GetCalorimeterSD ( ) const
inline
Returns
The calorimeter sensitive detector

Definition at line 157 of file Ex03cMCApplication.h.

158{
159 return fCalorimeterSD;
160}

◆ GetPrimaryGenerator()

Ex03PrimaryGenerator * Ex03cMCApplication::GetPrimaryGenerator ( ) const
inline
Returns
The primary generator

Definition at line 163 of file Ex03cMCApplication.h.

164{
165 return fPrimaryGenerator;
166}

◆ SetOldGeometry()

void Ex03cMCApplication::SetOldGeometry ( Bool_t oldGeometry = kTRUE)
inline

Switch on/off the old geometry definition (via VMC functions)

Parameters
oldGeometryIf true, geometry definition via VMC functions

Definition at line 170 of file Ex03cMCApplication.h.

171{
172 fOldGeometry = oldGeometry;
173}

◆ RegisterStack()

void Ex03cMCApplication::RegisterStack ( ) const
private

Register stack in the Root manager.

Definition at line 194 of file Ex03cMCApplication.cxx.

195{
196 /// Register stack in the Root manager.
197
198 if (fRootManager) {
199 // cout << "Ex03cMCApplication::RegisterStack: " << endl;
200 fRootManager->Register("stack", "Ex03cMCStack", &fStack);
201 }
202}

Member Data Documentation

◆ fRootManager

TMCRootManager* Ex03cMCApplication::fRootManager
mutableprivate

Root manager.

Definition at line 99 of file Ex03cMCApplication.h.

◆ fPrintModulo

Int_t Ex03cMCApplication::fPrintModulo
private

The event modulus number to be printed.

Definition at line 100 of file Ex03cMCApplication.h.

◆ fEventNo

Int_t Ex03cMCApplication::fEventNo
private

Event counter.

Definition at line 101 of file Ex03cMCApplication.h.

◆ fVerbose

TMCVerbose Ex03cMCApplication::fVerbose
private

VMC verbose helper.

Definition at line 102 of file Ex03cMCApplication.h.

◆ fStack

Ex03cMCStack* Ex03cMCApplication::fStack
private

VMC stack.

Definition at line 103 of file Ex03cMCApplication.h.

◆ fDetConstruction

Ex03cDetectorConstruction* Ex03cMCApplication::fDetConstruction
private

Dector construction.

Definition at line 104 of file Ex03cMCApplication.h.

◆ fCalorimeterSD

Ex03cCalorimeterSD* Ex03cMCApplication::fCalorimeterSD
private

Calorimeter SD.

Definition at line 105 of file Ex03cMCApplication.h.

◆ fPrimaryGenerator

Ex03PrimaryGenerator* Ex03cMCApplication::fPrimaryGenerator
private

Primary generator.

Definition at line 106 of file Ex03cMCApplication.h.

◆ fMagField

TGeoUniformMagField* Ex03cMCApplication::fMagField
private

Magnetic field.

Definition at line 107 of file Ex03cMCApplication.h.

◆ fOldGeometry

Bool_t Ex03cMCApplication::fOldGeometry
private

Option for geometry definition.

Definition at line 108 of file Ex03cMCApplication.h.

◆ fIsControls

Bool_t Ex03cMCApplication::fIsControls
private

Option to activate special controls.

Definition at line 109 of file Ex03cMCApplication.h.

◆ fIsMaster

Bool_t Ex03cMCApplication::fIsMaster
private

If is on master thread.

Definition at line 110 of file Ex03cMCApplication.h.

◆ fIsMultiRun

Bool_t Ex03cMCApplication::fIsMultiRun
private

Flag if having multiple engines.

Definition at line 111 of file Ex03cMCApplication.h.

◆ fSplitSimulation

Bool_t Ex03cMCApplication::fSplitSimulation
private

Split geometry given user criteria.

Definition at line 112 of file Ex03cMCApplication.h.

◆ fG3Id

Int_t Ex03cMCApplication::fG3Id
private

engine ID of Geant3

Definition at line 113 of file Ex03cMCApplication.h.

◆ fG4Id

Int_t Ex03cMCApplication::fG4Id
private

engine ID of Geant4

Definition at line 114 of file Ex03cMCApplication.h.

◆ fDebug

Int_t Ex03cMCApplication::fDebug
private

debug option for multiple run

Definition at line 115 of file Ex03cMCApplication.h.


The documentation for this class was generated from the following files: