VMC Examples Version 6.8
Loading...
Searching...
No Matches
Ex03dMCApplication.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 Ex03dMCApplication.h
14/// \brief Definition of the Ex03dMCApplication class
15///
16/// Geant4 ExampleN03 adapted to Virtual Monte Carlo
17///
18/// \author Radoslaw Karabowicz; GSI
19
20#include <TVirtualMCApplication.h>
21
23#include "Ex03dCalorimeterSD.h"
24#include "TMCRootManager.h"
25
26#include <TGeoUniformMagField.h>
27#include <TMCVerbose.h>
28
29class Ex03dMCStack;
31
32/// \ingroup E03
33/// \brief Implementation of the TVirtualMCApplication
34///
35/// A variant of the Ex03MCApplication class
36/// updated for RNTuple output.
37///
38
39/// \date 07/07/2026
40/// \author Radoslaw Karabowicz, GSI
41
43{
44 public:
45 Ex03dMCApplication(const char* name, const char* title);
47 virtual ~Ex03dMCApplication();
48
49 // methods
50 void InitMC(const char* setup,
51 TMCRootManager::StorageMode storageMode = TMCRootManager::kRNTuple);
52 void RunMC(Int_t nofEvents);
53 void FinishRun();
54 void ReadEvent(Int_t i);
55
57 virtual void InitOnWorker();
58 virtual void FinishRunOnWorker();
59
60 virtual void ConstructGeometry();
61 virtual void InitGeometry();
62 virtual void AddParticles();
63 virtual void AddIons();
64 virtual void GeneratePrimaries();
65 virtual void BeginEvent();
66 virtual void BeginPrimary();
67 virtual void PreTrack();
68 virtual void Stepping();
69 virtual void PostTrack();
70 virtual void FinishPrimary();
71 virtual void FinishEvent();
72
73 // set methods
74 void SetPrintModulo(Int_t value);
75 void SetVerboseLevel(Int_t verboseLevel);
76 void SetControls(Bool_t isConstrols);
77 void SetField(Double_t bz);
78
79 // get methods
83
84 // method for tests
85 void SetOldGeometry(Bool_t oldGeometry = kTRUE);
86
87 private:
88 // methods
90 void RegisterStack();
91
92 // data members
93 mutable TMCRootManager* fRootManager; //!< Root manager
94 Int_t fPrintModulo; ///< The event modulus number to be printed
95 Int_t fEventNo; ///< Event counter
96 TMCVerbose fVerbose; ///< VMC verbose helper
97 Ex03dMCStack* fStack; ///< VMC stack
98 Ex03DetectorConstruction* fDetConstruction; ///< Dector construction
99 Ex03dCalorimeterSD* fCalorimeterSD; ///< Calorimeter SD
101 TGeoUniformMagField* fMagField; ///< Magnetic field
102 Bool_t fOldGeometry; ///< Option for geometry definition
103 Bool_t fIsControls; ///< Option to activate special controls
104 Bool_t fIsMaster; ///< If is on master thread
105
106 TMCRootManager::StorageMode fStorageMode{ TMCRootManager::kTTree };
107 std::shared_ptr<RNTParaWriter> fParallelRNTupleWriter;
108
109 ClassDef(Ex03dMCApplication, 1) // Interface to MonteCarlo application
110};
111
112// inline functions
113
114/// Set the event modulus number to be printed
115/// \param value The new event modulus number value
117{
118 fPrintModulo = value;
119}
120
121/// Set verbosity
122/// \param verboseLevel The new verbose level value
123inline void Ex03dMCApplication::SetVerboseLevel(Int_t verboseLevel)
124{
125 fVerbose.SetLevel(verboseLevel);
126}
127
128// Set magnetic field
129// \param bz The new field value in z
130inline void Ex03dMCApplication::SetField(Double_t bz)
131{
132 fMagField->SetFieldValue(0., 0., bz);
133}
134
135/// \return The detector construction
141
142/// \return The calorimeter sensitive detector
147
148/// \return The primary generator
153
154/// Switch on/off the old geometry definition (via VMC functions)
155/// \param oldGeometry If true, geometry definition via VMC functions
156inline void Ex03dMCApplication::SetOldGeometry(Bool_t oldGeometry)
157{
158 fOldGeometry = oldGeometry;
159}
160
161/// Switch on/off special process controls
162/// \param isControls If true, special process controls setting is activated
163inline void Ex03dMCApplication::SetControls(Bool_t isControls)
164{
165 fIsControls = isControls;
166}
167
168#endif // EX03_MC_APPLICATION_H
Definition of the Ex03DetectorConstruction class.
Definition of the Ex03dCalorimeterSD class.
The detector construction (via TGeo ).
The primary generator.
The calorimeter sensitive detector.
TMCRootManager * fRootManager
Root manager.
virtual void GeneratePrimaries()
Ex03DetectorConstruction * fDetConstruction
Dector construction.
void RunMC(Int_t nofEvents)
Ex03DetectorConstruction * GetDetectorConstruction() const
virtual TVirtualMCApplication * CloneForWorker() const
TGeoUniformMagField * fMagField
Magnetic field.
Int_t fEventNo
Event counter.
std::shared_ptr< RNTParaWriter > fParallelRNTupleWriter
virtual void ConstructGeometry()
Ex03dMCApplication(const char *name, const char *title)
Ex03dCalorimeterSD * fCalorimeterSD
Calorimeter SD.
Bool_t fIsControls
Option to activate special controls.
Ex03dCalorimeterSD * GetCalorimeterSD() const
TMCRootManager::StorageMode fStorageMode
Ex03PrimaryGenerator * fPrimaryGenerator
Primary generator.
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
void SetControls(Bool_t isConstrols)
void SetField(Double_t bz)
Bool_t fOldGeometry
Option for geometry definition.
Ex03dMCStack * fStack
VMC stack.
Ex03PrimaryGenerator * GetPrimaryGenerator() const
void InitMC(const char *setup, TMCRootManager::StorageMode storageMode=TMCRootManager::kRNTuple)
void SetVerboseLevel(Int_t verboseLevel)
TMCVerbose fVerbose
VMC verbose helper.
virtual void FinishRunOnWorker()
Bool_t fIsMaster
If is on master thread.
Int_t fPrintModulo
The event modulus number to be printed.
void SetPrintModulo(Int_t value)
Implementation of the TVirtualMCStack interface.