Hello, I have a problem to access a variable of a static method from an other method which is non static. I needed to get the material of each step from the SteppingAction.cc, so i made a static method called GetNameMat(G4String) that get the step’s name material in this source file.
SteppingAction.cc:
class PhysicsList;
SteppingAction::SteppingAction(DetectorConstruction* det, G4Event* aEvent, EventAction* EA)
: event(aEvent),Detector(det),anEventAction(EA),fScoringVolume(0)
{}
SteppingAction::~SteppingAction()
{}
void SteppingAction::UserSteppingAction(const G4Step* step)
{
matname=step->GetPreStepPoint()->GetMaterial()->GetName();
PhysicsList::GetNameMat(matname);
}
SteppingAction.hh:
#include “PhysicsList.hh”
class PhysicsList;
class SteppingAction : public G4UserSteppingAction
{
public:
SteppingAction(DetectorConstruction*,G4Event*,EventAction*);
virtual ~SteppingAction();
…
PhysicsList* GetNameMat(G4String*);
private:
…
};
Then I describe this method in PhysicsList.cc where I need it for an other method (non-static) ConstructEM() which needs the material name.
PhysicsList.cc:
PhysicsList::PhysicsList()
: G4VModularPhysicsList()
{
SetDefaultCutValue(0.1*nm);
SetVerboseLevel(1);
…
}
PhysicsList::~PhysicsList()
{}
void PhysicsList::GetNameMat(const G4String& matname)
{
G4String npname=matname;
G4cout <<" MatName1: " <<npname<<G4endl;
}
void PhysicsList::ConstructEM()
{
G4String matname;
GetNameMat(matname);
G4String npname=matname;
G4cout <<" MatName2: " <<npname<<G4endl;
G4bool isGNP=false;
fphysname=“DNA”;
if(npname==“G4_Au”) isGNP=true;
…
}
PhysicsList.hh:
class SteppingAction;
class PhysicsList: public G4VModularPhysicsList
{
public:
PhysicsList();
virtual ~PhysicsList();
...
void ConstructEM();
static void GetNameMat(const G4String&);
private:
const G4Step* step;
G4VPhysicsConstructor* fEmPhysicsList;
G4String fphysname;
G4LogicalVolume* logicWater;
G4LogicalVolume* logicTarget;
};
I can get the material name with the static method GetNameMat(const G4String& matname) in PhysicsList.cc where the G4cout displays the material of each step (G4cout <<" MatName1: " <<npname<<G4endl) but I need it in the method ConstructEM() which does not display the material (G4cout <<" MatName2: " <<npname<<G4endl does not work).
So I wanted to know how to access this G4String matname in the ConstructEM() method. I hope that someone could help me. Thanks you