Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
exampleGB01.cc File Reference
#include "G4RunManager.hh"
#include "GB01ActionInitialization.hh"
#include "G4UImanager.hh"
#include "GB01DetectorConstruction.hh"
#include "GB01PrimaryGeneratorAction.hh"
#include "FTFP_BERT.hh"
#include "G4GenericBiasingPhysics.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file exampleGB01.cc.

References G4UImanager::ApplyCommand(), G4GenericBiasingPhysics::Bias(), G4cout, G4endl, G4UImanager::GetUIpointer(), G4RunManager::Initialize(), G4VisManager::Initialize(), G4UIExecutive::SessionStart(), G4MTRunManager::SetNumberOfThreads(), and G4RunManager::SetUserInitialization().

69 {
70  // Evaluate arguments
71  //
72  if ( argc > 5 ) {
73  PrintUsage();
74  return 1;
75  }
76 
77  G4String macro("");
78  G4String onOffBiasing("");
79  if ( argc == 2 ) macro = argv[1];
80  else
81  {
82  for ( G4int i=1; i<argc; i=i+2 )
83  {
84  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
85  else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
86  else
87  {
88  PrintUsage();
89  return 1;
90  }
91  }
92  }
93 
94  if ( onOffBiasing == "" ) onOffBiasing = "on";
95 
96  // -- Construct the run manager : MT or sequential one
97 #ifdef G4MULTITHREADED
98  G4MTRunManager * runManager = new G4MTRunManager;
99  G4cout << " ********** Run Manager constructed in MT mode ************ " << G4endl;
100  // -- Choose 4 threads:
101  runManager->SetNumberOfThreads(4);
102 #else
103  G4RunManager * runManager = new G4RunManager;
104  G4cout << " ********** Run Manager constructed in sequential mode ************ " << G4endl;
105 #endif
106 
107 
108  // -- Set mandatory initialization classes
110  runManager->SetUserInitialization(detector);
111  // -- Select a physics list:
112  FTFP_BERT* physicsList = new FTFP_BERT;
113  // -- and augment it with biasing facilities:
114  G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
115  if ( onOffBiasing == "on" )
116  {
117  biasingPhysics->Bias("gamma");
118  biasingPhysics->Bias("neutron");
119  biasingPhysics->Bias("kaon0L");
120  biasingPhysics->Bias("kaon0S");
121  physicsList->RegisterPhysics(biasingPhysics);
122  G4cout << " ********************************************************* " << G4endl;
123  G4cout << " ********** processes are wrapped for biasing ************ " << G4endl;
124  G4cout << " ********************************************************* " << G4endl;
125  }
126  else
127  {
128  G4cout << " ************************************************* " << G4endl;
129  G4cout << " ********** processes are not wrapped ************ " << G4endl;
130  G4cout << " ************************************************* " << G4endl;
131  }
132  runManager->SetUserInitialization(physicsList);
133  // -- Action initialization:
135 
136  // Initialize G4 kernel
137  runManager->Initialize();
138 
139 
140 #ifdef G4VIS_USE
141  // Initialize visualization
142  G4VisManager* visManager = new G4VisExecutive;
143  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
144  visManager->Initialize();
145 #endif
146 
147  // Get the pointer to the User Interface manager
148  G4UImanager* UImanager = G4UImanager::GetUIpointer();
149 
150  if ( macro != "" ) // batch mode
151  {
152  G4String command = "/control/execute ";
153  UImanager->ApplyCommand(command+macro);
154  }
155  else
156  { // interactive mode : define UI session
157 #ifdef G4UI_USE
158  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
159 #ifdef G4VIS_USE
160  // UImanager->ApplyCommand("/control/execute vis.mac");
161 #endif
162  // if (ui->IsGUI())
163  // UImanager->ApplyCommand("/control/execute gui.mac");
164  ui->SessionStart();
165  delete ui;
166 #endif
167  }
168 
169 
170 #ifdef G4VIS_USE
171  delete visManager;
172 #endif
173  delete runManager;
174 
175 
176  return 0;
177 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
void Bias(const G4String &particleName)