57 #include "ParRunManager.hh"
59 #include "MarshaledG4HCofThisEvent.h"
65 using namespace CLHEP;
73 G4int ParRunManager::n_event;
74 G4int ParRunManager::n_select;
82 TOPC_BUF ParRunManager::MyDoEvent(
void *input_buf ) {
83 return myRunManager->DoEvent(input_buf);
85 TOPC_ACTION ParRunManager::MyCheckEventResult(
void * input_buf,
void *buf ) {
86 return myRunManager->CheckEventResult(input_buf, buf);
90 static void trace_event_input(
void *input ) {
101 TOPC_OPT_trace_input = trace_event_input;
106 cout <<
"ParRunManager::DoEventLoop" << endl;
117 if(n_select<0) n_select = n_event;
118 msg =
"/control/execute ";
133 if ( eventManager->GetUserEventAction() ) {
134 origUserEventAction = eventManager->GetUserEventAction();
139 ImportDoEventLoopLocals( stateManager, n_event, n_select, msg );
143 g_Seeds = (
long*)calloc(n_event,
sizeof(
long));
146 for( i_event=0; i_event<n_event; i_event++ )
152 TOPC_raw_begin_master_slave(MyDoEvent, MyCheckEventResult, NULL);
154 if(TOPC_is_master()){
156 for( i_event=0; i_event<n_event; i_event++ )
158 TOPC_raw_submit_task_input(TOPC_MSG( &i_event,
sizeof(
G4int)));
159 if (runAborted)
break;
162 TOPC_raw_end_master_slave();
166 if ( verboseLevel > 0 ) {
173 G4cout <<
" Number of events processed : " << n_event <<
G4endl;
181 TOPC_BUF ParRunManager::DoEvent(
void *input_buf )
185 memcpy(&i_event, input_buf,
sizeof(
G4int));
191 currentEvent = GenerateEvent(i_event);
192 eventManager->ProcessOneEvent(currentEvent);
196 if(aMarshaledObj)
delete aMarshaledObj;
201 StackPreviousEvent( currentEvent );
203 return TOPC_MSG( aMarshaledObj->getBuffer(), aMarshaledObj->getBufferSize());
207 TOPC_ACTION ParRunManager::CheckEventResult(
void * input_buf,
void *output_buf )
210 memcpy(&i_event, input_buf,
sizeof(
G4int));
217 if ( !userPrimaryGeneratorAction ) {
218 G4Exception(
"ParRunManager::CheckEventResult",
"InvalidSetup",
220 "G4VUserPrimaryGeneratorAction is not defined.");
224 currentEvent =
new G4Event( i_event );
232 eventManager->ProcessOneEvent( currentEvent );
240 marshaledObj.unmarshalTo(HCE);
241 if(oldCE)
delete(oldCE);
243 currentEvent->SetHCofThisEvent(HCE);
247 if ( origUserEventAction )
248 origUserEventAction->BeginOfEventAction( currentEvent );
250 if ( origUserEventAction )
251 origUserEventAction->EndOfEventAction( currentEvent );
253 AnalyzeEvent(currentEvent);
258 StackPreviousEvent(currentEvent);