Import Geant4 7.0.0 source tree
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02ChamberParameterisation.cc,v 1.2 2003/12/03 14:15:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02DetectorConstruction.cc,v 1.2 2003/12/03 14:15:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02DetectorMessenger.cc,v 1.3 2003/12/03 14:15:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02EventAction.cc,v 1.1 2002/03/05 15:22:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02MagneticField.cc,v 1.1 2002/03/05 15:22:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
// User Field class implementation.
|
||||
//
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02PhysicsList.cc,v 1.3 2003/12/03 14:15:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02PrimaryGeneratorAction.cc,v 1.1 2002/03/05 15:22:01 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02RunAction.cc,v 1.1 2002/03/05 15:22:01 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02SteppingAction.cc,v 1.1 2002/03/05 15:22:01 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02SteppingVerbose.cc,v 1.3 2003/12/03 14:15:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02TrackerHit.cc,v 1.2 2003/07/04 15:36:51 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02TrackerSD.cc,v 1.2 2003/07/04 15:36:51 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: ExN02VisManager.cc,v 1.3 2003/11/13 15:11:38 johna Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00-patch-01 $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
//
|
||||
//
|
||||
// John Allison 24th January 1998.
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParExN02MarshaledHits.cc,v 1.1 2002/03/05 15:22:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
// Customize this file for your application.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "ParExMarshaledHits.hh"
|
||||
#include "ParMarshaledObj.hh"
|
||||
#include "ExN02TrackerHit.hh"
|
||||
|
||||
// =====================================================================
|
||||
// Must define MarshalHit and UnmarshalHit for each derived class of G4VHit
|
||||
|
||||
// MarshalHit() and UnmarshalHit() have defaults given by the member
|
||||
// function of TMarshaledHitsCollection<T>.
|
||||
// The default copies the entire class into a single buffer. If your
|
||||
// hit class includes pointers, and if you use those pointer in your
|
||||
// analysis (AnalyzeEvent), then you will need to override the default
|
||||
// with an explicit specialization that marshals the pointers.
|
||||
// You may also wish to override the default in order to write
|
||||
// more efficient marshaling code.
|
||||
|
||||
// See ParExMarshaledHits.cc-N04-efficient for an example of overriding
|
||||
// the default.
|
||||
|
||||
// =====================================================================
|
||||
// Dispatch marshaling and unmarshaling of HC's according to type of G4VHit
|
||||
// When unmarshaling, we will see the "G4String HCname", and have
|
||||
// to create a HC of the correct type.
|
||||
// So, You must include an "if" or "else if" for each type of hit.
|
||||
|
||||
// NOTE TO MYSELF: Is there a cleaner way to do this?
|
||||
// If types were objects, we'd just set up a table here:
|
||||
// { {"trackerCollection", TMarshaledHitsCollection<ExN02TrackerHit>},
|
||||
// ... }
|
||||
// and then write general code to use the table.
|
||||
|
||||
void MarshaledHCofThisEvent::MarshalHitsCollection
|
||||
(G4VHitsCollection * aBaseHC, G4String HCname)
|
||||
{ if (HCname == "trackerCollection")
|
||||
((TMarshaledHitsCollection<ExN02TrackerHit> *)this)
|
||||
-> Marshal( aBaseHC );
|
||||
else G4Exception( "TMarshaledHitsCollection<T>::MarshaledHCofThisEvent :"
|
||||
" HCname, " + HCname + ", not found." );
|
||||
}
|
||||
|
||||
void MarshaledHCofThisEvent::UnmarshalSlaveHitsCollection(G4String & HCname, G4String & SDname)
|
||||
{ if (HCname == "trackerCollection")
|
||||
((TMarshaledHitsCollection<ExN02TrackerHit> *)this)
|
||||
-> UnmarshalSlaveHitsCollection( HCname, SDname );
|
||||
else G4Exception( "TMarshaledHitsCollection<T>::UnmarshalSlaveHitsCollection"
|
||||
" : HCname, " + HCname + ", not found." );
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParMarshaledObj.cc,v 1.1 2002/03/05 15:22:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-05-02-patch-01 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
// When we implement track level parallelism, we will use G4PrimaryTransformer.
|
||||
// We will also need to merge hits from several slaves. To do so, we will need
|
||||
// the following:
|
||||
// - MarshaledHCofThisEvent must also have a private const member:
|
||||
// const G4bool canMergeHits = false;
|
||||
// and a virtual method (not pure)
|
||||
// virtual void insertOrMerge(ExN02TrackerHit *);
|
||||
// - Then can create a derived class with constructor:
|
||||
// inline DerivedClassConstructor()
|
||||
// : canMergeHits(true),MarshaledHCofThisEventWithTemplate() {}
|
||||
// - And insertOrMerge() should be defined in the derived class
|
||||
// The logic for insertOrMerge() can usually be copied from
|
||||
// (for example) ExN02TrackerSD::ProcessHits
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "ParMarshaledObj.hh"
|
||||
|
||||
MarshaledHCofThisEvent::MarshaledHCofThisEvent(G4Event *anEvent)
|
||||
{ MarshalHitsCollection(anEvent); }
|
||||
|
||||
MarshaledHCofThisEvent::MarshaledHCofThisEvent()
|
||||
{ MarshalHitsCollection( G4RunManager::GetRunManager()-> GetCurrentEvent() ); }
|
||||
|
||||
void MarshaledHCofThisEvent::MarshalHitsCollection(const G4Event *anEvent)
|
||||
{
|
||||
// MarshaledHCofThisEvent() can be in class ParMarshaledObj
|
||||
// It can then be dispatched based on HCname to submarshaling
|
||||
// for correct class.
|
||||
|
||||
G4HCofThisEvent *HCE = anEvent->GetHCofThisEvent();
|
||||
G4int numHitsColl = HCE->GetNumberOfCollections();
|
||||
Marshal( numHitsColl );
|
||||
for (int i = 0; i < numHitsColl; i++) {
|
||||
// Use base class to find HCname.
|
||||
G4VHitsCollection *aBaseHC = HCE->GetHC(i);
|
||||
G4String SDname = aBaseHC->GetSDname();
|
||||
G4String HCname = aBaseHC->GetName();
|
||||
Marshal( SDname );
|
||||
Marshal( HCname );
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "Marshaled HCname: " << HCname << G4endl;
|
||||
G4cout << "Marshaled SDname: " << SDname << G4endl;
|
||||
#endif
|
||||
|
||||
MarshalHitsCollection(aBaseHC, HCname);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTES TO MYSELF:
|
||||
// G4SDManager::GetSDMpointer()->FindSensitiveDetector(SDname);
|
||||
|
||||
// IMPORTANT: all calls to Unmarshal must be in same order as
|
||||
// the calls to Marshal in the constructor.
|
||||
void MarshaledHCofThisEvent::UnmarshalSlaveHCofThisEvent()
|
||||
{
|
||||
/*
|
||||
G4HCofThisEvent *HCE = G4RunManager::GetRunManager()->
|
||||
GetCurrentEvent()->
|
||||
GetHCofThisEvent();
|
||||
*/
|
||||
G4int numHitsColl;
|
||||
Unmarshal( numHitsColl );
|
||||
for (int i = 0; i < numHitsColl; i++) {
|
||||
G4String SDname;
|
||||
G4String HCname;
|
||||
Unmarshal( SDname );
|
||||
Unmarshal( HCname );
|
||||
#ifdef TOPC_DEBUG
|
||||
G4cout << "HCname: " << HCname << G4endl;
|
||||
G4cout << "SDname: " << SDname << G4endl;
|
||||
#endif
|
||||
|
||||
UnmarshalSlaveHitsCollection(HCname, SDname);
|
||||
}
|
||||
}
|
||||
@@ -20,21 +20,12 @@
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ParRunManager.cc,v 1.6 2004/06/19 20:50:42 cooperma Exp $
|
||||
// GEANT4 tag $Name: geant4-06-02 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// Parallel Library for Geant4
|
||||
//
|
||||
// Gene Cooperman <gene@ccs.neu.edu>, 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifdef G4USE_TOPC
|
||||
|
||||
// G4Timer.hh has to be loaded *before* globals.hh...
|
||||
//
|
||||
#include "G4Timer.hh"
|
||||
|
||||
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
@@ -58,34 +49,44 @@
|
||||
#include "G4VVisManager.hh"
|
||||
|
||||
#include "ParRunManager.hh"
|
||||
#include "ParMarshaledObj.hh"
|
||||
#include "ParRandomState.hh"
|
||||
//include file for marshaling structures
|
||||
#include "MarshaledG4HCofThisEvent.h"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include <strstream>
|
||||
|
||||
// Define static data members of ParRunManager
|
||||
// They are set by ImportDoEventLoopLocals
|
||||
G4StateManager* ParRunManager::stateManager;
|
||||
G4int ParRunManager::n_event;
|
||||
G4int ParRunManager::n_select;
|
||||
G4String ParRunManager::msg;
|
||||
ParRunManager* ParRunManager::myRunManager = NULL;
|
||||
/*
|
||||
* The TopC call backs are implemented by using the 5 static data members to store
|
||||
* the data and using the 3 static member functions to point to the corresponding
|
||||
* functions of the singleton class instance.
|
||||
*/
|
||||
G4StateManager* ParRunManager::stateManager;
|
||||
G4int ParRunManager::n_event;
|
||||
G4int ParRunManager::n_select;
|
||||
G4String ParRunManager::msg;
|
||||
ParRunManager* ParRunManager::myRunManager = 0;
|
||||
|
||||
// TOP-C callbacks (static functions)
|
||||
// If this->*(&ParRunManager::GenerateEventInput), created a thunk,
|
||||
// it would be ideal here.
|
||||
TOPC_BUF ParRunManager::MyGenerateEventInput()
|
||||
{ return myRunManager->GenerateEventInput(); }
|
||||
TOPC_BUF ParRunManager::MyDoEvent( void *input_buf )
|
||||
{ return myRunManager->DoEvent(input_buf); }
|
||||
TOPC_ACTION ParRunManager::MyCheckEventResult( void * input_buf, void *buf )
|
||||
{ return myRunManager->CheckEventResult(input_buf, buf); }
|
||||
//cross-context variables
|
||||
static long* g_Seeds;
|
||||
|
||||
static void trace_event_input( void *input )
|
||||
{ G4cout << "Event " << *(G4int *)input << G4endl; }
|
||||
// TOP-C callbacks functions
|
||||
TOPC_BUF ParRunManager::MyDoEvent( void *input_buf ) {
|
||||
return myRunManager->DoEvent(input_buf);
|
||||
}
|
||||
TOPC_ACTION ParRunManager::MyCheckEventResult( void * input_buf, void *buf ) {
|
||||
return myRunManager->CheckEventResult(input_buf, buf);
|
||||
}
|
||||
|
||||
void ParRunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_select)
|
||||
|
||||
static void trace_event_input( void *input ) {
|
||||
//G4cout << "Event " << *(G4int *)input << G4endl;
|
||||
}
|
||||
|
||||
/*
|
||||
* DoEventLoop is the most important piece in RunManager class to control the program runs,
|
||||
* this is where we embed the TopC parallelism callbacks.
|
||||
*/
|
||||
void ParRunManager::DoEventLoop( G4int n_event, const char* macroFile, G4int n_select )
|
||||
{
|
||||
TOPC_OPT_trace_input = trace_event_input;
|
||||
|
||||
@@ -97,18 +98,17 @@ void ParRunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_sele
|
||||
return;
|
||||
#endif
|
||||
|
||||
if(verboseLevel>0)
|
||||
{ timer->Start(); }
|
||||
if ( verboseLevel > 0 ) { timer->Start(); }
|
||||
|
||||
|
||||
G4String msg;
|
||||
if(macroFile!=NULL)
|
||||
{
|
||||
if(n_select<0) n_select = n_event;
|
||||
if ( macroFile != 0 ) {
|
||||
if ( n_select < 0 ) n_select = n_event;
|
||||
msg = "/control/execute ";
|
||||
msg += macroFile;
|
||||
} else {
|
||||
n_select = -1;
|
||||
}
|
||||
else
|
||||
{ n_select = -1; }
|
||||
|
||||
// BeginOfEventAction() and EndOfEventAction() would normally be
|
||||
// called inside G4EventManager::ProcessOneEvent() in ParRunManager::DoEvent
|
||||
@@ -117,116 +117,131 @@ void ParRunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_sele
|
||||
// on master instead, to process hits. So, set user event action to NULL.
|
||||
// Keep private copy, and execute it in CheckTaskResult().
|
||||
// If user later does: SetUserAction( (G4UserEventAction *)NULL );
|
||||
// we won't notice and copy it to origUserEventAction.
|
||||
// How paranoid do we want to be? Should we create trvialUserEventAction?
|
||||
if ( eventManager->GetUserEventAction() )
|
||||
{
|
||||
// we won't notice and copy it to origUserEventAction.
|
||||
if ( eventManager->GetUserEventAction() ) {
|
||||
origUserEventAction = eventManager->GetUserEventAction();
|
||||
SetUserAction( (G4UserEventAction *)NULL );
|
||||
SetUserAction( (G4UserEventAction *)0 );
|
||||
}
|
||||
|
||||
// Make these variables accessible to TOP-C callback functions
|
||||
ImportDoEventLoopLocals( stateManager, n_event, n_select, msg );
|
||||
|
||||
// This is where all the parallelism occurs
|
||||
i_event = -1; // ParRunManager::GenerateEventInput() will increment this.
|
||||
TOPC_master_slave(MyGenerateEventInput, MyDoEvent, MyCheckEventResult, NULL);
|
||||
|
||||
if(verboseLevel>0)
|
||||
{
|
||||
// Setup random seeds for each slave
|
||||
g_Seeds = (long*)calloc(n_event, sizeof(long));
|
||||
|
||||
G4int i_event;
|
||||
for( i_event=0; i_event<n_event; i_event++ )
|
||||
{
|
||||
g_Seeds[i_event] = (long) (100000000L * HepRandom::getTheGenerator()->flat());
|
||||
}
|
||||
|
||||
// This is where all the parallelism occurs
|
||||
TOPC_raw_begin_master_slave(MyDoEvent, MyCheckEventResult, NULL);
|
||||
|
||||
if(TOPC_is_master()){
|
||||
G4int i_event;
|
||||
for( i_event=0; i_event<n_event; i_event++ )
|
||||
{
|
||||
TOPC_raw_submit_task_input(TOPC_MSG( &i_event, sizeof(G4int)));
|
||||
if (runAborted) break;
|
||||
}
|
||||
}
|
||||
TOPC_raw_end_master_slave();
|
||||
|
||||
free(g_Seeds);
|
||||
|
||||
if ( verboseLevel > 0 ) {
|
||||
timer->Stop();
|
||||
G4cout << "Run terminated." << G4endl;
|
||||
G4cout << "Run Summary" << G4endl;
|
||||
if(runAborted)
|
||||
/*
|
||||
{ G4cout << " Run Aborted after " << i_event << " events processed." << G4endl; }
|
||||
*/
|
||||
{ G4cout << " Run Aborted." << G4endl; }
|
||||
else
|
||||
{ G4cout << " Number of events processed : " << n_event << G4endl; }
|
||||
if ( runAborted ) {
|
||||
G4cout << " Run Aborted." << G4endl;
|
||||
} else {
|
||||
G4cout << " Number of events processed : " << n_event << G4endl;
|
||||
}
|
||||
G4cout << " " << *timer << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TOPC_BUF ParRunManager::GenerateEventInput()
|
||||
{
|
||||
if(runAborted) return NOTASK;
|
||||
|
||||
i_event++;
|
||||
if (i_event >= n_event) return NOTASK;
|
||||
else
|
||||
{ ParMarshaledRandomState buf = ParMarshaledRandomState( i_event );
|
||||
return TOPC_MSG( buf.GetBuffer(), buf.BufferSize() );
|
||||
}
|
||||
// else return TOPC_MSG( &i_event, sizeof(i_event) );
|
||||
}
|
||||
static MarshaledG4HCofThisEvent *aMarshaledObj = NULL;
|
||||
|
||||
TOPC_BUF ParRunManager::DoEvent( void *input_buf )
|
||||
{
|
||||
static
|
||||
G4int i_event;
|
||||
ParMarshaledRandomState buf = ParMarshaledRandomState( input_buf );
|
||||
buf.unmarshalEventIDandSetState( i_event );
|
||||
memcpy(&i_event, input_buf, sizeof(G4int));
|
||||
HepRandom::setTheSeed(g_Seeds[i_event]);
|
||||
|
||||
// removed for Geant4.6
|
||||
// stateManager->SetNewState(G4State_EventProc);
|
||||
// removed for Geant4.6
|
||||
// stateManager->SetNewState(G4State_EventProc);
|
||||
|
||||
currentEvent = GenerateEvent(i_event);
|
||||
currentEvent = GenerateEvent( i_event );
|
||||
eventManager->ProcessOneEvent( currentEvent );
|
||||
|
||||
eventManager->ProcessOneEvent(currentEvent);
|
||||
G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
|
||||
|
||||
MarshaledObj *aMarshaledObj = new MarshaledHCofThisEvent(currentEvent);
|
||||
return TOPC_MSG(aMarshaledObj->GetBuffer(), aMarshaledObj->BufferSize());
|
||||
if(aMarshaledObj) delete aMarshaledObj;
|
||||
aMarshaledObj = new MarshaledG4HCofThisEvent(HCE);
|
||||
|
||||
// removed for Geant4.6
|
||||
//stateManager->SetNewState( G4State_GeomClosed );
|
||||
StackPreviousEvent( currentEvent );
|
||||
currentEvent = 0;
|
||||
return TOPC_MSG( aMarshaledObj->getBuffer(), aMarshaledObj->getBufferSize());
|
||||
}
|
||||
|
||||
|
||||
TOPC_ACTION ParRunManager::CheckEventResult( void * input_buf, void *output_buf )
|
||||
{
|
||||
G4int i_event;
|
||||
MarshaledObj buf = MarshaledObj(input_buf);
|
||||
buf.Unmarshal(i_event);
|
||||
memcpy(&i_event, input_buf, sizeof(G4int));
|
||||
|
||||
// removed for Geant4.6
|
||||
//stateManager->SetNewState(G4State_EventProc);
|
||||
// Geant4.6 requires the state to be G4State_GeomClosed
|
||||
// before calling EventManager::ProcessOneEvent(..)
|
||||
|
||||
if(!userPrimaryGeneratorAction)
|
||||
{
|
||||
G4Exception
|
||||
("G4RunManager::BeamOn - G4VUserPrimaryGeneratorAction is not defined.");
|
||||
}
|
||||
if ( !userPrimaryGeneratorAction )
|
||||
G4Exception("G4RunManager::BeamOn - G4VUserPrimaryGeneratorAction is not defined.");
|
||||
|
||||
// This creates a trivial event in lieu of GenerateEvent(i_event);
|
||||
currentEvent = new G4Event(i_event);
|
||||
//This creates a trivial event in lieu of GenerateEvent(i_event);
|
||||
currentEvent = new G4Event( i_event );
|
||||
|
||||
// Original UserEventAction was saved and set to NULL. Do it now on master.
|
||||
if (origUserEventAction)
|
||||
origUserEventAction->BeginOfEventAction( currentEvent );
|
||||
//
|
||||
SetUserAction( (G4UserEventAction *)0 );
|
||||
|
||||
// When Geant4 4.0 sees empty event, it still calls userStackingAction.
|
||||
// On master, only trivial events exist, so we delete userStackingAction
|
||||
SetUserAction( (G4UserStackingAction*)NULL );
|
||||
|
||||
eventManager->ProcessOneEvent(currentEvent); // Processing the trivial event
|
||||
SetUserAction( (G4UserStackingAction*)0 );
|
||||
eventManager->ProcessOneEvent( currentEvent ); // Processing the trivial event
|
||||
|
||||
// Called with output_buf and no size, creates object for unmarshaling
|
||||
MarshaledHCofThisEvent marshaledObj(output_buf);
|
||||
marshaledObj.UnmarshalSlaveHCofThisEvent();
|
||||
// UnmarshalSlaveHCofThisEvent placed slave Hits in ParRunManager::currentEvent
|
||||
// using marshalgen
|
||||
MarshaledG4HCofThisEvent marshaledObj( output_buf );
|
||||
G4HCofThisEvent* oldCE = currentEvent->GetHCofThisEvent();
|
||||
G4HCofThisEvent* HCE = new G4HCofThisEvent(oldCE->GetNumberOfCollections());
|
||||
|
||||
marshaledObj.unmarshalTo(HCE);
|
||||
if(oldCE) delete(oldCE);
|
||||
|
||||
currentEvent->SetHCofThisEvent(HCE);
|
||||
|
||||
// Original UserEventAction was saved and set to NULL. Do it now on master.
|
||||
if (origUserEventAction)
|
||||
HepRandom::setTheSeed(g_Seeds[i_event]);
|
||||
if ( origUserEventAction )
|
||||
origUserEventAction->BeginOfEventAction( currentEvent );
|
||||
|
||||
if ( origUserEventAction )
|
||||
origUserEventAction->EndOfEventAction( currentEvent );
|
||||
|
||||
AnalyzeEvent(currentEvent);
|
||||
AnalyzeEvent( currentEvent );
|
||||
|
||||
if(i_event<n_select) G4UImanager::GetUIpointer()->ApplyCommand(msg);
|
||||
stateManager->SetNewState(G4State_GeomClosed);
|
||||
StackPreviousEvent(currentEvent);
|
||||
currentEvent = NULL;
|
||||
// Move this to GenerateEventInput:
|
||||
// if(runAborted) break;
|
||||
return NO_ACTION;
|
||||
if ( i_event < n_select ) G4UImanager::GetUIpointer()->ApplyCommand( msg );
|
||||
stateManager->SetNewState( G4State_GeomClosed );
|
||||
StackPreviousEvent( currentEvent );
|
||||
currentEvent = 0;
|
||||
return NO_ACTION;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* G4USE_TOPC */
|
||||
|
||||
Reference in New Issue
Block a user