Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
Hadr02.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 // $Id: Hadr02.cc 109063 2018-03-23 12:56:28Z 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 #include "G4UIExecutive.hh"
61 #include "G4VisExecutive.hh"
62 
63 #include "UrQMD.hh"
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
67 int main(int argc,char** argv) {
68 
69  //detect interactive mode (if no arguments) and define UI session
70  G4UIExecutive* ui = nullptr;
71  if (argc == 1) ui = new G4UIExecutive(argc,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  //initialize visualization
114  G4VisManager* visManager = new G4VisExecutive;
115  visManager->Initialize();
116 
117  //get the pointer to the User Interface manager
118  G4UImanager* UImanager = G4UImanager::GetUIpointer();
119 
120  if (ui) {
121  //interactive mode
122  ui->SessionStart();
123  delete ui;
124  }
125  else {
126  //batch mode
127  G4String command = "/control/execute ";
128  G4String fileName = argv[1];
129  UImanager->ApplyCommand(command+fileName);
130  }
131 
132  //job termination
133  delete visManager;
134  delete runManager;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
virtual void SetUserAction(G4UserRunAction *userAction)
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
TUrQMD< G4VModularPhysicsList > UrQMD
Definition: UrQMD.hh:81
void SetPhysicsList(G4VModularPhysicsList *p)
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
The primary generator action class with particle gun.
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cout
void Initialize()
Definition of the UrQMD class.
Simple detector construction with a box volume placed in a world.