Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
exampleGB05.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 //
26 // $Id: $
27 //
30 
31 #include "G4Types.hh"
32 
33 #ifdef G4MULTITHREADED
34 #include "G4MTRunManager.hh"
35 #else
36 #include "G4RunManager.hh"
37 #endif
39 
40 #include "G4UImanager.hh"
41 
44 
45 #include "FTFP_BERT.hh"
47 
48 #include "G4VisExecutive.hh"
49 #include "G4UIExecutive.hh"
50 
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54 namespace {
55  void PrintUsage() {
56  G4cerr << " Usage: " << G4endl;
57  G4cerr << " ./exampleGB05 [-m macro ] "
58  << " [-b biasing {'on','off'}]"
59  << "\n or\n ./exampleGB05 [macro.mac]"
60  << G4endl;
61  }
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66 
67 int main(int argc,char** argv)
68 {
69  // Evaluate arguments
70  //
71  if ( argc > 5 ) {
72  PrintUsage();
73  return 1;
74  }
75 
76  G4String macro("");
77  G4String onOffBiasing("");
78  if ( argc == 2 ) macro = argv[1];
79  else
80  {
81  for ( G4int i=1; i<argc; i=i+2 )
82  {
83  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
84  else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
85  else
86  {
87  PrintUsage();
88  return 1;
89  }
90  }
91  }
92 
93  if ( onOffBiasing == "" ) onOffBiasing = "on";
94 
95  // Instantiate G4UIExecutive if interactive mode
96  G4UIExecutive* ui = nullptr;
97  if ( macro == "" ) {
98  ui = new G4UIExecutive(argc, argv);
99  }
100 
101  // -- Construct the run manager : MT or sequential one
102 #ifdef G4MULTITHREADED
103  G4MTRunManager * runManager = new G4MTRunManager;
104  G4cout << " ********** Run Manager constructed in MT mode ************ "
105  << G4endl;
106  // -- Choose 4 threads:
107  runManager->SetNumberOfThreads(4);
108 #else
109  G4RunManager * runManager = new G4RunManager;
110  G4cout << " ********** Run Manager constructed in sequential mode ************ "
111  << G4endl;
112 #endif
113 
114 
115  // -- Set mandatory initialization classes
117  runManager->SetUserInitialization(detector);
118  // -- Select a physics list:
119  FTFP_BERT* physicsList = new FTFP_BERT;
120  // -- and augment it with biasing facilities:
121  G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
122  biasingPhysics->BeVerbose();
123  if ( onOffBiasing == "on" )
124  {
125  biasingPhysics->Bias("neutron");
126  physicsList->RegisterPhysics(biasingPhysics);
127  G4cout << " ********************************************************* "
128  << G4endl;
129  G4cout << " ********** processes are wrapped for biasing ************ "
130  << G4endl;
131  G4cout << " ********************************************************* "
132  << G4endl;
133  }
134  else
135  {
136  G4cout << " ************************************************* " << G4endl;
137  G4cout << " ********** processes are not wrapped ************ " << G4endl;
138  G4cout << " ************************************************* " << G4endl;
139  }
140  runManager->SetUserInitialization(physicsList);
141  // -- Action initialization:
143 
144  // Initialize G4 kernel
145  runManager->Initialize();
146 
147  // Initialize visualization
148  G4VisManager* visManager = new G4VisExecutive;
149  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
150  visManager->Initialize();
151 
152  // Get the pointer to the User Interface manager
153  G4UImanager* UImanager = G4UImanager::GetUIpointer();
154 
155  if ( !ui ) // batch mode
156  {
157  G4String command = "/control/execute ";
158  UImanager->ApplyCommand(command+macro);
159  }
160  else
161  { // interactive mode : define UI session
162  UImanager->ApplyCommand("/control/execute vis.mac");
163  // if (ui->IsGUI())
164  // UImanager->ApplyCommand("/control/execute gui.mac");
165  ui->SessionStart();
166  delete ui;
167  }
168 
169  delete visManager;
170  delete runManager;
171 
172  return 0;
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the GB05ActionInitialization class.
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cerr
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
Definition of the GB05DetectorConstruction class.
Definition of the GB05PrimaryGeneratorAction class.
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void Initialize()
void Bias(const G4String &particleName)
virtual void Initialize()