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

Main program of the field/field01 example. More...

#include "G4Types.hh"
#include "F01SteppingVerbose.hh"
#include "G4RunManager.hh"
#include "F01DetectorConstruction.hh"
#include "F01ActionInitialization.hh"
#include "F01RunAction.hh"
#include "G4UImanager.hh"
#include "G4EmParameters.hh"
#include "G4HadronicProcessStore.hh"
#include "G4PhysicsListHelper.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4Electron.hh"
#include "G4Transportation.hh"
#include "G4CoupledTransportation.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the field/field01 example.

Definition in file field01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 75 of file field01.cc.

76 {
77  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
78  G4UIExecutive* ui = nullptr;
79  if ( argc == 1 ) {
80  ui = new G4UIExecutive(argc, argv);
81  }
82 
83  // Choose the Random engine
84  //
85  G4Random::setTheEngine(new CLHEP::RanecuEngine);
86 
87  // Construct the default run manager
88  //
89 #ifdef USE_MULTITHREADED
90  G4MTRunManager * runManager = new G4MTRunManager;
91 #else
92  G4VSteppingVerbose::SetInstance(new F01SteppingVerbose);
93  G4RunManager * runManager = new G4RunManager;
94 #endif
95 
96  // Set mandatory initialization classes
97  //
98  // Detector construction
99  F01DetectorConstruction* detector = new F01DetectorConstruction();
100  // detector->SetUseFSALstepper(); // Uncomment to use FSAL steppers
101 
102  runManager->SetUserInitialization(detector);
103 
104  // Configure the use of low thresholds for looping particles
105  // ( appropriate for typical applications using low-energy physics. )
106  auto plHelper = G4PhysicsListHelper::GetPhysicsListHelper();
107  plHelper->UseLowLooperThresholds();
108  // Request a set of pre-selected values of the parameters for looping
109  // particles
110 
111  // Physics list
112  G4VModularPhysicsList* physicsList = new FTFP_BERT;
113  physicsList->RegisterPhysics(new G4StepLimiterPhysics());
114  runManager->SetUserInitialization(physicsList);
115 
116  // User action initialization
117  runManager->SetUserInitialization(new F01ActionInitialization(detector));
118 
119  // Fine grained control of thresholds for looping particles
120  auto runAction= new F01RunAction();
121  runAction->SetWarningEnergy( 10.0 * CLHEP::keV );
122  // Looping particles with E < 10 keV will be killed after 1 step
123  // with warning.
124  // Looping particles with E > 10 keV will generate a warning.
125  runAction->SetImportantEnergy( 0.1 * CLHEP::MeV );
126  runAction->SetNumberOfTrials( 30 );
127  // Looping particles with E > 0.1 MeV will survive for up to
128  // 30 'tracking' steps, and only be killed if they still loop.
129  // Note: this mechanism overwrites the thresholds established by
130  // the call to UseLowLooperThresholds() above.
131 
132  runManager->SetUserAction(runAction);
133 
134  // Suppress large verbosity from EM & hadronic processes
135  G4EmParameters::Instance()->SetVerbose(-1);
136  G4HadronicProcessStore::Instance()->SetVerbose(0);
137 
138  // Initialize G4 kernel
139  //
140  runManager->Initialize();
141 
142  // Initialize visualization
143  //
144  G4VisManager* visManager = new G4VisExecutive;
145  // G4VisExecutive can take a verbosity argument - see /vis/verbose
146  // G4VisManager* visManager = new G4VisExecutive("Quiet");
147  visManager->Initialize();
148 
149  // Get the pointer to the User Interface manager
150  //
151  G4UImanager* UImanager = G4UImanager::GetUIpointer();
152 
153  if (!ui) // batch mode
154  {
155  G4String command = "/control/execute ";
156  G4String fileName = argv[1];
157  UImanager->ApplyCommand(command+fileName);
158  }
159  else
160  { // interactive mode : define UI session
161  UImanager->ApplyCommand("/control/execute init_vis.mac");
162  if (ui->IsGUI())
163  UImanager->ApplyCommand("/control/execute gui.mac");
164  ui->SessionStart();
165  delete ui;
166  }
167 
168  // Statistics of tracks killed by G4Transportation are currently
169  // printed in the RunAction's EndOfEvent action.
170  // ( Eventually a summary could be provided here instead or as well. )
171 
172  delete visManager;
173  delete runManager;
174 
175  return 0;
176 }