Geant4_10
Hadr05.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 // $Id$
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "G4RunManager.hh"
35 #include "G4MTRunManager.hh"
36 #include "G4UImanager.hh"
37 #include "Randomize.hh"
38 
39 #include "DetectorConstruction.hh"
40 #include "G4PhysListFactory.hh"
41 #include "G4VModularPhysicsList.hh"
42 #include "PrimaryGeneratorAction.hh"
43 #include "ActionInitialization.hh"
44 
45 #include "G4GenericPhysicsList.hh"
46 
47 #ifdef G4VIS_USE
48 #include "G4VisExecutive.hh"
49 #endif
50 
51 #ifdef G4UI_USE
52 #include "G4UIExecutive.hh"
53 #endif
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 int main(int argc,char** argv) {
58 
59  //choose the Random engine
60  G4Random::setTheEngine(new CLHEP::RanecuEngine());
61 
62 #ifdef G4MULTITHREADED
63  G4MTRunManager * runManager = new G4MTRunManager();
64 
65  // Number of threads can be defined via 3rd argument
66  if (argc==4) {
67  G4int nThreads = G4UIcommand::ConvertToInt(argv[3]);
68  runManager->SetNumberOfThreads(nThreads);
69  }
70  G4cout << "##### Hadr05 started for " << runManager->GetNumberOfThreads()
71  << " threads" << " #####" << G4endl;
72 #else
73  G4RunManager * runManager = new G4RunManager();
74  G4cout << "##### Hadr05 started in sequential mode"
75  << " #####" << G4endl;
76 #endif
77 
78  //set mandatory initialization classes
80 
81  G4VModularPhysicsList* phys = 0;
83 
84  // Physics List name defined via 3nd argument
85  if (argc>=3)
86  {
87  phys = new G4GenericPhysicsList();
88  G4String physListMacro = argv[2];
89  UImanager->ApplyCommand("/control/execute "+physListMacro);
90  }
91  else
92  {
93 
94  std::vector<G4String>* MyConstr = new std::vector<G4String>;
95 
96  MyConstr->push_back("G4EmStandardPhysics");
97  MyConstr->push_back("G4EmExtraPhysics");
98  MyConstr->push_back("G4DecayPhysics");
99  MyConstr->push_back("G4HadronElasticPhysics");
100  MyConstr->push_back("G4HadronPhysicsFTFP_BERT");
101  MyConstr->push_back("G4StoppingPhysics");
102  MyConstr->push_back("G4IonPhysics");
103  MyConstr->push_back("G4NeutronTrackingCut");
104 
105  phys = new G4GenericPhysicsList(MyConstr);
106  }
107 
108  runManager->SetUserInitialization(phys);
109 
110  //set user action classes
111  runManager->SetUserInitialization(new ActionInitialization());
112 
113 #ifdef G4VIS_USE
114  G4VisManager* visManager = 0;
115 #endif
116 
117  if (argc==1) // Define UI terminal for interactive mode
118  {
119 #ifdef G4VIS_USE
120  //visualization manager
121  visManager = new G4VisExecutive;
122  visManager->Initialize();
123 #endif
124 #ifdef G4UI_USE
125  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
126  ui->SessionStart();
127  delete ui;
128 #endif
129  }
130  else // Batch mode
131  {
132  G4String command = "/control/execute ";
133  G4String fileName = argv[1];
134  UImanager->ApplyCommand(command+fileName);
135  }
136 
137  //job termination
138 #ifdef G4VIS_USE
139  delete visManager;
140 #endif
141  delete runManager;
142 
143  return 0;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
int main(int argc, char **argv)
Definition: genwindef.cpp:30
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfThreads() const
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:421
void Initialize()
TG4GenericPhysicsList< G4VModularPhysicsList > G4GenericPhysicsList
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419