File indexing completed on 2025-02-23 09:21:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef WIN32
0037 # include <unistd.h>
0038 #endif
0039
0040 #include "F06ActionInitialization.hh"
0041 #include "F06DetectorConstruction.hh"
0042 #include "F06PhysicsList.hh"
0043
0044 #include "G4RunManagerFactory.hh"
0045 #include "G4Transportation.hh"
0046 #include "G4Types.hh"
0047 #include "G4UIExecutive.hh"
0048 #include "G4UIcommand.hh"
0049 #include "G4UImanager.hh"
0050 #include "G4VisExecutive.hh"
0051 #include "Randomize.hh"
0052
0053
0054 namespace
0055 {
0056 void PrintUsage()
0057 {
0058 G4cerr << " Usage: " << G4endl;
0059 G4cerr << " field06 [-m macro ] [-u UIsession] [-t nThreads] [-r randomSeed] " << G4endl;
0060 G4cerr << " note: -t option is available only for multi-threaded mode." << G4endl;
0061 }
0062 }
0063
0064
0065
0066 int main(int argc, char** argv)
0067 {
0068
0069
0070 if (argc > 9) {
0071 PrintUsage();
0072 return 1;
0073 }
0074
0075 G4String macro;
0076 G4String session;
0077 G4int nThreads = 0;
0078
0079 G4long randomSeed = 1234;
0080 for (G4int i = 1; i < argc; i = i + 2) {
0081 if (G4String(argv[i]) == "-m")
0082 macro = argv[i + 1];
0083 else if (G4String(argv[i]) == "-u")
0084 session = argv[i + 1];
0085 else if (G4String(argv[i]) == "-r")
0086 randomSeed = atoi(argv[i + 1]);
0087 else if (G4String(argv[i]) == "-t") {
0088 nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0089 }
0090 else {
0091 PrintUsage();
0092 return 1;
0093 }
0094 }
0095
0096
0097 G4UIExecutive* ui = nullptr;
0098 if (macro.size() == 0) {
0099 ui = new G4UIExecutive(argc, argv, session);
0100 }
0101
0102
0103
0104 G4Random::setTheEngine(new CLHEP::RanecuEngine);
0105
0106
0107
0108 auto* runManager = G4RunManagerFactory::CreateRunManager();
0109 if (nThreads > 0) runManager->SetNumberOfThreads(nThreads);
0110
0111
0112 G4Random::setTheSeed(randomSeed);
0113
0114
0115
0116
0117 runManager->SetUserInitialization(new F06DetectorConstruction());
0118
0119 runManager->SetUserInitialization(new F06PhysicsList());
0120
0121
0122 G4Transportation::EnableGravity(true);
0123
0124
0125 runManager->SetUserInitialization(new F06ActionInitialization());
0126
0127
0128
0129 G4VisManager* visManager = new G4VisExecutive;
0130
0131
0132 visManager->Initialize();
0133
0134
0135
0136 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0137
0138 if (!ui) {
0139
0140 G4String command = "/control/execute ";
0141 UImanager->ApplyCommand(command + macro);
0142 }
0143 else {
0144 UImanager->ApplyCommand("/control/execute init_vis.mac");
0145 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac");
0146 ui->SessionStart();
0147 delete ui;
0148 }
0149
0150
0151
0152
0153
0154
0155 delete visManager;
0156 delete runManager;
0157
0158 return 0;
0159 }
0160
0161