Warning, file /geant4/examples/extended/biasing/GB04/exampleGB04.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "GB04ActionInitialization.hh"
0031 #include "GB04DetectorConstruction.hh"
0032 #include "GB04PrimaryGeneratorAction.hh"
0033
0034 #include "G4GenericBiasingPhysics.hh"
0035 #include "G4RunManagerFactory.hh"
0036 #include "G4Types.hh"
0037 #include "G4UIExecutive.hh"
0038 #include "G4UImanager.hh"
0039 #include "G4VisExecutive.hh"
0040
0041
0042
0043 namespace
0044 {
0045 void PrintUsage()
0046 {
0047 G4cerr << " Usage: " << G4endl;
0048 G4cerr << " ./exampleGB04 [-m macro ] "
0049 << " [-b biasing {'on','off'}]"
0050 << "\n or\n ./exampleGB04 [macro.mac]" << G4endl;
0051 }
0052 }
0053
0054
0055
0056 int main(int argc, char** argv)
0057 {
0058
0059
0060 if (argc > 5) {
0061 PrintUsage();
0062 return 1;
0063 }
0064
0065 G4String macro("");
0066 G4String onOffBiasing("");
0067 if (argc == 2)
0068 macro = argv[1];
0069 else {
0070 for (G4int i = 1; i < argc; i = i + 2) {
0071 if (G4String(argv[i]) == "-m")
0072 macro = argv[i + 1];
0073 else if (G4String(argv[i]) == "-b")
0074 onOffBiasing = argv[i + 1];
0075 else {
0076 PrintUsage();
0077 return 1;
0078 }
0079 }
0080 }
0081
0082 if (onOffBiasing == "") onOffBiasing = "on";
0083
0084
0085 G4UIExecutive* ui = nullptr;
0086 if (macro == "") {
0087 ui = new G4UIExecutive(argc, argv);
0088 }
0089
0090
0091 auto* runManager = G4RunManagerFactory::CreateRunManager();
0092 runManager->SetNumberOfThreads(4);
0093
0094 G4bool biasingFlag = (onOffBiasing == "on");
0095
0096
0097 auto detector = new GB04DetectorConstruction(biasingFlag);
0098 runManager->SetUserInitialization(detector);
0099
0100 auto physicsList = new FTFP_BERT;
0101 if (biasingFlag) {
0102
0103 auto biasingPhysics = new G4GenericBiasingPhysics();
0104
0105 std::vector<G4String> processToBias;
0106 processToBias.push_back("eBrem");
0107
0108
0109 biasingPhysics->PhysicsBias("e-", processToBias);
0110 biasingPhysics->PhysicsBias("e+", processToBias);
0111 physicsList->RegisterPhysics(biasingPhysics);
0112 G4cout << " ********************************************************* " << G4endl;
0113 G4cout << " ********** processes are wrapped for biasing ************ " << G4endl;
0114 G4cout << " ********************************************************* " << G4endl;
0115 }
0116 else {
0117 G4cout << " ************************************************* " << G4endl;
0118 G4cout << " ********** processes are not wrapped ************ " << G4endl;
0119 G4cout << " ************************************************* " << G4endl;
0120 }
0121 runManager->SetUserInitialization(physicsList);
0122
0123 runManager->SetUserInitialization(new GB04ActionInitialization);
0124
0125
0126 runManager->Initialize();
0127
0128
0129 auto visManager = new G4VisExecutive;
0130
0131 visManager->Initialize();
0132
0133
0134 auto UImanager = G4UImanager::GetUIpointer();
0135
0136 if (!ui)
0137 {
0138 G4String command = "/control/execute ";
0139 UImanager->ApplyCommand(command + macro);
0140 }
0141 else {
0142 UImanager->ApplyCommand("/control/execute vis.mac");
0143
0144
0145 ui->SessionStart();
0146 delete ui;
0147 }
0148
0149 delete visManager;
0150 delete runManager;
0151
0152 return 0;
0153 }
0154
0155