Main program of the B2b example.
More...
#include "B2bDetectorConstruction.hh"
#include "B2ActionInitialization.hh"
#include "tbbUserWorkerInitialization.hh"
#include "SimpleTbbMasterRunManager.hh"
#include "G4Threading.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include <tbb/task_scheduler_init.h>
#include <tbb/task.h>
Go to the source code of this file.
|
G4ThreadFunReturnType | startWork (G4ThreadFunArgType arg) |
|
int | main (int argc, char **argv) |
|
Main program of the B2b example.
Definition in file exampleB2b.cc.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 81 of file exampleB2b.cc.
References startWork().
85 G4Random::setTheEngine(
new CLHEP::RanecuEngine);
87 unsigned int numCoresAvailable= G4Threading::G4GetNumberOfCores();
88 unsigned int numberOfCoresToUse= (numCoresAvailable > 1 ) ? 2 : 1 ;
90 tbb::task_scheduler_init init( numberOfCoresToUse );
93 SimpleTbbMasterRunManager* runManager =
new SimpleTbbMasterRunManager;
97 runManager->SetNumberEventsPerTask(1);
98 runManager->SetTaskList(&tasks);
101 runManager->SetUserInitialization(
new tbbUserWorkerInitialization );
106 runManager->SetUserInitialization(
new B2bDetectorConstruction());
108 G4VModularPhysicsList* physicsList =
new FTFP_BERT;
109 physicsList->RegisterPhysics(
new G4StepLimiterPhysics());
110 runManager->SetUserInitialization(physicsList);
114 runManager->SetUserInitialization(
new B2ActionInitialization());
118 runManager->Initialize();
121 G4UImanager* UImanager = G4UImanager::GetUIpointer();
125 G4String command =
"/control/execute ";
127 UImanager->ApplyCommand(command+fileName);
133 runManager->BeamOn(nEvents);
136 G4UIExecutive* ui =
new G4UIExecutive(argc, argv);
137 UImanager->ApplyCommand(
"/control/execute init.mac");
139 UImanager->ApplyCommand(
"/control/execute gui.mac");
147 G4THREADCREATE(&aThread,
startWork,static_cast<G4ThreadFunArgType>(&tasks));
150 G4THREADJOIN(aThread);
G4ThreadFunReturnType startWork(G4ThreadFunArgType arg)
G4ThreadFunReturnType startWork |
( |
G4ThreadFunArgType |
arg | ) |
|
Definition at line 65 of file exampleB2b.cc.
References e.
Referenced by main().
67 tbb::task_list* tasks =
static_cast<tbb::task_list*
>(arg);
71 std::cout<<
"Now calling 'tbb::task::spawn_work_and_wait' "<<std::endl;
72 tbb::task::spawn_root_and_wait( *tasks );
74 std::cerr<<
"Error occurred. Error info is:\""<<e.what()<<
"\""<<std::endl;
76 return static_cast<G4ThreadFunReturnType
>(0);
cet::coded_exception< error, detail::translate > exception