_Geant4 Version:_geant4-v11.1.1
_Operating System: CentOS 8
_Compiler/Version: gcc 8.5.0
_CMake Version: 3.20.2
Appears that event processing is unsuccessful. Geant is running in multi-threaded mode with 4 threads. Visualization with processing 1 event/thread works fine. evtNb prints as expected. Total events prints 0 and HCE prints false.
// EVENT ACTION FILE
#ifdef G4UI_USE_ROOT
#include "G4UIRoot.hh"
#endif
////////////////////////////
#include "SteppingAction.hh"
/////////////////////////////
#include "EventAction.hh"
#include "GdScintHit.hh"
#include "RunAction.hh"
#include "GdScintEventMessenger.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4HCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4VVisManager.hh"
#include "G4SDManager.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#include "GdScintSD.hh"
//For outputting to ascii:
#include <iomanip>
#include <fstream>
/////////////////////////////////////////////////////////////////////////////
////OUTPUT //
G4int verboseLevel= 2; //choose 0,1 or 2 for screen output detail //
G4int dataFiles = 2; //choose 0,1,2,3 for ascii creation //
G4int Ntuples = 0; //choose 1 for Ntuple creation //
/////////////////////////////////////////////////////////////////////////////
EventAction::EventAction()
{
totEvents=0;
//create messenger
fGdScintEvMess=new GdScintEventMessenger(this);
//hits collections
GdScintCollID = -1;
}
EventAction::~EventAction()
{
delete fGdScintEvMess;
}
void EventAction::BeginOfEventAction(const G4Event* evt)
{
G4int evtNb;
evtNb = evt->GetEventID();
G4SDManager *SDman = G4SDManager::GetSDMpointer();
if(GdScintCollID==-1) {
GdScintCollID = SDman->GetCollectionID("GdScintCollection");
}
}
void EventAction::EndOfEventAction(const G4Event* evt)
{ G4cout << "Total Events: " << G4endl;
G4cout << totEvents << G4endl;
totEvents++;
G4int evtNb = evt->GetEventID();
GdScintHitsCollection* ScintHC = NULL;
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
G4int n_hit = 0;
G4double ScintTotalEnergy = 0;
G4ThreeVector ScintPosition;
G4String ScintParticle;
G4double ScintEdep = 0;
G4String ScintParticleType;
G4ThreeVector ScintMomentum;
G4ThreeVector ScintMomentumDir;
G4String ScintVertexVolumeName;
G4ThreeVector ScintVertexPosition;
G4ThreeVector ScintVertexMomDir;
G4String ScintNuclearProcess;
if (HCE) {
ScintHC = (GdScintHitsCollection*)(HCE->GetHC(GdScintCollID));
//////////////////////////////////////////////////////////
// SCINTILLATOR ANALYSIS //
/////////////////////////////////////////////////////////
//Analyse info from the scintillator
if ( ScintHC )
{
n_hit = ScintHC->entries();
if( verboseLevel > 1 ) {
G4cout<<"Total Number Of Step on this Hit "<<n_hit<<G4endl;
}
for (G4int i=0;i<n_hit;i++)
{
ScintEdep = (*ScintHC)[i]-> GetScintEdep(); //GetScintEdep() ? ScintTotalEnergy += ScintEdep; // Keep it for later
}
G4cout<<"Edep in scintillator = "<<ScintTotalEnergy/MeV<<" MeV"<<G4endl;
std::ofstream theFile6("scintillator.dat", std::ios::app);
theFile6<<evtNb<<"\t"<<ScintTotalEnergy/MeV<<G4endl;
}
}
}//End of function