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