55 #include "ParRunManager.hh"
57 #include "MarshaledG4HCofThisEvent.h"
63 using namespace CLHEP;
71 G4int ParRunManager::n_event;
72 G4int ParRunManager::n_select;
80 TOPC_BUF ParRunManager::MyDoEvent(
void *input_buf ) {
81 return myRunManager->DoEvent(input_buf);
83 TOPC_ACTION ParRunManager::MyCheckEventResult(
void * input_buf,
void *buf ) {
84 return myRunManager->CheckEventResult(input_buf, buf);
88 static void trace_event_input(
void *input ) {
99 TOPC_OPT_trace_input = trace_event_input;
104 cout <<
"ParRunManager::DoEventLoop" << endl;
115 if(n_select<0) n_select = n_event;
116 msg =
"/control/execute ";
131 if ( eventManager->GetUserEventAction() ) {
132 origUserEventAction = eventManager->GetUserEventAction();
137 ImportDoEventLoopLocals( stateManager, n_event, n_select, msg );
141 g_Seeds = (
long*)calloc(n_event,
sizeof(
long));
144 for( i_event=0; i_event<n_event; i_event++ )
150 TOPC_raw_begin_master_slave(MyDoEvent, MyCheckEventResult, NULL);
152 if(TOPC_is_master()){
154 for( i_event=0; i_event<n_event; i_event++ )
156 TOPC_raw_submit_task_input(TOPC_MSG( &i_event,
sizeof(
G4int)));
157 if (runAborted)
break;
160 TOPC_raw_end_master_slave();
164 if ( verboseLevel > 0 ) {
171 G4cout <<
" Number of events processed : " << n_event <<
G4endl;
179 TOPC_BUF ParRunManager::DoEvent(
void *input_buf )
183 memcpy(&i_event, input_buf,
sizeof(
G4int));
189 currentEvent = GenerateEvent(i_event);
190 eventManager->ProcessOneEvent(currentEvent);
194 if(aMarshaledObj)
delete aMarshaledObj;
199 StackPreviousEvent( currentEvent );
201 return TOPC_MSG( aMarshaledObj->getBuffer(), aMarshaledObj->getBufferSize());
205 TOPC_ACTION ParRunManager::CheckEventResult(
void * input_buf,
void *output_buf )
208 memcpy(&i_event, input_buf,
sizeof(
G4int));
215 if ( !userPrimaryGeneratorAction ) {
216 G4Exception(
"ParRunManager::CheckEventResult",
"InvalidSetup",
218 "G4VUserPrimaryGeneratorAction is not defined.");
222 currentEvent =
new G4Event( i_event );
230 eventManager->ProcessOneEvent( currentEvent );
238 marshaledObj.unmarshalTo(HCE);
239 if(oldCE)
delete(oldCE);
241 currentEvent->SetHCofThisEvent(HCE);
245 if ( origUserEventAction )
246 origUserEventAction->BeginOfEventAction( currentEvent );
248 if ( origUserEventAction )
249 origUserEventAction->EndOfEventAction( currentEvent );
251 AnalyzeEvent(currentEvent);
256 StackPreviousEvent(currentEvent);