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