Geant4  10.02.p03
exampleGB04.cc File Reference

Main program of the GB04 example. More...

Include dependency graph for exampleGB04.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the GB04 example.

Definition in file exampleGB04.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file exampleGB04.cc.

72 {
73  // Evaluate arguments
74  //
75  if ( argc > 5 ) {
76  PrintUsage();
77  return 1;
78  }
79 
80  G4String macro("");
81  G4String onOffBiasing("");
82  if ( argc == 2 ) macro = argv[1];
83  else
84  {
85  for ( G4int i=1; i<argc; i=i+2 )
86  {
87  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
88  else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
89  else
90  {
91  PrintUsage();
92  return 1;
93  }
94  }
95  }
96 
97  if ( onOffBiasing == "" ) onOffBiasing = "on";
98 
99  // -- Construct the run manager : MT or sequential one
100 #ifdef G4MULTITHREADED
101  G4MTRunManager * runManager = new G4MTRunManager;
102  G4cout << " ********** Run Manager constructed in MT mode ************ "
103  << G4endl;
104  // -- Choose 4 threads:
105  runManager->SetNumberOfThreads(4);
106 #else
107  G4RunManager * runManager = new G4RunManager;
108  G4cout << " ********** Run Manager constructed in sequential mode ************ "
109  << G4endl;
110 #endif
111 
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 
151 #ifdef G4VIS_USE
152  // Initialize visualization
153  G4VisManager* visManager = new G4VisExecutive;
154  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
155  visManager->Initialize();
156 #endif
157 
158  // Get the pointer to the User Interface manager
159  G4UImanager* UImanager = G4UImanager::GetUIpointer();
160 
161  if ( macro != "" ) // batch mode
162  {
163  G4String command = "/control/execute ";
164  UImanager->ApplyCommand(command+macro);
165  }
166  else
167  { // interactive mode : define UI session
168 #ifdef G4UI_USE
169  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
170 #ifdef G4VIS_USE
171  // UImanager->ApplyCommand("/control/execute vis.mac");
172 #endif
173  // if (ui->IsGUI())
174  // UImanager->ApplyCommand("/control/execute gui.mac");
175  ui->SessionStart();
176  delete ui;
177 #endif
178  }
179 
180 
181 #ifdef G4VIS_USE
182  delete visManager;
183 #endif
184  delete runManager;
185 
186 
187  return 0;
188 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
void PhysicsBias(const G4String &particleName)
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:446
Here is the call graph for this function: