VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex03cMCApplication.h
Go to the documentation of this file.
1#ifndef EX03_MC_APPLICATION_H
2#define EX03_MC_APPLICATION_H
3
4//------------------------------------------------
5// The Virtual Monte Carlo examples
6// Copyright (C) 2014 - 2018 Ivana Hrivnacova
7// All rights reserved.
8//
9// For the licensing terms see geant4_vmc/LICENSE.
10// Contact: root-vmc@cern.ch
11//-------------------------------------------------
12
13/// \file Ex03cMCApplication.h
14/// \brief Definition of the Ex03cMCApplication class
15///
16/// Geant4 ExampleN03 adapted to Virtual Monte Carlo
17///
18/// \author Benedikt Volkel, CERN
19
20#include <initializer_list>
21
22#include <TVirtualMCApplication.h>
23
24#include "Ex03cCalorimeterSD.h"
26
27#include <TGeoUniformMagField.h>
28#include <TMCVerbose.h>
29
30class Ex03cMCStack;
32
33class TMCRootManager;
34
35/// \ingroup E03
36/// \brief Implementation of the TVirtualMCApplication
37///
38/// A variant of the Ex03MCApplication class
39/// updated for multiple engine runs.
40///
41
42/// \date 21/08/2019
43/// \author Benedikt Volkel, CERN
44
46{
47 public:
48 Ex03cMCApplication(const char* name, const char* title,
49 Bool_t isMulti = kFALSE, Bool_t splitSimulation = kFALSE);
51 virtual ~Ex03cMCApplication();
52
53 // methods
54 void InitMC(const char* setup);
55 void InitMC(std::initializer_list<const char*> setupMacros);
56 void InitMC();
57 void RunMC(Int_t nofEvents);
58 void FinishRun();
59 void ReadEvent(Int_t i);
60
62 virtual void InitOnWorker();
63 virtual void FinishRunOnWorker();
64
65 virtual void ConstructGeometry();
66 virtual void InitGeometry();
67 virtual void AddParticles();
68 virtual void AddIons();
69 virtual void GeneratePrimaries();
70 virtual void BeginEvent();
71 virtual void BeginPrimary();
72 virtual void PreTrack();
73 virtual void Stepping();
74 virtual void PostTrack();
75 virtual void FinishPrimary();
76 virtual void FinishEvent();
77
78 // set methods
79 void SetPrintModulo(Int_t value);
80 void SetVerboseLevel(Int_t verboseLevel);
81 void SetControls(Bool_t isConstrols);
82 void SetField(Double_t bz);
83 void SetDebug(Int_t debug);
84
85 // get methods
89
90 // method for tests
91 void SetOldGeometry(Bool_t oldGeometry = kTRUE);
92
93 private:
94 // methods
96 void RegisterStack() const;
97
98 // data members
99 mutable TMCRootManager* fRootManager; //!< Root manager
100 Int_t fPrintModulo; ///< The event modulus number to be printed
101 Int_t fEventNo; ///< Event counter
102 TMCVerbose fVerbose; ///< VMC verbose helper
103 Ex03cMCStack* fStack; ///< VMC stack
105 Ex03cCalorimeterSD* fCalorimeterSD; ///< Calorimeter SD
107 TGeoUniformMagField* fMagField; ///< Magnetic field
108 Bool_t fOldGeometry; ///< Option for geometry definition
109 Bool_t fIsControls; ///< Option to activate special controls
110 Bool_t fIsMaster; ///< If is on master thread
111 Bool_t fIsMultiRun; ///< Flag if having multiple engines
112 Bool_t fSplitSimulation; ///< Split geometry given user criteria
113 Int_t fG3Id; ///< engine ID of Geant3
114 Int_t fG4Id; ///< engine ID of Geant4
115 Int_t fDebug; ///< debug option for multiple run
116
117 ClassDef(Ex03cMCApplication, 1) // Interface to MonteCarlo application
118};
119
120// Define typedef so that we can use the E03 macros for all examples variants
122
123// inline functions
124
125/// Set the event modulus number to be printed
126/// \param value The new event modulus number value
128{
129 fPrintModulo = value;
130}
131
132/// Set verbosity
133/// \param verboseLevel The new verbose level value
134inline void Ex03cMCApplication::SetVerboseLevel(Int_t verboseLevel)
135{
136 fVerbose.SetLevel(verboseLevel);
137}
138
139/// Set magnetic field
140/// \param bz The new field value in z
141inline void Ex03cMCApplication::SetField(Double_t bz)
142{
143 fMagField->SetFieldValue(0., 0., bz);
144}
145
146/// Set debug option for multiple run
147inline void Ex03cMCApplication::SetDebug(Int_t debug) { fDebug = debug; }
148
149/// \return The detector construction
155
156/// \return The calorimeter sensitive detector
161
162/// \return The primary generator
167
168/// Switch on/off the old geometry definition (via VMC functions)
169/// \param oldGeometry If true, geometry definition via VMC functions
170inline void Ex03cMCApplication::SetOldGeometry(Bool_t oldGeometry)
171{
172 fOldGeometry = oldGeometry;
173}
174
175/// Switch on/off special process controls
176/// \param isControls If true, special process controls setting is activated
177inline void Ex03cMCApplication::SetControls(Bool_t isControls)
178{
179 fIsControls = isControls;
180}
181
182#endif // EX03_MC_APPLICATION_H
Definition of the Ex03cCalorimeterSD class.
Definition of the Ex03cDetectorConstruction class.
Ex03cMCApplication Ex03MCApplication
The primary generator.
The calorimeter sensitive detector.
The detector construction (via TGeo )
Implementation of the TVirtualMCApplication.
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.
void SetVerboseLevel(Int_t verboseLevel)
void SetField(Double_t bz)
Ex03cCalorimeterSD * GetCalorimeterSD() const
Ex03cCalorimeterSD * fCalorimeterSD
Calorimeter SD.
virtual void GeneratePrimaries()
void RunMC(Int_t nofEvents)
Bool_t fOldGeometry
Option for geometry definition.
Ex03cDetectorConstruction * GetDetectorConstruction() const
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.
virtual TVirtualMCApplication * CloneForWorker() const
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.
void SetDebug(Int_t debug)
Set debug option for multiple run.
virtual void ConstructGeometry()
Ex03PrimaryGenerator * GetPrimaryGenerator() const
virtual void FinishRunOnWorker()
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
void SetPrintModulo(Int_t value)
void SetControls(Bool_t isConstrols)
Int_t fG4Id
engine ID of Geant4
Int_t fDebug
debug option for multiple run
Implementation of the TVirtualMCStack interface.