12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting Started with <strong>Geant4</strong>- Running a Simple ExampleExample 2.24. The typical main() routine from the examples directory.int main(int argc,char** argv) {// Construct the default run managerG4RunManager * runManager = new G4RunManager;// set mandatory initialization classesN03DetectorConstruction* detector = new N03DetectorConstruction;runManager->SetUserInitialization(detector);runManager->SetUserInitialization(new N03PhysicsList);#ifdef G4VIS_USE// visualization managerG4VisManager* visManager = new G4VisExecutive;visManager->Initialize();#endif// set user action classesrunManager->SetUserAction(new N03PrimaryGeneratorAction(detector));runManager->SetUserAction(new N03RunAction);runManager->SetUserAction(new N03EventAction);runManager->SetUserAction(new N03SteppingAction);// get the pointer to the User Interface managerG4UImanager* UI = G4UImanager::GetUIpointer();if (argc==1) // Define UI terminal <strong>for</strong> interactive mode{G4UIExecutive* session = new G4UIExecutive(argc, argv);UI->ApplyCommand("/control/execute prerunN03.mac");session->SessionStart();delete session;}else// Batch mode{G4String command = "/control/execute ";G4String fileName = argv[1];UI->ApplyCommand(command+fileName);}// job termination#ifdef G4VIS_USEdelete visManager;#endifdelete runManager;}return 0;Notice that the visualization system is under the control of the precompiler variable G4VIS_USE. Notice also that,in interactive mode, few intializations have been put in the macro prerunN03.mac which is executed be<strong>for</strong>ethe session start.27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!