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 #include "G3toG4ActionInitialization.hh"
0035 #include "G3toG4DetectorConstruction.hh"
0036
0037
0038 #include "FTFP_BERT.hh"
0039 #include "G3VolTable.hh"
0040
0041 #include "G4RunManagerFactory.hh"
0042 #include "G4UIExecutive.hh"
0043 #include "G4UImanager.hh"
0044 #include "G4VisExecutive.hh"
0045 #include "G4ios.hh"
0046
0047
0048
0049 namespace
0050 {
0051 void PrintUsage()
0052 {
0053 G4cerr << " Usage: " << G4endl;
0054 G4cerr << "clGeometry <call_list_file> [-m macro ] [-u UIsession] [-t nThreads]" << G4endl;
0055 G4cerr << " note: -t option is relevant only for multi-threaded mode." << G4endl;
0056 }
0057 }
0058
0059
0060
0061 int main(int argc, char** argv)
0062 {
0063
0064
0065 G4cout << "argc " << argc << G4endl;
0066 if (argc < 2 || argc > 8) {
0067 PrintUsage();
0068 return 1;
0069 }
0070
0071 G4String inFile;
0072 G4String macro = "";
0073 G4String session;
0074 G4int nofThreads = 0;
0075
0076
0077 inFile = argv[1];
0078 G4cout << "Geometry data file: " << inFile << G4endl;
0079 std::ifstream in(inFile);
0080 if (!in) {
0081 G4cerr << "Cannot open input file \"" << inFile << "\"" << G4endl;
0082 return EXIT_FAILURE;
0083 }
0084
0085
0086 for (G4int i = 2; i < argc; i = i + 2) {
0087 G4cout << "evaluating " << argv[i] << G4endl;
0088 if (G4String(argv[i]) == "-m")
0089 macro = argv[i + 1];
0090 else if (G4String(argv[i]) == "-u")
0091 session = argv[i + 1];
0092 else if (G4String(argv[i]) == "-t") {
0093 nofThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0094 }
0095 else {
0096 PrintUsage();
0097 return 1;
0098 }
0099 }
0100
0101
0102
0103 G4UIExecutive* ui = nullptr;
0104 if (!macro.size()) {
0105 ui = new G4UIExecutive(argc, argv, session);
0106 }
0107
0108
0109 auto* runManager = G4RunManagerFactory::CreateRunManager();
0110 if (nofThreads > 0) runManager->SetNumberOfThreads(nofThreads);
0111
0112
0113
0114
0115 runManager->SetUserInitialization(new G3toG4DetectorConstruction(inFile));
0116
0117
0118 runManager->SetUserInitialization(new FTFP_BERT);
0119
0120
0121 runManager->SetUserInitialization(new G3toG4ActionInitialization());
0122
0123
0124
0125 auto visManager = new G4VisExecutive;
0126
0127
0128 visManager->Initialize();
0129
0130
0131 auto UImanager = G4UImanager::GetUIpointer();
0132
0133
0134
0135 if (macro.size()) {
0136
0137 G4String command = "/control/execute ";
0138 UImanager->ApplyCommand(command + macro);
0139 }
0140 else {
0141
0142 UImanager->ApplyCommand("/control/execute init_vis.mac");
0143 ui->SessionStart();
0144 delete ui;
0145 }
0146
0147
0148
0149
0150
0151
0152 delete visManager;
0153 delete runManager;
0154 }