VMC Examples Version 6.6
Loading...
Searching...
No Matches
exampleMonopole.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2018 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
10/// \file exampleMonopole.cxx
11/// \brief The Geant4 VMC example Monopole application executable
12///
13/// The Geant4 VMC application executable
14/// with explicitely instantiated TGeant3 or TGeant4 and linked
15/// with all libraries.
16///
17/// \date 15/07/2018
18/// \author I. Hrivnacova; IPN, Orsay
19
20#include "DetectorConstruction.h"
21#include "MCApplication.h"
22
23#ifdef USE_GEANT4
24#include "TG4RunConfiguration.h"
25#include "TGeant4.h"
26#endif
27
28#include "TROOT.h"
29
30/// Application main program
31int main(int argc, char** argv)
32{
33#ifdef USE_GEANT3
34 // This example cannot run with Geant3
35 std::cerr << "Monopole example: Geant3 is not supported." << std::endl;
36 return 1;
37#endif
38
39 // Initialize Root threading.
40 // (Multi-threading is triggered automatically if Geant4 was built
41 // in MT mode.)
42#ifdef G4MULTITHREADED
43 ROOT::EnableThreadSafety();
44#endif
45
46 // Create MC application
48 "ExampleMonopole", "The exampleMonopole MC application");
49 // Set detector parameters
50 // /testex/det/setMat G4_Si
51 // /testex/det/setSizeX 10 cm
52 // /testex/det/setSizeYZ 20 cm
53 // /testex/det/setStepSize 0.2 mm
54 // /testex/run/binSize 0.2 mm
57 detector->SetAbsorberMaterial("Si");
58 detector->SetAbsorberSizeX(10);
59 detector->SetAbsorberSizeYZ(20);
60 detector->SetMaxStepSize(0.02);
61 appl->SetBinSize(0.02);
62
63#ifdef USE_GEANT4
64 // RunConfiguration for Geant4
65 TG4RunConfiguration* runConfiguration = new TG4RunConfiguration(
66 "geomRootToGeant4", "FTFP_BERT+monopole", "stepLimiter", false, false);
67
68 // TGeant4
69 TGeant4* geant4 = new TGeant4(
70 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
71 std::cout << "Geant4 has been created." << std::endl;
72
73 // Customise Geant4 setting
74 // (verbose level, global range cut, ..)
75 geant4->ProcessGeantMacro("g4config.in");
76#endif
77
78 // Run from this main
79 appl->InitMC("");
80
81#ifdef USE_GEANT4
82 // Customise Geant4 setting after initialization:
83 // Physics list
84 geant4->ProcessGeantMacro("g4config2.in");
85#endif
86
87#ifdef USE_GEANT4
88 // Setting Geant4 visualization
89 geant4->ProcessGeantMacro("g4vis.in");
90#endif
91
92 appl->RunMC(5);
93
94 delete appl;
95}
The detector construction (via TGeo )
void SetAbsorberMaterial(const TString &name)
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void SetBinSize(Double_t binSize)
void RunMC(Int_t nofEvents)
DetectorConstruction * GetDetectorConstruction() const
int main(int argc, char **argv)
Application main program.