Loading...
Searching...
No Matches
Functions
field01.cc File Reference

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

#include "G4Types.hh"
#include "F01SteppingVerbose.hh"
#include "G4RunManagerFactory.hh"
#include "F01DetectorConstruction.hh"
#include "F01ActionInitialization.hh"
#include "F01RunAction.hh"
#include "G4UImanager.hh"
#include "G4EmParameters.hh"
#include "G4HadronicParameters.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"
#include "G4TransportationParameters.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 70 of file field01.cc.

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}
Action initialization class.

Applications | User Support | Publications | Collaboration