Hello,I want to change the thickness in a loop as:
/control/loop loop1.mac thickness 0.1 10.1 0.1
and loop1.mac:
/control/verbose 0
/run/verbose 0
/tracking/verbose 0
/process/verbose 0
/ZnS/SetThickness {thickness} um
/run/initialize
/run/beamOn 300
But it can`t work;
The change of thickness only worked when I just execute mac without loop
/control/verbose 0
/run/verbose 0
/tracking/verbose 0
/process/verbose 0
/ZnS/SetThickness 10 um
/run/initialize
/run/beamOn 300
Does your /ZnS/SetThickness
command automatically call runManager->GeometryHasBeenModified()
? If not, then your loop needs to do that by hand:
/ZnS/SetThickness {thickness} um
/run/geometryModified
/run/initialize
In my DetectorConstruction,I write the method as
void DetectorConstruction::SetThickness(G4double val)
{
fThickness = val;
p_z = fThickness/2+3*mm;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
I think it has automatically called runManager->GeometryHasBeenModified()
And,even if loop with
/ZnS/SetThickness {thickness} um
/run/geometryModified
/run/initialize
There is still no change.
Try putting /run/reinitializeGeometry
explicitly in your loop1.mac
, before /run/initialize
, instead of my first suggestion. According to the help for both:
17) geometryModified * Force geometry to be closed (re-voxellized) again.
18) reinitializeGeometry * Force geometry to be rebuilt once again.
The “re-voxellized” means that the geometry structure doesn’t get constructed again, but you might have gone through and changed materials, or density or something.
In your case, you’re changing dimensions, which means you need the whole thing constructed from scratch.
So,did I should wirte loop1.mac as:
/control/verbose 0
/run/verbose 0
/tracking/verbose 0
/process/verbose 0
/ZnS/SetThickness {thickness} um
/run/initialize
/run/reinitializeGeometry
/run/beamOn 300
Doing this seems to have no effect
loop1.mac
should have
/ZnS/SetThickness {thickness} um
/run/reinitializeGeometry
/run/initialize
/run/beamOn 300
[quote=“mojingshihua, post:9, topic:11904, full:true”]
In my DetectorConstruction,I change the thickness as:
void DetectorConstruction::SetThickness(G4double val)
{
fThickness = val;
p_z = fThickness/2+3*mm;
// G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
Should I cancel the " G4RunManager::GetRunManager()->GeometryHasBeenModified(); "?Because if loop1.mac as
/ZnS/SetThickness {thickness} um
/run/reinitializeGeometry
/run/initialize
/run/beamOn 300
I can`t see any energy deposite in ZnS , likes it disappeared.