The different value

in my application, the DetectorMessenger class is used to change some members in DetectorConstruction class,
in PrimaryGeneratorAction class, i get one member like A defined in DetectorConstruction class;
in ImportanceDetectorConstruction class(the class used to do variance reduction), i get the same member,
after changing the member value through command defined in DetectorMessenger class, something puzzling occured, the member value is not changed from ImportanceDetectorConstruction class,
but the member value changes from PrimaryGeneratorAction class.

Could you post, or otherwise link to the code please? Without this, it’s impossible to determine what the cause of the issue might be.

@ bmorgan, thanks, the code is too long, i will check the code first.

here is the key code:
in the DetectorConstruction class, the “DetectorPosition” member is difined:

and initialized in constructed function:

and revised it through the resolution below:

after revised it through the command defined in DetectorMessenger, like this:
/det/setDetectorPosition 3 cm;

from PrimaryGeneratorAction class, the code that get the member is:

and from ImportanceDetectorConstruction class, the code that get the member is:

the results are:

It seems that these two fDetector are not consistent. Where did you get them?

I’d echo the above comment - how/where does ImportanceDetectorConstruction get the fDetector pointer? Also, what member function of ImportanceDetectorConstruction is the call to GetDetectorPosition being made in, and does that call really happening after the dimension is updated?

sorry for replying later, i get the fDetetor pointer in ImportanceDetectorConstruction::Construct() and PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) function;

i do not know if the call really happening after the dimension is updated,

but the parameter DetectorPosition is changed printed from PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) function

it seems the ImportanceDetectorConstruction object is implemented only once before /run/initialize, and the parameter DetectorPosition is not changed printed.