-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (65 loc) · 2.39 KB
/
main.cpp
File metadata and controls
79 lines (65 loc) · 2.39 KB
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
// defines
// system includes
#include <iostream>
// G4 includes
#include "G4RunManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4OpticalPhysics.hh"
// project includes
#include "OMConstruction.hh"
#include "OMPrimaryGenerator.hh"
#include "OMSteppingAction.hh"
#include "OMTrackingAction.hh"
#include "OMRunAction.hh"
#include "OMDataManager.hh"
int main(int argc,char** argv)
{
G4RunManager* runManager = new G4RunManager;
// set up optical physics
G4VModularPhysicsList* OMphysicsList = new FTFP_BERT;
G4OpticalPhysics* OMopticalPhysics = new G4OpticalPhysics();
OMphysicsList->RegisterPhysics(OMopticalPhysics);
// run manager initialisation
runManager->SetUserInitialization(OMphysicsList);
runManager->SetUserInitialization(new OMConstruction());
runManager->SetUserAction (new OMPrimaryGenerator());
runManager->SetUserAction (new OMRunAction());
runManager->SetUserAction (new OMTrackingAction());
runManager->SetUserAction (new OMSteppingAction());
//runManager->Initialize(); // done in macro
// call singletons where necessary
OMDataManager::getInstance();
// set random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::MTwistEngine);
CLHEP::HepRandom::setTheSeed((unsigned)clock());
// Initialize visualization
if ( argc == 1 || argv[1] == std::string("--vis") || argv[1] == std::string("--interactive") )
{
G4UIExecutive* ui = new G4UIExecutive(argc, argv);
G4VisExecutive* visManager = new G4VisExecutive();
visManager->SetVerboseLevel(0);
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand("/control/execute macros/init.mac");
ui->SessionStart();
delete ui;
delete visManager;
}
else if ( argv[1] == std::string("--batch") )
{
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand("/control/execute macros/init.mac");
}
else
{
G4Exception("int main()",
"invalid command arguments",
FatalErrorInArgument,
"Can't make sense of command line arguments.\nTry '--batch' for batch mode or '--vis' for interactive mode!");
}
delete runManager;
return 0;
}