Loading...
Searching...
No Matches
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//
27/// \file field/field01/field01.cc
28/// \brief Main program of the field/field01 example
29//
30//
31//
32//
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35
36#include "G4Types.hh"
37
38#include "F01SteppingVerbose.hh"
39#include "G4RunManagerFactory.hh"
40
43
44#include "F01RunAction.hh"
45
46#include "G4UImanager.hh"
47
48// To control verbosity
49#include "G4EmParameters.hh"
50#include "G4HadronicParameters.hh"
51
52#include "G4PhysicsListHelper.hh"
53
54#include "FTFP_BERT.hh"
55#include "G4StepLimiterPhysics.hh"
56#include "Randomize.hh"
57
58#include "G4VisExecutive.hh"
59#include "G4UIExecutive.hh"
60
61// For Printing statistic from Transporation process(es)
62#include "G4Electron.hh"
63#include "G4Transportation.hh"
64#include "G4CoupledTransportation.hh"
65
66#include "G4TransportationParameters.hh"
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
70int main(int argc,char** argv)
71{
72 // Instantiate G4UIExecutive if there are no arguments (interactive mode)
73 G4UIExecutive* ui = nullptr;
74 if ( argc == 1 ) {
75 ui = new G4UIExecutive(argc, argv);
76 }
77
78 // Choose the Random engine
79 //
80 G4Random::setTheEngine(new CLHEP::RanecuEngine);
81
82 G4VSteppingVerbose::SetInstance(new F01SteppingVerbose);
83
84 // Construct the sequential (or default) run manager
85 auto* runManager =
86 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Serial);
87
88 // G4TransportationWithMscType: fDisabled, fEnabled, fMultipleSteps
89 // G4EmParameters::Instance()->SetTransportationWithMsc(G4TransportationWithMscType::fEnabled);
90
91 // Set mandatory initialization classes
92 //
93 // Detector construction
94 auto detector = new F01DetectorConstruction();
95 // detector->SetUseFSALstepper(); // Uncomment to use FSAL steppers
96
97 runManager->SetUserInitialization(detector);
98
99 // Configure the use of low thresholds for looping particles
100 // ( appropriate for typical applications using low-energy physics. )
101 // auto plHelper = G4PhysicsListHelper::GetPhysicsListHelper();
102 // plHelper->UseLowLooperThresholds();
103 // plHelper->UseHighLooperThresholds();
104 // Request a set of pre-selected values of the parameters for looping
105 // particles:
106 // - High for collider HEP applications,
107 // - Low for 'low-E' applications, medical, ..
108 // Note: If helper is used select low or high thresholds , it will overwrite
109 // values from TransportationParameters!
110
111 // They are currently applied in the following order:
112 // 1. Transportation Parameters - fine grained control in Transportation construction
113 // 2. Physics List Helper - impose a fixed set of new values in Transport classes
114 // 3. Run Action (F01RunAction) - revise values at Start of Run
115 // 4. Tracking Action - could revise value at start of each track (not shown)
116 // Note that this also could customise by particle type, e.g. giving different values
117 // to mu-/mu+ , e-/e+ vs others)
118 // If multiple are present, later methods overwrite previous ones in this list.
119
120 // Physics list
121 G4VModularPhysicsList* physicsList = new FTFP_BERT;
122 physicsList->RegisterPhysics(new G4StepLimiterPhysics());
123 runManager->SetUserInitialization(physicsList);
124
125 // User action initialization
126 runManager->SetUserInitialization(new F01ActionInitialization(detector));
127
128 G4double warningE = 10.0 * CLHEP::keV;
129 G4double importantE = 0.1 * CLHEP::MeV;
130 G4int numTrials = 30;
131
132 G4bool useTransportParams= true; // Use the new way - Nov 2022
133
134 if( useTransportParams )
135 {
136 auto transportParams= G4TransportationParameters::Instance();
137 transportParams->SetWarningEnergy( warningE );
138 transportParams->SetImportantEnergy( importantE );
139 transportParams->SetNumberOfTrials( numTrials );
140 G4cout << "field01: Using G4TransportationParameters to set looper parameters." << G4endl;
141 }
142 else
143 {
144 // Fine grained control of thresholds for looping particles
145 auto runAction= new F01RunAction();
146 runAction->SetWarningEnergy( warningE );
147 // Looping particles with E < 10 keV will be killed after 1 step
148 // with warning.
149 // Looping particles with E > 10 keV will generate a warning.
150 runAction->SetImportantEnergy( importantE );
151 runAction->SetNumberOfTrials( numTrials );
152 // Looping particles with E > 0.1 MeV will survive for up to
153 // 30 'tracking' steps, and only be killed if they still loop.
154
155 G4cout << "field01: Using F01RunAction to set looper parameters." << G4endl;
156 runManager->SetUserAction(runAction);
157 }
158
159 // Note: this mechanism overwrites the thresholds established by
160 // the call to UseLowLooperThresholds() above.
161
162 // Suppress large verbosity from EM & hadronic processes
163 G4EmParameters::Instance()->SetVerbose(0);
164 G4HadronicParameters::Instance()->SetVerboseLevel(0);
165
166 // Initialize G4 kernel
167 //
168 runManager->Initialize();
169
170 // Initialize visualization
171 //
172 // G4VisExecutive can take a verbosity argument - see /vis/verbose
173 G4VisManager* visManager = new G4VisExecutive("Quiet");
174 visManager->Initialize();
175
176 // Get the pointer to the User Interface manager
177 //
178 G4UImanager* UImanager = G4UImanager::GetUIpointer();
179
180 if (!ui) // batch mode
181 {
182 G4String command = "/control/execute ";
183 G4String fileName = argv[1];
184 UImanager->ApplyCommand(command+fileName);
185 }
186 else
187 { // interactive mode : define UI session
188 UImanager->ApplyCommand("/control/execute init_vis.mac");
189 if (ui->IsGUI())
190 UImanager->ApplyCommand("/control/execute gui.mac");
191 ui->SessionStart();
192 delete ui;
193 }
194
195 // Statistics of tracks killed by G4Transportation are currently
196 // printed in the RunAction's EndOfEvent action.
197 // ( Eventually a summary could be provided here instead or as well. )
198
199 delete visManager;
200 delete runManager;
201
202 return 0;
203}
204
205//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the F01ActionInitialization class.
Definition of the F01DetectorConstruction class.
Definition of the F01SteppingVerbose class.
Action initialization class.
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration