Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hadr02.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 //
26 /// \file hadronic/Hadr02/Hadr02.cc
27 /// \brief Main program of the hadronic/Hadr02 example
28 //
29 // $Id: Hadr02.cc 77519 2013-11-25 10:54:57Z gcosmo $
30 //
31 // -------------------------------------------------------------
32 // GEANT4 Hadr02
33 //
34 // Application demonstrating Geant4 hadronic cross sections
35 //
36 // Author: V.Ivanchenko 20 June 2008
37 //
38 // Modified:
39 //
40 // -------------------------------------------------------------
41 //
42 //
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
46 #include "G4RunManager.hh"
47 #include "G4UImanager.hh"
48 #include "Randomize.hh"
49 
50 #include "DetectorConstruction.hh"
51 #include "G4PhysListFactory.hh"
52 #include "G4VModularPhysicsList.hh"
53 #include "PrimaryGeneratorAction.hh"
54 
55 #include "RunAction.hh"
56 #include "EventAction.hh"
57 #include "StackingAction.hh"
58 #include "HistoManager.hh"
59 
60 #ifdef G4VIS_USE
61 #include "G4VisExecutive.hh"
62 #endif
63 
64 #ifdef G4UI_USE
65 #include "G4UIExecutive.hh"
66 #endif
67 
68 #include "UrQMD.hh"
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
71 int main(int argc,char** argv) {
72 
73  //choose the Random engine
75 
76  //Construct the default run manager
77  G4RunManager * runManager = new G4RunManager();
78 
79  //set mandatory initialization classes
81 
82  G4PhysListFactory factory;
83  G4VModularPhysicsList* phys = 0;
84 
85  // default Physics List for this example
86  G4String physName = "QBBC";
87 
88  // Physics List name defined via 2nd argument
89  if (argc==3) { physName = argv[2]; }
90  else {
91  char* path = getenv("PHYSLIST");
92  if (path) { physName = G4String(path); }
93  }
94  if ( physName == "UrQMD" ) { phys = new UrQMD; }
95  else { phys = factory.GetReferencePhysList(physName); }
96 
97  // Physics List is defined via environment variable PHYSLIST
98  if(!phys) {
99  G4cout << "Hadr02 FATAL ERROR: Physics List is not defined"
100  << G4endl;
101  return 1;
102  }
103  runManager->SetUserInitialization(phys);
105 
106  runManager->SetUserAction(new PrimaryGeneratorAction());
107 
108  //set user action classes
109  runManager->SetUserAction(new RunAction());
110  runManager->SetUserAction(new EventAction());
111  runManager->SetUserAction(new StackingAction());
112 
113  //get the pointer to the User Interface manager
114  G4UImanager* UImanager = G4UImanager::GetUIpointer();
115 #ifdef G4VIS_USE
116  G4VisManager* visManager = 0;
117 #endif
118 
119  if (argc==1) // Define UI terminal for interactive mode
120  {
121 #ifdef G4VIS_USE
122  //visualization manager
123  visManager = new G4VisExecutive;
124  visManager->Initialize();
125 #endif
126 #ifdef G4UI_USE
127  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
128  ui->SessionStart();
129  delete ui;
130 #endif
131  }
132  else // Batch mode
133  {
134  G4String command = "/control/execute ";
135  G4String fileName = argv[1];
136  UImanager->ApplyCommand(command+fileName);
137  }
138 
139  //job termination
140 #ifdef G4VIS_USE
141  delete visManager;
142 #endif
143  delete runManager;
144 
145  return 0;
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetPhysicsList(G4VModularPhysicsList *p)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
void Initialize()
TUrQMD< G4VModularPhysicsList > UrQMD
Definition: UrQMD.hh:81
#define G4endl
Definition: G4ios.hh:61
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:170
Definition of the UrQMD class.
int main(int argc, char **argv)
Definition: Hadr02.cc:71
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
virtual void SetUserAction(G4UserRunAction *userAction)