30 #include "B2bDetectorConstruction.hh" 31 #include "B2ActionInitialization.hh" 34 #include "tbbUserWorkerInitialization.hh" 35 #include "SimpleTbbMasterRunManager.hh" 36 #include "G4Threading.hh" 38 #include "G4UImanager.hh" 39 #include "FTFP_BERT.hh" 40 #include "G4StepLimiterPhysics.hh" 42 #include "Randomize.hh" 44 #include "G4VisExecutive.hh" 45 #include "G4UIExecutive.hh" 48 #include <tbb/task_scheduler_init.h> 59 G4ThreadFunReturnType
startWork(G4ThreadFunArgType arg)
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);
75 int main(
int argc,
char** argv)
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));
int main(int argc, char **argv)
G4ThreadFunReturnType startWork(G4ThreadFunArgType arg)
cet::coded_exception< error, detail::translate > exception