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