Loading...
Searching...
No Matches
Functions
saxs.cc File Reference
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "SAXSDetectorConstruction.hh"
#include "SAXSPhysicsList.hh"
#include "SAXSActionInitialization.hh"
#include "SAXSRunAction.hh"
#include "SAXSEventAction.hh"
#include "SAXSSteppingAction.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4Timer.hh"
#include "Randomize.hh"
#include <time.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file saxs.cc.

51{
52
53 G4Timer* theTimer = new G4Timer();
54 theTimer->Start();
55
56 //Choose the Random engine and reset the seed (before the RunManager)
57 /*
58 G4int seed = time(0);
59 G4cout << "Random seed: " << seed << G4endl;
60 CLHEP::HepRandom::setTheSeed(seed);
61 */
62 //Construct the run manager
63 auto* runManager = G4RunManagerFactory::CreateRunManager();
64 int vNumberOfThreads = 2;
65 if (argc>2) {
66 vNumberOfThreads = atoi(argv[2]);
67 }
68 if (vNumberOfThreads > 0) {
69 runManager->SetNumberOfThreads(vNumberOfThreads);
70 }
71
72 //Set mandatory initialization classes
73 runManager->SetUserInitialization(new SAXSDetectorConstruction);
74 runManager->SetUserInitialization(new SAXSPhysicsList());
75
76 //Set user action classes
77 runManager->SetUserInitialization(new SAXSActionInitialization());
78
79 //Get the pointer to the User Interface manager
80 G4UImanager* UImanager = G4UImanager::GetUIpointer();
81
82 //No arguments: set the batch mode
83 if (argc!=1) {
84 //Batch mode
85 G4String command = "/control/execute ";
86 G4String fileName = argv[1];
87 UImanager->ApplyCommand(command+fileName);
88 } else {
89 //Visualization manager
90 G4VisManager* visManager = new G4VisExecutive;
91 visManager->Initialize();
92
93 //Define UI session for interactive mode
94 G4UIExecutive* ui = new G4UIExecutive(argc,argv);
95 UImanager->ApplyCommand("/control/execute init_vis.mac");
96 if (ui->IsGUI())
97 UImanager->ApplyCommand("/control/execute gui.mac");
98 ui->SessionStart();
99
100 delete ui;
101 delete visManager;
102 }
103
104 //Job termination
105 delete runManager;
106
107 theTimer->Stop();
108 G4cout << "Execution completed" << G4endl;
109 G4cout << (*theTimer) << G4endl;
110 delete theTimer;
111
112 return 0;
113}
Action initialization class.

Applications | User Support | Publications | Collaboration