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