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

Main program of the pdb4dna example. More...

#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "CommandLineParser.hh"
Include dependency graph for pdb4dna.cc:

Go to the source code of this file.

Functions

CommandLineParserparser (0)
 
void Parse (int &argc, char **argv)
 
int main (int argc, char **argv)
 

Detailed Description

Main program of the pdb4dna example.

Definition in file pdb4dna.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file pdb4dna.cc.

69 {
71  // Parse options given in commandLine
72  //
73  Parse(argc, argv);
74 
75  // Set the Seed
76  CLHEP::RanecuEngine defaultEngine(1234567);
77  G4Random::setTheEngine(&defaultEngine);
78 
79  // Choose the Random engine
80  //
82 
84  // Construct the run manager according to whether MT is activated or not
85  //
86  Command* commandLine(0);
87 
88 #ifdef G4MULTITHREADED
89  G4MTRunManager* runManager= new G4MTRunManager;
90  if ((commandLine = parser->GetCommandIfActive("-mt")))
91  {
92  int nThreads = 2;
93  if(commandLine->GetOption() == "NMAX")
94  {
96  }
97  else
98  {
99  nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
100  }
101  G4cout << "===== PDB4DNA is started with "
102  << runManager->GetNumberOfThreads()
103  << " threads =====" << G4endl;
104 
105  runManager->SetNumberOfThreads(nThreads);
106  }
107 #else
108  G4RunManager* runManager = new G4RunManager();
109 #endif
110 
111  // Set user classes
112  //
113  runManager->SetUserInitialization(new DetectorConstruction());
114  runManager->SetUserInitialization(new PhysicsList);
115  runManager->SetUserInitialization(new ActionInitialization());
116 
117  // Initialize G4 keRnel
118  //
119  // runManager->Initialize();
120 
121  // Initialize visualization
122  G4VisManager* visManager = new G4VisExecutive;
123  visManager->Initialize();
124 
125  // Get the pointer to the User Interface manager
126  G4UImanager* UImanager = G4UImanager::GetUIpointer();
127  G4UIExecutive* ui(0);
128 
129  // interactive mode : define UI session
130  if ((commandLine = parser->GetCommandIfActive("-gui")))
131  {
132  ui = new G4UIExecutive(argc, argv,
133  commandLine->GetOption());
134 
135  if(parser->GetCommandIfActive("-novis") == 0)
136  // visualization is used by default
137  {
138  if ((commandLine = parser->GetCommandIfActive("-vis")))
139  // select a visualization driver if needed (e.g. HepFile)
140  {
141  UImanager->ApplyCommand(G4String("/vis/open ")+
142  commandLine->GetOption());
143  }
144  else
145  // by default OGL is used
146  {
147  UImanager->ApplyCommand("/vis/open OGL 600x600-0+0");
148  }
149  UImanager->ApplyCommand("/control/execute vis.mac");
150  }
151  if (ui->IsGUI())
152  UImanager->ApplyCommand("/control/execute gui.mac");
153  }
154  else
155  // to be use visualization file (= store the visualization into
156  // an external file:
157  // ASCIITree ; DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
158  {
159  if ((commandLine = parser->GetCommandIfActive("-vis")))
160  {
161  UImanager->ApplyCommand(G4String("/vis/open ")+
162  commandLine->GetOption());
163  UImanager->ApplyCommand("/control/execute vis.mac");
164  }
165  }
166 
167  if ((commandLine = parser->GetCommandIfActive("-mac")))
168  {
169  G4String command = "/control/execute ";
170  UImanager->ApplyCommand(command + commandLine->GetOption());
171  }
172  else
173  {
174  UImanager->ApplyCommand("/control/execute init.mac");
175  }
176 
177  if ((commandLine = parser->GetCommandIfActive("-gui")))
178  {
179 #ifdef G4UI_USE_QT
180  G4UIQt* UIQt = static_cast<G4UIQt*> (UImanager->GetG4UIWindow());
181  if ( UIQt) {
182  UIQt->AddViewerTabFromFile("README", "README from "+ G4String(argv[0]));
183  }
184 #endif
185  ui->SessionStart();
186  delete ui;
187  }
188 
189  // Job termination
190  delete visManager;
191  delete runManager;
192 
193  return 0;
194 }
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
Detector construction class to define materials and geometry.
#define G4endl
Definition: G4ios.hh:61
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
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 ( )