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

Implementation of the microdosimetry example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4VisExecutive.hh"
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "CommandLineParser.hh"
Include dependency graph for wholeNuclearDNA.cc:

Go to the source code of this file.

Functions

CommandLineParserparser (0)
 
void Parse (int &argc, char **argv)
 
int main (int argc, char **argv)
 
void GetNameAndPathOfExecutable (char **argv, G4String &executable, G4String &path)
 

Detailed Description

Implementation of the microdosimetry example.

Definition in file wholeNuclearDNA.cc.

Function Documentation

void GetNameAndPathOfExecutable ( char **  argv,
G4String executable,
G4String path 
)

Definition at line 191 of file wholeNuclearDNA.cc.

194 {
195  // Get the last position of '/'
196  std::string aux(argv[0]);
197 
198  // get '/' or '\\' depending on unix/mac or windows.
199 #if defined(_WIN32) || defined(WIN32)
200  int pos = aux.rfind('\\');
201 #else
202  int pos = aux.rfind('/');
203 #endif
204 
205  // Get the path and the name
206  path = aux.substr(0, pos + 1);
207  executable = aux.substr(pos + 1);
208 }
static const G4double pos
int main ( int  argc,
char **  argv 
)

Definition at line 65 of file wholeNuclearDNA.cc.

66 {
67  // Choose the Random engine
68 
69  G4Random::setTheEngine(new CLHEP::RanecuEngine);
70 
72  // Parse options given in commandLine
73  //
74  Parse(argc, argv);
75 
77  // Construct the run manager according to whether MT is activated or not
78  //
79  Command* commandLine(0);
80 
81 #ifdef G4MULTITHREADED
82  G4MTRunManager* runManager= new G4MTRunManager;
83  if ((commandLine = parser->GetCommandIfActive("-mt")))
84  {
85  int nThreads = 2;
86  if(commandLine->GetOption() == "NMAX")
87  {
89  }
90  else
91  {
92  nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
93  }
94  G4cout << "===== WholeNuclearDNA is started with "
95  << runManager->GetNumberOfThreads()
96  << " threads =====" << G4endl;
97 
98  runManager->SetNumberOfThreads(nThreads);
99  }
100 #else
101  G4RunManager* runManager = new G4RunManager();
102 #endif
103 
104  // Set mandatory user initialization classes
106  runManager->SetUserInitialization(detector);
107  runManager->SetUserInitialization(new PhysicsList);
108  runManager->SetUserInitialization(new ActionInitialization());
109 
110  // Initialize G4 kernel
111  runManager->Initialize();
112 
113  // Initialize visualization
114  G4VisManager* visManager = new G4VisExecutive;
115  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
116  // G4VisManager* visManager = new G4VisExecutive("Quiet");
117  visManager->Initialize();
118 
119  // Get the pointer to the User Interface manager
120  G4UImanager* UImanager = G4UImanager::GetUIpointer();
121  G4UIExecutive* ui(0);
122 
123  // interactive mode : define UI session
124  if ((commandLine = parser->GetCommandIfActive("-gui")))
125  {
126  ui = new G4UIExecutive(argc, argv,
127  commandLine->GetOption());
128 
129  if(ui->IsGUI())
130  UImanager->ApplyCommand("/control/execute gui.mac");
131 
132  if(parser->GetCommandIfActive("-novis") == 0)
133  // visualization is used by default
134  {
135  if((commandLine = parser->GetCommandIfActive("-vis")))
136  // select a visualization driver if needed (e.g. HepFile)
137  {
138  UImanager->ApplyCommand(G4String("/vis/open ")+
139  commandLine->GetOption());
140  }
141  else
142  // by default OGL is used
143  {
144  UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
145  }
146  UImanager->ApplyCommand("/control/execute vis.mac");
147  }
148  }
149  else
150  // to be use visualization file (= store the visualization into
151  // an external file:
152  // ASCIITree ; DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
153  {
154  if ((commandLine = parser->GetCommandIfActive("-vis")))
155  {
156  UImanager->ApplyCommand(G4String("/vis/open ")+commandLine->GetOption());
157  UImanager->ApplyCommand("/control/execute vis.mac");
158  }
159  }
160 
161  if ((commandLine = parser->GetCommandIfActive("-mac")))
162  {
163  G4String command = "/control/execute ";
164  UImanager->ApplyCommand(command + commandLine->GetOption());
165  }
166  else
167  {
168  UImanager->ApplyCommand("/control/execute wholeNuclearDNA.in");
169  }
170 
171  if ((commandLine = parser->GetCommandIfActive("-gui")))
172  {
173 #ifdef G4UI_USE_QT
174  G4UIQt* UIQt = static_cast<G4UIQt*> (UImanager->GetG4UIWindow());
175  if ( UIQt) {
176  UIQt->AddViewerTabFromFile("README", "README from "+ G4String(argv[0]));
177  }
178 #endif
179  ui->SessionStart();
180  delete ui;
181  }
182 
183  delete visManager;
184  delete runManager;
185 
186  return 0;
187 }
void Parse(int &argc, char **argv)
Definition: chem1.cc:193
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
Command * GetCommandIfActive(const G4String &marker)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:143
G4int GetNumberOfThreads() const
CommandLineParser * parser(0)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void Initialize()
G4UIsession * GetG4UIWindow() const
Definition: G4UImanager.hh:210
virtual void Initialize()
Detector construction class to define materials and geometry.
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
Physics list class.
Definition: PhysicsList.hh:47

Here is the call graph for this function:

void Parse ( int argc,
char **  argv 
)
CommandLineParser* parser ( )