I am working with Geant version 11.3.1, specifically with example B4d. I changed the absorber material from lead to tungsten, and I am shooting 10 GeV charged pions at the system. However, I find that even if I make the absorber layer incredibly large,
G4int nofLayers = 800;
G4double absoThickness = 210. * mm;
G4double gapThickness = 400. * mm;
G4double calorSizeXY = 10000. * cm;
I cannot recover all of the pion energy. I would expect Eabs + Egap to spike at 10 GeV, but it peaks at ~9.1 GeV (interestingly, the max is at 10.1 GeV!). Is there some way to track this missing energy?
Seems awfully coincidental that that missing mass is close to the rest mass of a neutron/proton which would not be translated into deposited energy or kinetic energy.
If you want a sanity check then you can enclose all volumes and your particle gun in a big bounding box and just sum the energy, any energy, that is going from inside the box to outside the box.
Thanks for the response!
In example B4d, the detector is already absorbed in a bounding box made of the Galactic
material.
I tried to register the world logical volume as a detector, with
// declare World as a MultiFunctionalDetector scorer
//
auto worldDetector = new G4MultiFunctionalDetector("World");
G4SDManager::GetSDMpointer()->AddNewDetector(worldDetector);
primitive1 = new G4PSEnergyDeposit("Edep");
worldDetector->RegisterPrimitive(primitive1);
SetSensitiveDetector("WorldLV", worldDetector);
But the energy deposited in the world is on the order of MeV. I suppose this is not registering the energy leaving the box, but I am not sure how to recover that.
In a step you can check where it “starts” (prestep) and where it “ends” (poststep). There is always a step at a boundary between two regions.
So, for example:
step->GetPostStepPoint()->GetStepStatus()==fGeomBoundary
checks if you are “leaving” the current volume and
G4LogicalVolume* volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
Give you the volume it is “starting” in (there are many other ways to do this). So if you check that the step occurs inside some bounding box but is leaving it, then you can tag that particle. You can then sum all the energy of any particle leaving that bounding box and either print it, histogram it, or do whatever you think you need for debugging. You can use the world volume but you might get erratic behavior since there is no post volume per se. Probably easier to put a smaller bounding box inside that is a mother to all of your detectors.