File indexing completed on 2026-09-16 08:29:15
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 "DetectorConstruction.hh"
0030 #include "EventAction.hh"
0031 #include "PhysicsList.hh"
0032 #include "PrimaryGeneratorAction.hh"
0033 #include "RunAction.hh"
0034 #include "StackingAction.hh"
0035 #include "SteppingAction.hh"
0036 #include "TrackingAction.hh"
0037
0038 #include "G4RunManager.hh"
0039 #include "G4SteppingVerbose.hh"
0040 #include "G4UIExecutive.hh"
0041 #include "G4UImanager.hh"
0042 #include "G4VisExecutive.hh"
0043 #include "Randomize.hh"
0044
0045
0046
0047 int main(int argc, char** argv)
0048 {
0049
0050 G4UIExecutive* ui = nullptr;
0051 if (argc == 1) ui = new G4UIExecutive(argc, argv);
0052
0053
0054 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
0055
0056
0057 G4int precision = 4;
0058 G4SteppingVerbose::UseBestUnit(precision);
0059
0060
0061 G4RunManager* runManager = new G4RunManager;
0062
0063
0064 DetectorConstruction* detector;
0065 detector = new DetectorConstruction;
0066 runManager->SetUserInitialization(detector);
0067 runManager->SetUserInitialization(new PhysicsList());
0068
0069
0070
0071
0072 PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
0073 runManager->SetUserAction(primary);
0074
0075
0076 RunAction* runaction = new RunAction(detector, primary);
0077 runManager->SetUserAction(runaction);
0078
0079
0080 EventAction* eventaction = new EventAction(runaction);
0081 runManager->SetUserAction(eventaction);
0082
0083
0084 TrackingAction* trackingaction = new TrackingAction(runaction);
0085 runManager->SetUserAction(trackingaction);
0086
0087
0088 SteppingAction* steppingaction = new SteppingAction(runaction, eventaction);
0089 runManager->SetUserAction(steppingaction);
0090
0091
0092 StackingAction* stackingaction = new StackingAction();
0093 runManager->SetUserAction(stackingaction);
0094
0095
0096 G4VisManager* visManager = nullptr;
0097
0098
0099 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0100
0101 if (ui) {
0102
0103 visManager = new G4VisExecutive;
0104 visManager->Initialize();
0105 ui->SessionStart();
0106 delete ui;
0107 }
0108 else {
0109
0110 G4String command = "/control/execute ";
0111 G4String fileName = argv[1];
0112 UImanager->ApplyCommand(command + fileName);
0113 }
0114
0115
0116 delete visManager;
0117 delete runManager;
0118 }
0119
0120