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