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

clustering example More...

#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4DNAChemistryManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "CommandLineParser.hh"
Include dependency graph for clustering.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

clustering example

Definition in file clustering.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 59 of file clustering.cc.

60 {
62  // Parse options given in commandLine
63  //
64  Parse(argc, argv);
65 
67  // Construct the run manager according to whether MT is activated or not
68  //
69  Command* commandLine(0);
70 
71 #ifdef G4MULTITHREADED
72  G4MTRunManager* runManager= new G4MTRunManager;
73  if ((commandLine = parser->GetCommandIfActive("-mt")))
74  {
75  int nThreads = 2;
76  if(commandLine->GetOption() == "NMAX")
77  {
79  }
80  else
81  {
82  nThreads = G4UIcommand::ConvertToInt(commandLine->GetOption());
83  }
84  G4cout << "===== clustering is started with "
85  << runManager->GetNumberOfThreads()
86  << " threads =====" << G4endl;
87 
88  runManager->SetNumberOfThreads(nThreads);
89  }
90 #else
91  G4RunManager* runManager = new G4RunManager();
92 #endif
93 
95  // Set mandatory user initialization classes
96  //
98  runManager->SetUserInitialization(new PhysicsList);
99  runManager->SetUserInitialization(detector);
100  runManager->SetUserInitialization(new ActionInitialization());
101 
102  // Initialize G4 kernel
103  runManager->Initialize();
104 
105  // Initialize visualization
106  G4VisManager* visManager = new G4VisExecutive;
107  visManager->Initialize();
108 
109  // Get the pointer to the User Interface manager
110  G4UImanager* UImanager = G4UImanager::GetUIpointer();
111  G4UIExecutive* ui(0);
112 
113  // interactive mode : define UI session
114  if ((commandLine = parser->GetCommandIfActive("-gui")))
115  {
116  ui = new G4UIExecutive(argc, argv, commandLine->GetOption());
117 
118  if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac");
119 
120  if (parser->GetCommandIfActive("-novis") == 0)
121  // visualization is used by default
122  {
123  if ((commandLine = parser->GetCommandIfActive("-vis")))
124  // select a visualization driver if needed (e.g. HepFile)
125  {
126  UImanager->ApplyCommand(
127  G4String("/vis/open ") + commandLine->GetOption());
128  }
129  else
130  // by default OGL is used
131  {
132  UImanager->ApplyCommand("/vis/open OGL 800x600-0+0");
133  }
134  UImanager->ApplyCommand("/control/execute vis.mac");
135  }
136  }
137  else
138  // to be use visualization file (= store the visualization into
139  // an external file:
140  // ASCIITree ; DAWNFILE ; HepRepFile ; VRML(1,2)FILE ; gMocrenFile ...
141  {
142  if ((commandLine = parser->GetCommandIfActive("-vis")))
143  {
144  UImanager->ApplyCommand(
145  G4String("/vis/open ") + commandLine->GetOption());
146  UImanager->ApplyCommand("/control/execute vis.mac");
147  }
148  }
149 
150  if ((commandLine = parser->GetCommandIfActive("-mac")))
151  {
152  G4String command = "/control/execute ";
153  UImanager->ApplyCommand(command + commandLine->GetOption());
154  }
155  else
156  {
157  UImanager->ApplyCommand("/control/execute run.in");
158  }
159 
160  if ((commandLine = parser->GetCommandIfActive("-gui")))
161  {
162  ui->SessionStart();
163  delete ui;
164  }
165 
166  // Job termination
167  // Free the store: user actions, physics_list and detector_description are
168  // owned and deleted by the run manager, so they should not be deleted
169  // in the main() program !
170 
171  delete visManager;
172  delete runManager;
173 
174  CommandLineParser::DeleteInstance();
175 
176  return 0;
177 }
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()
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 ( )