Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
field04.cc File Reference

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

#include <unistd.h>
#include "F04SteppingVerbose.hh"
#include "G4RunManager.hh"
#include "F04PhysicsList.hh"
#include "F04DetectorConstruction.hh"
#include "F04ActionInitialization.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
Include dependency graph for field04.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the field/field04 example.

Definition in file field04.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file field04.cc.

78 {
79  // Choose the Random engine
80  //
81  G4Random::setTheEngine(new CLHEP::RanecuEngine);
82 
83  G4int myseed = 1234;
84  if (argc > 2) myseed = atoi(argv[argc-1]);
85 
86  // Construct the default run manager
87  //
88 #ifdef G4MULTITHREADED
89  G4MTRunManager * runManager = new G4MTRunManager;
90 #else
92  G4RunManager * runManager = new G4RunManager;
93 #endif
94 
95  G4Random::setTheSeed(myseed);
96 
97  G4String physicsList = "QGSP_BERT";
98 
99 #ifndef WIN32
100  G4int c = 0;
101  while ((c=getopt(argc,argv,"p")) != -1)
102  {
103  switch (c)
104  {
105  case 'p':
106  physicsList = optarg;
107  G4cout << "Physics List used is " << physicsList << G4endl;
108  break;
109  case ':': /* -p without operand */
110  fprintf(stderr,"Option -%c requires an operand\n", optopt);
111  break;
112  case '?':
113  fprintf(stderr,"Unrecognised option: -%c\n", optopt);
114  }
115  }
116 #endif
117 
118  // Set mandatory initialization classes
119  //
120  // Detector construction
122  runManager->SetUserInitialization(detector);
123  // Physics list
124  runManager->SetUserInitialization(new F04PhysicsList(physicsList));
125  // User action initialization
126  runManager->SetUserInitialization(new F04ActionInitialization(detector));
127 
128  // Initialize G4 kernel
129  //
130  //runManager->Initialize();
131 
132 #ifdef G4VIS_USE
133  // Initialize visualization
134  //
135  G4VisManager* visManager = new G4VisExecutive;
136  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
137  // G4VisManager* visManager = new G4VisExecutive("Quiet");
138  visManager->Initialize();
139 #endif
140 
141  // Get the pointer to the User Interface manager
142  //
143  G4UImanager* UImanager = G4UImanager::GetUIpointer();
144 
145 #ifndef WIN32
146  G4int optmax = argc;
147  if (argc > 2) { optmax = optmax-1; }
148 
149  if (optind < optmax)
150  {
151  G4String command = "/control/execute ";
152  for ( ; optind < optmax; optind++)
153  {
154  G4String macroFilename = argv[optind];
155  UImanager->ApplyCommand(command+macroFilename);
156  }
157  }
158 #else // Simple UI for Windows runs, no possibility of additional arguments
159  if (argc!=1) // batch mode
160  {
161  G4String command = "/control/execute ";
162  G4String fileName = argv[1];
163  UImanager->ApplyCommand(command+fileName);
164  }
165 #endif
166  else
167  {
168  // Define (G)UI terminal for interactive mode
169 #ifdef G4UI_USE
170  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
171 #ifdef G4VIS_USE
172 // UImanager->ApplyCommand("/control/execute vis.mac");
173  G4cout << "At the prompt, issue commands to set up detector & field, then:"
174  << G4endl;
175  G4cout << "/run/initialize" << G4endl;
176  G4cout << "Then if you want a viewer:"<< G4endl;
177  G4cout << "/control/execute vis.mac" << G4endl;
178  G4cout << "Then: " << G4endl;
179  G4cout << "/run/beamOn … etc." << G4endl;
180 #endif
181  if (ui->IsGUI())
182  UImanager->ApplyCommand("/control/execute gui.mac");
183  ui->SessionStart();
184  delete ui;
185 #endif
186  }
187 
188  // Job termination
189  // Free the store: user actions, physics_list and detector_description are
190  // owned and deleted by the run manager, so they should not
191  // be deleted in the main() program !
192 
193 #ifdef G4VIS_USE
194  delete visManager;
195 #endif
196  delete runManager;
197 
198  return 0;
199 }
Action initialization class.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int optind
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
int optopt
#define G4endl
Definition: G4ios.hh:61
char * optarg
G4bool IsGUI() const
tuple c
Definition: test.py:13
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function: