File indexing completed on 2026-06-14 07:53:23
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
0042
0043
0044
0045
0046 #include "DetectorConstruction.hh"
0047 #include "EventAction.hh"
0048 #include "PhysicsList.hh"
0049 #include "PrimaryGeneratorAction.hh"
0050 #include "RunAction.hh"
0051 #include "StackingAction.hh"
0052
0053 #include "G4HadronicParameters.hh"
0054 #include "G4PhysListFactory.hh"
0055 #include "G4RunManagerFactory.hh"
0056 #include "G4UIExecutive.hh"
0057 #include "G4UImanager.hh"
0058 #include "G4VModularPhysicsList.hh"
0059 #include "G4VisExecutive.hh"
0060
0061
0062
0063 int main(int argc, char** argv)
0064 {
0065
0066 G4UIExecutive* ui = nullptr;
0067 if (argc == 1) {
0068 ui = new G4UIExecutive(argc, argv);
0069 }
0070
0071
0072 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0073
0074
0075 runManager->SetUserInitialization(new DetectorConstruction());
0076
0077 G4PhysListFactory factory;
0078 G4VModularPhysicsList* phys = nullptr;
0079 G4String physName = "";
0080
0081
0082 if (argc >= 3) {
0083 physName = argv[2];
0084 }
0085
0086
0087 if ("" == physName) {
0088 char* path = std::getenv("PHYSLIST");
0089 if (nullptr != path) {
0090 physName = G4String(path);
0091 }
0092 }
0093
0094 G4cout << "PhysicsList: " << physName << G4endl;
0095
0096
0097 if ("" != physName && factory.IsReferencePhysList(physName)) {
0098 phys = factory.GetReferencePhysList(physName);
0099 }
0100
0101
0102 if (nullptr == phys) {
0103 phys = new PhysicsList();
0104 }
0105
0106
0107 if (argc >= 5) {
0108 auto param = G4HadronicParameters::Instance();
0109 G4double e1 = CLHEP::GeV * std::strtod(argv[3], 0);
0110 G4double e2 = CLHEP::GeV * std::strtod(argv[4], 0);
0111 G4cout << "### Bertini/FTFP limits: e1(GeV)=" << e1 / CLHEP::GeV
0112 << " e2(GeV)=" << e2 / CLHEP::GeV << G4endl;
0113 param->SetMinEnergyTransitionFTF_Cascade(e1);
0114 param->SetMaxEnergyTransitionFTF_Cascade(e2);
0115 }
0116
0117 if (argc >= 6) {
0118 auto param = G4HadronicParameters::Instance();
0119 param->SetEnableNUDEX(true);
0120 }
0121
0122
0123 runManager->SetUserInitialization(phys);
0124 runManager->SetUserAction(new PrimaryGeneratorAction());
0125
0126
0127 runManager->SetUserAction(new RunAction());
0128 runManager->SetUserAction(new EventAction());
0129 runManager->SetUserAction(new StackingAction());
0130
0131
0132 G4VisManager* visManager = nullptr;
0133
0134
0135 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0136
0137 if (ui) {
0138
0139 visManager = new G4VisExecutive;
0140 visManager->Initialize();
0141 ui->SessionStart();
0142 delete ui;
0143 }
0144 else {
0145
0146 G4String command = "/control/execute ";
0147 G4String fileName = argv[1];
0148 UImanager->ApplyCommand(command + fileName);
0149 }
0150
0151
0152 delete visManager;
0153 delete runManager;
0154 }
0155
0156