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