-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
executable file
·106 lines (83 loc) · 2.55 KB
/
main.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
106
//global configuration
#include <DetectorConstruction.hh>
#include <JediConfigurationManager.hh>
//Geometries
#include "UserActionInitialization.hh"
//Physics
#include "JediPhysicsListFactory.hh"
//Geant4 stuff
#include <G4UImanager.hh>
#include <G4UIterminal.hh>
#include <G4UItcsh.hh>
#ifdef G4VIS_USE
#include <G4VisExecutive.hh>
#endif
#ifdef G4UI_USE
#include <G4UIExecutive.hh>
#endif
#ifdef G4MULTITHREADED
#include <G4MTRunManager.hh>
#else
#include <G4RunManager.hh>
#endif
#include <TROOT.h>
#include "Rtypes.h"
#include <memory>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv) {
std::unique_ptr<JediConfigurationManager> ConfigurationManager;
try{
ConfigurationManager.reset(new JediConfigurationManager(argc,argv));
}
catch(const std::exception& e){
std::cout<<"uncaught exception in main: "<<e.what()<<std::endl;
throw e;
}
#ifdef G4MULTITHREADED
ROOT::EnableThreadSafety();
G4MTRunManager* runManager = new G4MTRunManager();
runManager->SetNumberOfThreads(JediConfigurationManager::Instance()->GetMap()["general.num_threads"].as<int>());
#else
G4RunManager* runManager = new G4RunManager();
#endif
runManager->SetVerboseLevel(0);
// set mandatory initialization classes
G4VUserDetectorConstruction* detector =DetectorConstruction::Create();
runManager->SetUserInitialization(detector);
// set physics list
G4VModularPhysicsList* the_physics=JediPhysicsListFactory::Create();
runManager->SetUserInitialization(the_physics);
// all other user action
runManager->SetUserInitialization(new UserActionInitialization);
// get the pointer to the UI manager and set verbosities
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->SetVerboseLevel(0);
#ifdef G4VIS_USE
G4VisManager* visManager = nullptr;
#endif
if(!JediConfigurationManager::Instance()->GetMap().count("general.macro_file")){
#ifdef G4VIS_USE
//visualization manager
visManager = new G4VisExecutive();
visManager->SetVerboseLevel(JediConfigurationManager::Instance()->GetVerbose());
visManager->Initialize();
#endif
#ifdef G4UI_USE
G4UIExecutive* ui = new G4UIExecutive(argc, argv);
UImanager->ApplyCommand("/control/execute scripts/gui.mac");
ui->SessionStart();
delete ui;
#endif
}
else{
G4String command = "/control/execute ";
G4String filename = JediConfigurationManager::Instance()->GetMap()["general.macro_file"].as<std::string>().c_str();
UImanager->ApplyCommand(command+filename);
}
#ifdef G4VIS_USE
delete visManager;
#endif
// job termination
delete runManager;
return 0;
}