Access the position

Hi All,
I want to access the primary particle position in the SensitiveDetector.

const B1PrimaryGeneratorAction* generatorAction
= static_cast<const B1PrimaryGeneratorAction*>(
G4double xPosition;
G4double yPosition;
G4double zPosition;
if (generatorAction)
xPosition = generatorAction->GetMethodsOfGenartingSource();
yPosition = generatorAction->GetMethodsOfGenartingSource();
zPosition = generatorAction->GetMethodsOfGenartingSource();

And in PrimaryGeneratorAction, I tried to do this using the ‘‘set method’’ and the ‘‘get method’’.

void B1PrimaryGeneratorAction::SetMethodsOfGenartingSource(G4double xpne)
xPosition= x0;
yPosition= y0;
zPosition= z0;
G4double B1PrimaryGeneratorAction::GetMethodsOfGenartingSource() const
return xPosition;
return yPosition;
return zPosition;

That X0, y0 and z0 are the same primary particle position.
But the ‘‘set’’ operation is not performed.

Thanks for any suggestions.