File indexing completed on 2025-01-30 09:20:16
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 #include "TETDetectorConstruction.hh"
0033 #include "TETModelImport.hh"
0034 #include "TETActionInitialization.hh"
0035 #include "G4RunManagerFactory.hh"
0036 #include "G4UImanager.hh"
0037 #include "G4UIterminal.hh"
0038 #include "G4VisExecutive.hh"
0039 #include "G4UIExecutive.hh"
0040 #include "Randomize.hh"
0041 #include "QGSP_BIC_HP.hh"
0042
0043 void PrintUsage(){
0044 G4cerr<< "Usage: ./External -m [MACRO] -o [OUTPUT] -f (option for MRCP-AF phantom)" <<G4endl;
0045 G4cerr<< "Example: ./External -m run.mac -o run.out (-f)" <<G4endl;
0046 }
0047
0048 int main(int argc,char** argv)
0049 {
0050
0051
0052 G4String macro;
0053 G4String output;
0054 G4bool isAF(false);
0055 G4UIExecutive* ui = nullptr;
0056
0057 for ( G4int i=1; i<argc; i++ ) {
0058
0059 if ( G4String(argv[i]) == "-m" ) {
0060 macro = argv[i+1];
0061 i++;
0062 }
0063
0064 else if ( G4String(argv[i]) == "-o" ) {
0065 output = argv[i+1];
0066 i++;
0067 }
0068
0069 else if ( G4String(argv[i]) == "-f" ) {
0070 isAF = true;
0071 }
0072 else {
0073 PrintUsage();
0074 return 1;
0075 }
0076 }
0077
0078
0079 if ( argc>6 ){
0080 PrintUsage();
0081 return 1;
0082 }
0083
0084
0085
0086 if ( !macro.size() ) {
0087 ui = new G4UIExecutive(argc, argv);
0088 }
0089
0090 else if ( !output.size() ) output = macro + ".out";
0091
0092
0093
0094
0095
0096
0097
0098 auto* runManager = G4RunManagerFactory::CreateRunManager();
0099 G4int nThreads = 4;
0100 runManager->SetNumberOfThreads(nThreads);
0101
0102
0103
0104 auto* tetData = new TETModelImport(isAF, ui);
0105
0106
0107
0108
0109 runManager->SetUserInitialization(new TETDetectorConstruction(tetData));
0110
0111
0112 runManager->SetUserInitialization(new QGSP_BIC_HP());
0113
0114 runManager->SetUserInitialization(new TETActionInitialization(tetData, output));
0115
0116
0117
0118 G4VisManager* visManager = new G4VisExecutive;
0119 visManager->Initialise();
0120
0121
0122
0123 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0124
0125 if ( ! ui ){
0126
0127 G4String command = "/control/execute ";
0128 UImanager->ApplyCommand(command+macro);
0129 }
0130 else {
0131
0132 UImanager->ApplyCommand("/control/execute init_vis.mac");
0133 ui->SessionStart();
0134
0135 delete ui;
0136 }
0137
0138 delete visManager;
0139 delete runManager;
0140 }
0141
0142