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