File indexing completed on 2025-02-23 09:22:34
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
0037
0038
0039 #include "FTFP_BERT.hh"
0040 #include "Par03ActionInitialisation.hh"
0041 #include "Par03DetectorConstruction.hh"
0042
0043 #include "G4EmParameters.hh"
0044 #include "G4FastSimulationPhysics.hh"
0045 #include "G4HadronicProcessStore.hh"
0046 #include "G4RunManagerFactory.hh"
0047 #include "G4Types.hh"
0048 #include "G4UIExecutive.hh"
0049 #include "G4UImanager.hh"
0050 #include "G4VisExecutive.hh"
0051
0052 #include <sstream>
0053
0054 int main(int argc, char** argv)
0055 {
0056
0057 G4String batchMacroName;
0058 G4bool useInteractiveMode = true;
0059 G4String helpMsg(
0060 "Usage: " + G4String(argv[0]) +
0061 " [option(s)] \n No additional arguments triggers an interactive mode "
0062 "executing vis.mac macro. \n Options:\n\t-h\t\tdisplay this help "
0063 "message\n\t-m MACRO\ttriggers a batch mode executing MACRO\n");
0064 for (G4int i = 1; i < argc; ++i) {
0065 G4String argument(argv[i]);
0066 if (argument == "-h" || argument == "--help") {
0067 G4cout << helpMsg << G4endl;
0068 return 0;
0069 }
0070 else if (argument == "-m") {
0071 batchMacroName = G4String(argv[i + 1]);
0072 useInteractiveMode = false;
0073 ++i;
0074 }
0075 else {
0076 G4Exception(
0077 "main", "Unknown argument", FatalErrorInArgument,
0078 ("Unknown argument passed to " + G4String(argv[0]) + " : " + argument + "\n" + helpMsg)
0079 .c_str());
0080 }
0081 }
0082
0083
0084 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0085
0086
0087 auto detector = new Par03DetectorConstruction();
0088 runManager->SetUserInitialization(detector);
0089
0090
0091 auto physicsList = new FTFP_BERT();
0092
0093 auto fastSimulationPhysics = new G4FastSimulationPhysics();
0094 fastSimulationPhysics->BeVerbose();
0095 fastSimulationPhysics->ActivateFastSimulation("e-");
0096 fastSimulationPhysics->ActivateFastSimulation("e+");
0097 fastSimulationPhysics->ActivateFastSimulation("gamma");
0098 physicsList->RegisterPhysics(fastSimulationPhysics);
0099
0100 G4EmParameters::Instance()->SetVerbose(0);
0101 runManager->SetUserInitialization(physicsList);
0102 G4HadronicProcessStore::Instance()->SetVerbose(0);
0103
0104
0105
0106
0107 runManager->SetUserInitialization(new Par03ActionInitialisation(detector));
0108
0109
0110
0111
0112 G4cout << "Instantiating Visualization Manager......." << G4endl;
0113 G4VisManager* visManager = new G4VisExecutive;
0114 visManager->Initialize();
0115 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0116
0117 if (useInteractiveMode) {
0118 auto ui = new G4UIExecutive(argc, argv);
0119 UImanager->ApplyCommand("/control/execute vis.mac");
0120 ui->SessionStart();
0121 delete ui;
0122 }
0123 else {
0124 G4String command = "/control/execute ";
0125 UImanager->ApplyCommand(command + batchMacroName);
0126 }
0127
0128
0129
0130
0131
0132 delete visManager;
0133 delete runManager;
0134
0135 return 0;
0136 }