Issue with extended example field04

Hi everyone. I am trying to modify “G4double targetLength” in exampleB2a with .mac file, so I copied and modified this code in extended example field04:

void F04DetectorConstruction::SetTargetThickness(G4double val)
{
  fTargetThickness = val;
  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
    G4RunManager::GetRunManager()->ReinitializeGeometry();
  }
}

This didn’t work normally. Then I ran field04 and used this command.

/field04/SetTgtThick 5 um
/field04/SetTgtThick 5 m

But I didn’t see any changes in viewer-0. In fact, I searched field04 in forum, and I think this guy meet the same problem with me:
Lowering the step-size in the magnetic field in example field04
Are there some problem in this code? Did I do it wrong? How can I modify “targetLength” in .mac file?

_Geant4 Version:_v11.2.1
_Operating System:_Windows 10
_Compiler/Version:_Visual Studio 2022
_CMake Version:_cmake-3.18.4-win64-x64

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.