I am running Extended Example->Electromagnetic->TestEm1. I want to change the detector material dimensions from a cubical box to a thin strip. In the src file DetectorConstruction.cc, I changed the following lines from:
‘’’
if(fPBox) { return fPBox; }
fBox = new G4Box(“Container”, //its name
fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions,
‘’’
to
‘’’
if(fPBox) { return fPBox; }
fBox = new G4Box(“Container”, //its name
fBoxSize/100,fBoxSize/2,fBoxSize/2); //its dimensions,
‘’’
and
‘’’
if(fBox) {
fBox->SetXHalfLength(fBoxSize/2);
fBox->SetYHalfLength(fBoxSize/2);
fBox->SetZHalfLength(fBoxSize/2);
}
‘’’
to
‘’’
if(fBox) {
fBox->SetXHalfLength(fBoxSize/100);
fBox->SetYHalfLength(fBoxSize/2);
fBox->SetZHalfLength(fBoxSize/2);
}
‘’’
.
The shape outline in the OpenGL visualizer changed as expected. However, after running 100 gamma rays of 2 MeV each in interactive mode, using Lead as the detector material, the visualizer behaved as though the detector dimensions had not changed from their original cubical shape. Is there anything I missed here, and anything else I need to do to change the shape of this detector material block?
I do have a question about this. In DetectorConstruction.cc, fBoxSize appears to dictate all three dimensions of the box. Does this change in DetectorConstruction.hh change all three dimensions?
In that particular example, the assumption is that you’re building a cube with just one dimension. So yeah, any code that calls GetBoxSize() will get the smaller value, and won’t realize that it only applies to one of the three dimensions.
Your modification suggests that a more general version of DetectorConstruction, written for your own job, would have three separate dimensions (call them “fBoxX”, “fBoxY”, and “fBoxZ” if you like). You’d then probably write three different Get functions, and whatever other code is using the Get function would need to be modified to ask for the appropriate dimension. This is part of the process of moving from a fixed simple example to a more complex real application.