Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
Hadr00.cc
이 파일의 문서화 페이지로 가기
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 // $Id: Hadr00.cc 109182 2018-04-03 07:18:45Z 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 #include "G4UIExecutive.hh"
59 #include "G4VisExecutive.hh"
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
63 int main(int argc,char** argv) {
64 
65  //detect interactive mode (if no arguments) and define UI session
66  G4UIExecutive* ui = nullptr;
67  if (argc == 1) { ui = new G4UIExecutive(argc,argv); }
68 
69 #ifdef G4MULTITHREADED
70  G4MTRunManager * runManager = new G4MTRunManager();
71 
72  // Number of threads can be defined via 3rd argument
73  if (argc==4) {
74  G4int nThreads = G4UIcommand::ConvertToInt(argv[3]);
75  runManager->SetNumberOfThreads(nThreads);
76  }
77  G4cout << "##### Hadr00 started for " << runManager->GetNumberOfThreads()
78  << " threads" << " #####" << G4endl;
79 #else
80  G4RunManager * runManager = new G4RunManager();
81  G4cout << "##### Hadr00 started in sequential mode"
82  << " #####" << G4endl;
83 #endif
84 
85  //set mandatory initialization classes
87  runManager->SetUserInitialization(det);
88 
89  G4PhysListFactory factory;
90  G4VModularPhysicsList* phys = nullptr;
91  G4String physName = "";
92 
93  //Physics List name defined via 3nd argument
94  if (argc>=3) { physName = argv[2]; }
95 
96  //Physics List is defined via environment variable PHYSLIST
97  if ("" == physName) {
98  char* path = getenv("PHYSLIST");
99  if (path) { physName = G4String(path); }
100  }
101 
102  //if name is not known to the factory use FTFP_BERT
103  if("" == physName || !factory.IsReferencePhysList(physName)) {
104  physName = "FTFP_BERT";
105  }
106 
107  //reference PhysicsList via its name
108  phys = factory.GetReferencePhysList(physName);
109 
110  runManager->SetUserInitialization(phys);
111  det->SetPhysicsList(phys);
112 
113  //set user action classes
114  runManager->SetUserInitialization(new ActionInitialization(det));
115 
116  //initialize visualization
117  G4VisManager* visManager = nullptr;
118 
119  //get the pointer to the User Interface manager
120  G4UImanager* UImanager = G4UImanager::GetUIpointer();
121 
122  if (ui) {
123  //interactive mode
124  visManager = new G4VisExecutive;
125  visManager->Initialize();
126  ui->SessionStart();
127  delete ui;
128  } else {
129  //batch mode
130  G4String command = "/control/execute ";
131  G4String fileName = argv[1];
132  UImanager->ApplyCommand(command+fileName);
133  }
134 
135  //job termination
136  delete visManager;
137  delete runManager;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
G4bool IsReferencePhysList(const G4String &)
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
G4int GetNumberOfThreads() const
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:449
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: genwindef.cc:359
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void Initialize()
Simple detector construction with a box volume placed in a world.