** Warning **
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle dbname=lxr_eic at /usr/local/share/lxr/lxr-2.3.7/lib/LXR/Common.pm line 1161, <GEN27> line 1.
Last-Modified: Wed, 1 Dec 2026 10:33:04 GMT
Content-Type: text/html; charset=utf-8
/master/geant4/examples/extended/field/field06/field06.cc
File indexing completed on 2026-12-01 09:29:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef WIN32
0030 # include <unistd.h >
0031 #endif
0032
0033 #include "F06ActionInitialization.hh "
0034 #include "F06DetectorConstruction.hh "
0035 #include "F06PhysicsList.hh "
0036
0037 #include "G4RunManagerFactory.hh "
0038 #include "G4Transportation.hh "
0039 #include "G4Types.hh "
0040 #include "G4UIExecutive.hh "
0041 #include "G4UIcommand.hh "
0042 #include "G4UImanager.hh "
0043 #include "G4VisExecutive.hh "
0044 #include "Randomize.hh "
0045
0046
0047 namespace
0048 {
0049 void PrintUsage ()
0050 {
0051 G4cerr << " Usage: " << G4endl ;
0052 G4cerr << " field06 [-m macro ] [-u UIsession] [-t nThreads] [-r randomSeed] " << G4endl ;
0053 G4cerr << " note: -t option is available only for multi-threaded mode." << G4endl ;
0054 }
0055 }
0056
0057
0058
0059 int main (int argc , char ** argv )
0060 {
0061
0062
0063 if (argc > 9) {
0064 PrintUsage ();
0065 return 1;
0066 }
0067
0068 G4String macro ;
0069 G4String session ;
0070 G4int nThreads = 0;
0071
0072 G4long randomSeed = 1234;
0073 for (G4int i = 1; i < argc ; i = i + 2) {
0074 if (G4String (argv [i ]) == "-m" )
0075 macro = argv [i + 1];
0076 else if (G4String (argv [i ]) == "-u" )
0077 session = argv [i + 1];
0078 else if (G4String (argv [i ]) == "-r" )
0079 randomSeed = atoi (argv [i + 1]);
0080 else if (G4String (argv [i ]) == "-t" ) {
0081 nThreads = G4UIcommand ::ConvertToInt (argv [i + 1]);
0082 }
0083 else {
0084 PrintUsage ();
0085 return 1;
0086 }
0087 }
0088
0089
0090 G4UIExecutive * ui = nullptr;
0091 if (macro .size () == 0) {
0092 ui = new G4UIExecutive (argc , argv , session );
0093 }
0094
0095
0096
0097 auto * runManager = G4RunManagerFactory ::CreateRunManager ();
0098 if (nThreads > 0) runManager ->SetNumberOfThreads (nThreads );
0099
0100
0101 G4Random ::setTheSeed (randomSeed );
0102
0103
0104
0105
0106 runManager ->SetUserInitialization (new F06DetectorConstruction ());
0107
0108 runManager ->SetUserInitialization (new F06PhysicsList ());
0109
0110
0111 G4Transportation ::EnableGravity (true );
0112
0113
0114 runManager ->SetUserInitialization (new F06ActionInitialization ());
0115
0116
0117
0118 G4VisManager * visManager = new G4VisExecutive ;
0119
0120
0121 visManager ->Initialize ();
0122
0123
0124
0125 G4UImanager * UImanager = G4UImanager ::GetUIpointer ();
0126
0127 if (!ui ) {
0128
0129 G4String command = "/control/execute " ;
0130 UImanager ->ApplyCommand (command + macro );
0131 }
0132 else {
0133 UImanager ->ApplyCommand ("/control/execute init_vis.mac" );
0134 if (ui ->IsGUI ()) UImanager ->ApplyCommand ("/control/execute gui.mac" );
0135 ui ->SessionStart ();
0136 delete ui ;
0137 }
0138
0139
0140
0141
0142
0143
0144 delete visManager ;
0145 delete runManager ;
0146
0147 return 0;
0148 }
0149
0150