Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exgps.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 #include "G4RunManager.hh"
30 #include "G4UImanager.hh"
31 
32 #ifdef G4ANALYSIS_USE
33 #include "exGPSAnalysisManager.hh"
34 #endif
35 
36 #ifdef G4VIS_USE
37 #include "G4VisExecutive.hh"
38 #endif
39 
40 #ifdef G4UI_USE
41 #include "G4UIExecutive.hh"
42 #endif
43 
45 #include "exGPSPhysicsList.hh"
47 #include "exGPSRunAction.hh"
48 #include "exGPSEventAction.hh"
49 
50 
51 int main(int argc,char** argv) {
52 
53  // Construct the default run manager
54  G4RunManager * runManager = new G4RunManager;
55 
56 #ifdef G4ANALYSIS_USE
57  //constructe the analysis manager (need here to activate the UI)
59 #endif
60 
61  // set mandatory initialization classes
63  runManager->SetUserInitialization(detector);
64  runManager->SetUserInitialization(new exGPSPhysicsList);
65 
66  // Set optional user action classes
67  exGPSEventAction* eventAction = new exGPSEventAction();
68  exGPSRunAction* runAction = new exGPSRunAction();
69 
70  // set user action classes
72  runManager->SetUserAction(runAction);
73  runManager->SetUserAction(eventAction);
74 
75  //Initialize G4 kernel
76  runManager->Initialize();
77 
78  // visualization manager
79 #ifdef G4VIS_USE
80  G4VisManager* visManager = new G4VisExecutive;
81  visManager->Initialize();
82 #endif
83 
84  // get the pointer to the User Interface manager
85  G4UImanager* UImanager = G4UImanager::GetUIpointer();
86  // UI->ApplyCommand("/control/execute display.mac");
87 
88  if (argc!=1) // batch mode
89  {
90  G4String command = "/control/execute ";
91  G4String fileName = argv[1];
92  UImanager->ApplyCommand(command+fileName);
93  }
94  else
95  { // interactive mode : define UI session
96 #ifdef G4UI_USE
97  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
98  ui->SessionStart();
99  delete ui;
100 #endif
101  }
102 
103  // job termination
104 
105 #ifdef G4ANALYSIS_USE
106  exGPSAnalysisManager::Dispose();
107 #endif
108 
109 #ifdef G4VIS_USE
110  delete visManager;
111 #endif
112  delete runManager;
113 
114  return 0;
115 }