LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
field01.cc
Go to the documentation of this file.
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 //
29 //
30 //
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "G4Types.hh"
37 
38 #ifdef G4MULTITHREADED
39 // #define USE_MULTITHREADED
40 #endif
41 
42 #ifdef USE_MULTITHREADED
43 #include "G4MTRunManager.hh"
44 #else
45 #include "F01SteppingVerbose.hh"
46 #include "G4RunManager.hh"
47 #endif
48 
49 #include "F01DetectorConstruction.hh"
50 #include "F01ActionInitialization.hh"
51 
52 #include "F01RunAction.hh"
53 
54 #include "G4UImanager.hh"
55 
56 #include "G4EmParameters.hh"
57 #include "G4HadronicProcessStore.hh"
58 
59 #include "G4PhysicsListHelper.hh"
60 
61 #include "FTFP_BERT.hh"
62 #include "G4StepLimiterPhysics.hh"
63 #include "Randomize.hh"
64 
65 #include "G4VisExecutive.hh"
66 #include "G4UIExecutive.hh"
67 
68 // For Printing statistic from Transporation process(es)
69 #include "G4Electron.hh"
70 #include "G4Transportation.hh"
71 #include "G4CoupledTransportation.hh"
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
75 int main(int argc,char** argv)
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 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char **argv)
Definition: field01.cc:75