File indexing completed on 2026-04-08 07:53:22
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
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #include "CRMC_FTFP_BERT.hh"
0042 #include "DetectorConstruction.hh"
0043 #include "EventAction.hh"
0044 #include "HistoManager.hh"
0045 #include "PrimaryGeneratorAction.hh"
0046 #include "RunAction.hh"
0047 #include "StackingAction.hh"
0048 #include "UrQMD.hh"
0049
0050 #include "G4PhysListFactory.hh"
0051 #include "G4RunManagerFactory.hh"
0052 #include "G4UIExecutive.hh"
0053 #include "G4UImanager.hh"
0054 #include "G4VModularPhysicsList.hh"
0055 #include "G4VisExecutive.hh"
0056 #include "Randomize.hh"
0057
0058 int main(int argc, char** argv)
0059 {
0060
0061 G4UIExecutive* ui = nullptr;
0062 if (argc == 1) ui = new G4UIExecutive(argc, argv);
0063
0064
0065 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
0066
0067
0068 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0069
0070
0071 runManager->SetUserInitialization(new DetectorConstruction());
0072
0073 G4PhysListFactory factory;
0074 G4VModularPhysicsList* phys = 0;
0075
0076
0077 G4String physName = "QBBC";
0078
0079
0080 if (argc == 3) {
0081 physName = argv[2];
0082 }
0083 else {
0084 char* path = std::getenv("PHYSLIST");
0085 if (path) {
0086 physName = G4String(path);
0087 }
0088 }
0089 if (physName == "UrQMD") {
0090 phys = new UrQMD;
0091 }
0092 else if (physName == "CRMC_FTFP_BERT") {
0093 phys = new CRMC_FTFP_BERT;
0094 }
0095 else {
0096 phys = factory.GetReferencePhysList(physName);
0097 }
0098
0099
0100 if (!phys) {
0101 G4cout << "Hadr02 FATAL ERROR: Physics List is not defined" << G4endl;
0102 return 1;
0103 }
0104 runManager->SetUserInitialization(phys);
0105 HistoManager::GetPointer()->SetPhysicsList(phys);
0106
0107 runManager->SetUserAction(new PrimaryGeneratorAction());
0108
0109
0110 runManager->SetUserAction(new RunAction());
0111 runManager->SetUserAction(new EventAction());
0112 runManager->SetUserAction(new StackingAction());
0113
0114
0115 G4VisManager* visManager = new G4VisExecutive;
0116 visManager->Initialize();
0117
0118
0119 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0120
0121 if (ui) {
0122
0123 ui->SessionStart();
0124 delete ui;
0125 }
0126 else {
0127
0128 G4String command = "/control/execute ";
0129 G4String fileName = argv[1];
0130 UImanager->ApplyCommand(command + fileName);
0131 }
0132
0133
0134 delete visManager;
0135 delete runManager;
0136 }