File indexing completed on 2025-10-13 08:26:25
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 #include "FTFP_BERT.hh"
0028 #include "GB03ActionInitialization.hh"
0029 #include "GB03DetectorConstruction.hh"
0030 #include "GB03PrimaryGeneratorAction.hh"
0031
0032 #include "G4GenericBiasingPhysics.hh"
0033 #include "G4RunManagerFactory.hh"
0034 #include "G4Types.hh"
0035 #include "G4UIExecutive.hh"
0036 #include "G4UImanager.hh"
0037 #include "G4VisExecutive.hh"
0038
0039
0040 namespace
0041 {
0042 void PrintUsage()
0043 {
0044 G4cerr << " Usage: " << G4endl;
0045 G4cerr << " ./exampleGB04 [-m macro ] "
0046 << " [-b biasing {'on','off'}]"
0047 << "\n or\n ./exampleGB04 [macro.mac]" << G4endl;
0048 }
0049 }
0050
0051
0052
0053 int main(int argc, char** argv)
0054 {
0055
0056
0057 if (argc > 5) {
0058 PrintUsage();
0059 return 1;
0060 }
0061
0062 G4String macro("");
0063 G4String onOffBiasing("");
0064 if (argc == 2)
0065 macro = argv[1];
0066 else {
0067 for (G4int i = 1; i < argc; i = i + 2) {
0068 if (G4String(argv[i]) == "-m")
0069 macro = argv[i + 1];
0070 else if (G4String(argv[i]) == "-b")
0071 onOffBiasing = argv[i + 1];
0072 else {
0073 PrintUsage();
0074 return 1;
0075 }
0076 }
0077 }
0078
0079 if (onOffBiasing == "") onOffBiasing = "on";
0080
0081
0082 G4UIExecutive* ui = nullptr;
0083 if (macro == "") {
0084 ui = new G4UIExecutive(argc, argv);
0085 }
0086
0087
0088 auto* runManager = G4RunManagerFactory::CreateRunManager();
0089 runManager->SetNumberOfThreads(4);
0090
0091 G4bool biasingFlag = (onOffBiasing == "on");
0092
0093
0094 G4VUserDetectorConstruction* detector = new GB03DetectorConstruction(biasingFlag);
0095 runManager->SetUserInitialization(detector);
0096 G4VModularPhysicsList* physicsList = new FTFP_BERT;
0097
0098
0099
0100 if (biasingFlag) {
0101 auto biasingPhysics = new G4GenericBiasingPhysics();
0102 biasingPhysics->NonPhysicsBias("neutron");
0103 physicsList->RegisterPhysics(biasingPhysics);
0104 G4cout << " ********************************************************* " << G4endl;
0105 G4cout << " ********** processes are wrapped for biasing ************ " << G4endl;
0106 G4cout << " ********************************************************* " << G4endl;
0107 }
0108 else {
0109 G4cout << " ************************************************* " << G4endl;
0110 G4cout << " ********** processes are not wrapped ************ " << G4endl;
0111 G4cout << " ************************************************* " << G4endl;
0112 }
0113 runManager->SetUserInitialization(physicsList);
0114
0115
0116 G4VUserActionInitialization* actions = new GB03ActionInitialization;
0117 runManager->SetUserInitialization(actions);
0118
0119
0120
0121 auto visManager = new G4VisExecutive;
0122 visManager->Initialize();
0123
0124
0125
0126 runManager->Initialize();
0127
0128
0129
0130 auto UImanager = G4UImanager::GetUIpointer();
0131
0132 if (ui)
0133 {
0134 UImanager->ApplyCommand("/control/execute vis.mac");
0135 ui->SessionStart();
0136 delete ui;
0137 }
0138 else
0139 {
0140 G4String command = "/control/execute ";
0141 UImanager->ApplyCommand(command + macro);
0142 }
0143
0144 delete visManager;
0145 delete runManager;
0146
0147 return 0;
0148 }