LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 //
28 //
29 //
30 //
31 // -------------------------------------------------------------
32 // GEANT4 Hadr00
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 "G4MTRunManager.hh"
48 #include "G4UImanager.hh"
49 #include "Randomize.hh"
50 
51 #include "DetectorConstruction.hh"
52 #include "G4PhysListFactory.hh"
53 #include "G4VModularPhysicsList.hh"
55 #include "ActionInitialization.hh"
56 
57 #include "G4UIExecutive.hh"
58 #include "G4VisExecutive.hh"
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
62 int main(int argc,char** argv) {
63 
64  //detect interactive mode (if no arguments) and define UI session
65  G4UIExecutive* ui = nullptr;
66  if (argc == 1) { ui = new G4UIExecutive(argc,argv); }
67 
68 #ifdef G4MULTITHREADED
69  G4MTRunManager * runManager = new G4MTRunManager();
70 
71  // Number of threads can be defined via 3rd argument
72  if (argc==4) {
73  G4int nThreads = G4UIcommand::ConvertToInt(argv[3]);
74  runManager->SetNumberOfThreads(nThreads);
75  }
76  G4cout << "##### Hadr00 started for " << runManager->GetNumberOfThreads()
77  << " threads" << " #####" << G4endl;
78 #else
79  G4RunManager * runManager = new G4RunManager();
80  G4cout << "##### Hadr00 started in sequential mode"
81  << " #####" << G4endl;
82 #endif
83 
84  //set mandatory initialization classes
86  runManager->SetUserInitialization(det);
87 
88  G4PhysListFactory factory;
89  G4VModularPhysicsList* phys = nullptr;
90  G4String physName = "";
91 
92  //Physics List name defined via 3nd argument
93  if (argc>=3) { physName = argv[2]; }
94 
95  //Physics List is defined via environment variable PHYSLIST
96  if ("" == physName) {
97  char* path = std::getenv("PHYSLIST");
98  if (path) { physName = G4String(path); }
99  }
100 
101  //if name is not known to the factory use FTFP_BERT
102  if("" == physName || !factory.IsReferencePhysList(physName)) {
103  physName = "FTFP_BERT";
104  }
105 
106  //reference PhysicsList via its name
107  phys = factory.GetReferencePhysList(physName);
108 
109  runManager->SetUserInitialization(phys);
110  det->SetPhysicsList(phys);
111 
112  //set user action classes
113  runManager->SetUserInitialization(new ActionInitialization(det));
114 
115  //initialize visualization
116  G4VisManager* visManager = nullptr;
117 
118  //get the pointer to the User Interface manager
119  G4UImanager* UImanager = G4UImanager::GetUIpointer();
120 
121  if (ui) {
122  //interactive mode
123  visManager = new G4VisExecutive;
124  visManager->Initialize();
125  ui->SessionStart();
126  delete ui;
127  } else {
128  //batch mode
129  G4String command = "/control/execute ";
130  G4String fileName = argv[1];
131  UImanager->ApplyCommand(command+fileName);
132  }
133 
134  //job termination
135  delete visManager;
136  delete runManager;
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char **argv)
Definition: Hadr00.cc:62