-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg4workshop.cc
104 lines (81 loc) · 2.38 KB
/
g4workshop.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// To run g4workshop
// make g4workshop_build
// cd g4workshop_build
// cmake -DGeant4_DIR=$G4COMP ../g4workshop_example
// make -j
// ./g4workshop
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4UIExecutive.hh"
//#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
//#endif
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include <stdlib.h>
int main(int argc,char** argv) {
G4UIExecutive* ui = nullptr;
ui = new G4UIExecutive(argc, argv);
// Choose the Random engine
//
G4Random::setTheEngine(new CLHEP::RanecuEngine);
//set random seed with system time
G4long seed = time(NULL);
CLHEP::HepRandom::setTheSeed(seed);
// Construct the default run manager
#ifdef G4MULTITHREADED
G4RunManager* runManager = new G4RunManager;
runManager->SetNumberOfThreads(1);
#else
G4RunManager* runManager = new G4RunManager;
#endif
// Set mandatory user initialization classes
DetectorConstruction* detector = new DetectorConstruction;
runManager->SetUserInitialization(detector);
PhysicsList* physics = new PhysicsList();
runManager->SetUserInitialization(physics);
// User action initialization
double x = atof(argv[1]);
double y = atof(argv[2]);
double z = atof(argv[3]);
runManager->SetUserInitialization(new ActionInitialization(detector,x,y,z));
// Initialize G4 kernel
//runManager->Initialize();
//#ifdef G4VIS_USE
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
//#endif
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (argc==1+3) // Define UI session for interactive mode.
{
//#ifdef _WIN32
//G4UIsession * session = new G4UIterminal();
//#else
//G4UIsession * session = new G4UIterminal(new G4UItcsh);
//#endif
UImanager->ApplyCommand("/control/execute vdrift_build/g4workshop.mac");
ui->SessionStart();
delete ui;
// session->SessionStart();
// delete session;
}
else // Batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
return 0;
}