LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleGB06.cc File Reference

Main program of the GB06 example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "GB06ActionInitialization.hh"
#include "G4UImanager.hh"
#include "GB06DetectorConstruction.hh"
#include "GB06ParallelWorldForSlices.hh"
#include "GB06PrimaryGeneratorAction.hh"
#include "FTFP_BERT.hh"
#include "G4GenericBiasingPhysics.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the GB06 example.

Definition in file exampleGB06.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file exampleGB06.cc.

References PrintUsage().

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  // Instantiate G4UIExecutive if interactive mode
97  G4UIExecutive* ui = nullptr;
98  if ( macro == "" ) {
99  ui = new G4UIExecutive(argc, argv);
100  }
101 
102  // -- Construct the run manager : MT or sequential one
103 #ifdef G4MULTITHREADED
104  G4MTRunManager * runManager = new G4MTRunManager;
105  G4cout << " ********** Run Manager constructed in MT mode ************ "
106  << G4endl;
107  // -- Choose 4 threads:
108  runManager->SetNumberOfThreads(4);
109 #else
110  G4RunManager * runManager = new G4RunManager;
111  G4cout << " ********** Run Manager constructed in sequential mode ************ "
112  << G4endl;
113 #endif
114 
115 
116  // -- Set mandatory initialization classes
117 
118  // -- Create geometry:
119  GB06DetectorConstruction* detector = new GB06DetectorConstruction();
120  // -- Create parallel world:
121  GB06ParallelWorldForSlices* parallelWorld =
122  new GB06ParallelWorldForSlices("parallelWorldForSlices");
123  // -- and "augment" detector geometry with the parallelWorld one:
124  detector->RegisterParallelWorld( parallelWorld );
125  runManager->SetUserInitialization(detector);
126 
127  // -- Select a physics list:
128  FTFP_BERT* physicsList = new FTFP_BERT;
129  // -- and augment it with biasing facilities:
130  G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
131  biasingPhysics->BeVerbose();
132  if ( onOffBiasing == "on" )
133  {
134  // -- We use only the "non physics biasing" functionnality (ie, the ones which don't
135  // -- alter physics processes behavior), and hence we equipe the physics list
136  // -- accordingly:
137  biasingPhysics->NonPhysicsBias("neutron");
138  // -- we activate and configure the parallel geometry facility:
139  biasingPhysics->AddParallelGeometry("neutron","parallelWorldForSlices");
140  physicsList->RegisterPhysics(biasingPhysics);
141  G4cout << " ********************************************************* "
142  << G4endl;
143  G4cout << " ********** processes are wrapped for biasing ************ "
144  << G4endl;
145  G4cout << " ********************************************************* "
146  << G4endl;
147  }
148  else
149  {
150  G4cout << " ************************************************* " << G4endl;
151  G4cout << " ********** processes are not wrapped ************ " << G4endl;
152  G4cout << " ************************************************* " << G4endl;
153  }
154  runManager->SetUserInitialization(physicsList);
155 
156  // -- Action initialization:
157  runManager->SetUserInitialization(new GB06ActionInitialization);
158 
159  // Initialize G4 kernel
160  runManager->Initialize();
161 
162  // Initialize visualization
163  G4VisManager* visManager = new G4VisExecutive;
164  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
165  visManager->Initialize();
166 
167  // Get the pointer to the User Interface manager
168  G4UImanager* UImanager = G4UImanager::GetUIpointer();
169 
170  if ( macro != "" ) // batch mode
171  {
172  G4String command = "/control/execute ";
173  UImanager->ApplyCommand(command+macro);
174  }
175  else
176  { // interactive mode : define UI session
177  UImanager->ApplyCommand("/control/execute vis.mac");
178  // if (ui->IsGUI())
179  // UImanager->ApplyCommand("/control/execute gui.mac");
180  ui->SessionStart();
181  delete ui;
182  }
183 
184  delete visManager;
185  delete runManager;
186 
187  return 0;
188 }
void PrintUsage()