Can anyone helpe me to read IAEAPhaseSpace file as a source?

Dear all,
As my title, I want to read an IAEA Phasespace file as a source. I tried to read the file as an example code but it did not work. Please help me.

#ifndef PrimaryGeneratorAction_h
#define PrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
class G4Event;
class G4IAEAphspReader;
class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
PrimaryGeneratorAction();
~PrimaryGeneratorAction();
void GeneratePrimaries(G4Event*);
private:
// Phase space reader
G4IAEAphspReader* theIAEAReader;
};
#endif
#include "PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4IAEAphspReader.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
G4String fileName = "PSF";
theIAEAReader = new G4IAEAphspReader(fileName);
}
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
if (theIAEAReader) delete theIAEAReader;
}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
theIAEAReader->GeneratePrimaryVertex(anEvent);
}
1 Like

The source codes look fine to me.
What error did the program report?

Sir, this is the error
error

It seems some functions get passed 1 argument, but they need more or (more likely) 0 arguments.
Could you show me which function it is in your G4IAEAphspReader (154,50), (217,73) …
In my version of G4IAEAphspReader, there is no function in those positions at all.

Dear sir,
I dowloaded the IAEA file at here: Phase-space database for external beam radiotherapy


I had to modify the original IAEA code in order to compile it with a Geant4 application. Mind this possibility. The original code was written for some 9.x version of Geant4.

G4Exception might need more or fewer parameters; just check the declarations of this function.

If it may help GitHub - phirippu/instrument-simulation: Small and flexible tool for charged particle simulations.