-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathG4Radiacode.cc
105 lines (82 loc) · 2.9 KB
/
G4Radiacode.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
105
/*
Radiacode Geant4 Model
------------------------
Radiacode 103
*/
// Geant4 core libs
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "Randomize.hh"
#include "QGSP_BIC_HP.hh"
// User defined classes
#include "G4RadiacodeDetectorConstruction.hh"
#include "G4RadiacodePhysicsList.hh"
#include "G4RadiacodePrimaryGeneratorAction.hh"
#include "G4RadiacodeRunAction.hh"
#include "G4RadiacodeStackingAction.hh"
#include "G4RadiacodeEventAction.hh"
// STL libs
#include <memory>
#include <random>
#include <ctime>
#include <chrono>
int main(int argc, char** argv)
{
G4UIExecutive * ui = 0;
if(argc == 1)
{
ui = new G4UIExecutive(argc, argv);
}
// Choose the random engine
G4Random::setTheEngine(new CLHEP::RanecuEngine);
// Initialize SEED using current time since epoch
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
// Set HepRandom with time dependent seed --> Needed for Cloud Parallelization
CLHEP::HepRandom::setTheSeed(seed);
G4Random::setTheSeed(seed);
// Construct the run manager
G4RunManager * runManager = new G4RunManager;
// Set Mandatory initialization classes
// ---------------------------------------------------------------------------
G4RadiacodeDetectorConstruction * det = new G4RadiacodeDetectorConstruction();
runManager->SetUserInitialization(det);
G4RadiacodePhysicsList * phys = new G4RadiacodePhysicsList();
runManager->SetUserInitialization(phys);
// Set action classes
// ---------------------------------------------------------------------------
G4RadiacodePrimaryGeneratorAction * gen = new G4RadiacodePrimaryGeneratorAction();
runManager->SetUserAction(gen);
G4RadiacodeRunAction * run = new G4RadiacodeRunAction();
runManager->SetUserAction(run);
G4RadiacodeEventAction * event = new G4RadiacodeEventAction();
runManager->SetUserAction(event);
G4RadiacodeStackingAction * stack = new G4RadiacodeStackingAction();
runManager->SetUserAction(stack);
// Initialize Geant4 Kernel
runManager->Initialize();
// Initialize visualization
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
// get the pointer to the User Interface Manager
G4UImanager * uiManager = G4UImanager::GetUIpointer();
if(!ui)
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
uiManager->ApplyCommand(command+fileName);
}
else
{
uiManager->ApplyCommand("/control/execute macro/vis/initialize_visualization.mac");
ui->SessionStart();
delete ui;
}
// Terminate application
// All user action and initialization classes are freed by the runManager
// so they should not be deleted in the main() program
delete visManager;
delete runManager;
return 0;
}