Hello,
I’m just learning Geant4. I try to modify the B1 example and need to get the total amount of energy deposited, (for example, shoot 100000 10MeV photons into the scintillator), so I modified Steppingaction.cc (code listed below) and the data is saved to a file called record1.txt,
but after I plotted the energy deposition rate curve using the photon energy and the deposition energy obtained with the “step->GetTotalEnergyDeposit()” command, I found that my data is different from the data obtained by other authors of the paper exists. (as shown below)
I would like to get the energy deposition due to photoelectric absorption, but it seems that now I get the energy attenuation that the photons pass through the scintillator (the physicslists I used is QBBC).
Could I use the “step->GetTotalEnergyDeposit()” command to get data on the energy deposited by photoelectric absorption in the scintillator? If not, is there a way to get this information?
yes, you can, at least if what you want to do is to get the energy deposited by electrons created by the photoelectric effect. In your Steppingaction.cc add
#include G4VProcess.hh
and in your UserSteppingAction
auto CreatorProc = step->GetTrack()->GetCreatorProcess();
if (CreatorProc && CreatorProc->GetProcessName()=="phot"){ //nullpointer for primary particle
step->GetTotalEnergyDeposit();
}
Hello dear lopezzot,
As you said, I added these code in my SteppingAction.cc
#include "G4VProcess.hh"
using namespace std;
G4double edepphot;
ofstream data("./record.txt");
void B1SteppingAction::UserSteppingAction(const G4Step *step)
{
...
auto CreatorProc = step->GetTrack()->GetCreatorProcess();
if (CreatorProc && CreatorProc->GetProcessName()=="phot"){ //nullpointer for primary particle
edepphot = step->GetTotalEnergyDeposit();
data << edepphot << G4endl;
}
I tried to record these energy data to a file called “record.txt”. After a run, I found that the “record.txt” has just been modified but these is no data in “record.txt” .
Did I use the wrong way to record the data or are these any special methods to record data in Geant4?
if (CreatorProc && CreatorProc->GetProcessName()=="phot")
is true at least once per event/run?
Otherwise, it means that in the volume you are considering there are no tracks created by the photoelectric process.
“tmp_record” is the value that I use to record the energy deposited by electrons. “A1” is the scintillator I created. I tried to saved “tmp_record” in a file called “record1.txt” and got the value once an event.
My goal was recording the value only when physical processes occurred in the scintillator. But the value I got was very small. Did I skip too many physical processes?