VMC Examples Version 6.6
Loading...
Searching...
No Matches
exampleA01.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2014 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 exampleA01.cxx
11/// \brief The Geant4 VMC example A01 application executable
12///
13/// \date 26/02/2014
14/// \author I. Hrivnacova; IPN, Orsay
15
16#include "A01MCApplication.h"
17#include "A01PrimaryGenerator.h"
18
19#ifdef USE_GEANT4
20#include "TG4RunConfiguration.h"
21#include "TGeant4.h"
22#endif
23
24#ifdef USE_GEANT3
25#include "TGeant3TGeo.h"
26#endif
27
28#include "TROOT.h"
29
30/// Application main program
31int main(int argc, char** argv)
32{
33 // Initialize Root threading.
34 // (Multi-threading is triggered automatically if Geant4 was built
35 // in MT mode.)
36#ifdef G4MULTITHREADED
37 ROOT::EnableThreadSafety();
38#endif
39
40 // Create MC application (thread local)
41 A01MCApplication* appl =
42 new A01MCApplication("ExampleA01", "The exampleA01 MC application");
43 appl->GetPrimaryGenerator()->SetRandomize(false);
44 appl->SetWriteStack(true);
45 appl->SetWriteHits(true);
46
47#ifdef USE_GEANT4
48 // RunConfiguration for Geant4
49 TG4RunConfiguration* runConfiguration =
50 new TG4RunConfiguration("geomRootToGeant4", "FTFP_BERT");
51
52 // TGeant4
53 TGeant4* geant4 = new TGeant4(
54 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
55
56 // Customise Geant4 setting
57 // (verbose level, global range cut, ..)
58 geant4->ProcessGeantMacro("g4config.in");
59#endif
60
61#ifdef USE_GEANT3
62 new TGeant3TGeo("C++ Interface to Geant3");
63 gMC->SetProcess("DRAY", 1);
64 gMC->SetProcess("LOSS", 1);
65 gMC->SetProcess("HADR", 1);
66#endif
67
68 // Run example
69 appl->InitMC("");
70
71#ifdef USE_GEANT4
72 // Setting Geant4 visualization
73 geant4->ProcessGeantMacro("g4vis.in");
74#endif
75
76 appl->RunMC(5);
77
78 delete appl;
79}
Definition of the A01MCApplication class.
Definition of the A01PrimaryGenerator class.
Implementation of the TVirtualMCApplication.
void SetWriteHits(Bool_t writeHits)
void RunMC(Int_t nofEvents)
void SetWriteStack(Bool_t writeStack)
A01PrimaryGenerator * GetPrimaryGenerator() const
void InitMC(const char *setup)
void SetRandomize(Bool_t val)
int main(int argc, char **argv)
Application main program.