00001
00002
00003
00004
00005
00006
00007
00008 #include "G4RunManager.hh"
00009
00010 #include "G4UImanager.hh"
00011 #include "G4UIterminal.hh"
00012 #include "G4UItcsh.hh"
00013
00014 #include "DetectorConstruction.hh"
00015 #include "PhysicsList.hh"
00016 #include "PrimaryGeneratorAction.hh"
00017
00018 #include "RunAction.hh"
00019 #include "SteppingAction.hh"
00020 #include "SteppingVerbose.hh"
00021
00022 #ifdef G4VIS_USE
00023 #include "G4VisExecutive.hh"
00024 #endif
00025
00026
00027
00028 int main(int argc,char** argv) {
00029
00030
00031 G4VSteppingVerbose::SetInstance(new SteppingVerbose);
00032
00033
00034 G4RunManager* runManager = new G4RunManager;
00035
00036
00037
00038 DetectorConstruction* detector = new DetectorConstruction();
00039 runManager->SetUserInitialization(detector);
00040
00041 PhysicsList* physics = new PhysicsList();
00042 runManager->SetUserInitialization(physics);
00043
00044 PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
00045 runManager->SetUserAction(primary);
00046
00047
00048
00049 RunAction* run_action = new RunAction(detector);
00050 runManager->SetUserAction(run_action);
00051
00052 SteppingAction* step_action = new SteppingAction(detector, run_action);
00053 runManager->SetUserAction(step_action);
00054
00055
00056
00057 runManager->Initialize();
00058
00059
00060 G4UImanager* UI = G4UImanager::GetUIpointer();
00061
00062 if (argc!=1) {
00063 G4String command = "/control/execute ";
00064 G4String fileName = argv[1];
00065 UI->ApplyCommand(command+fileName);
00066 }
00067
00068 else {
00069
00070 #ifdef G4VIS_USE
00071 G4VisManager* visManager = new G4VisExecutive;
00072 visManager->Initialize();
00073 #endif
00074
00075 G4UIsession* session = 0;
00076 #ifdef G4UI_USE_TCSH
00077 session = new G4UIterminal(new G4UItcsh);
00078 #else
00079 session = new G4UIterminal();
00080 #endif
00081 UI->ApplyCommand( "/control/execute vis.mac");
00082 session->SessionStart();
00083 delete session;
00084
00085 #ifdef G4VIS_USE
00086 delete visManager;
00087 #endif
00088 }
00089
00090
00091
00092 delete runManager;
00093 return 0;
00094 }
00095
00096