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 "G4VisExecutive.hh"
#include "G4UIExecutive.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 75 of file exampleB2b.cc.
References startWork().
78 G4UIExecutive* ui = 0;
80 ui =
new G4UIExecutive(argc, argv);
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);
135 UImanager->ApplyCommand(
"/control/execute init.mac");
137 UImanager->ApplyCommand(
"/control/execute gui.mac");
143 G4Thread* aThread =
new G4Thread;
144 G4THREADCREATE(aThread,
startWork, static_cast<G4ThreadFunArgType>(&tasks));
G4ThreadFunReturnType startWork(G4ThreadFunArgType arg)
G4ThreadFunReturnType startWork |
( |
G4ThreadFunArgType |
arg | ) |
|
Definition at line 59 of file exampleB2b.cc.
References e.
Referenced by main().
61 tbb::task_list* tasks =
static_cast<tbb::task_list*
>(arg);
65 std::cout<<
"Now calling 'tbb::task::spawn_work_and_wait' "<<std::endl;
66 tbb::task::spawn_root_and_wait( *tasks );
68 std::cerr<<
"Error occurred. Error info is:\""<<e.what()<<
"\""<<std::endl;
70 return static_cast<G4ThreadFunReturnType
>(0);
cet::coded_exception< error, detail::translate > exception