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