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