Get particle energy

Dear Developers,

I am currently using three IBL pixel sensors to determine the entry coordinates of protons into a passive material. After the passive material follows another three sensors to determine the exit coordinates and the exit angle.

Now I try to get the proton energy after or before every sensor. The search in the source code resulted only in this functions in the MCTrack.cpp file.

double MCTrack::getKineticEnergyInitial() const {
     return initial_kin_E_;
}

double MCTrack::getTotalEnergyInitial() const {
    return initial_tot_E_;
}

double MCTrack::getKineticEnergyFinal() const {
    return final_kin_E_;
}

double MCTrack::getTotalEnergyFinal() const {
    return final_tot_E_;
}

Maybe I’m blind, but I can’t find any function that gives me back the current energy of all passing particles at every sensor.

Is such a function implemented or planned? Or is it possible to maintain the current particle energy in another way?

I highly appreciate any help! Thanks a lot!

Hi @marius

I fear that this information is currently not available. However, it should be rather easy to add this as properties of the MCParticle object. They represent a particle passing through a sensor and are all linked to their parent MCTrack.

So that way you would take your MCTrack, ask for its MCParticles, loop over them and check their detector name and finally get the initial and final energy with respect to this detector.

Contributions would be more than welcome.

If you’re interested in adding this functionality, here are some pointers to start with:
The object header is here: https://gitlab.cern.ch/allpix-squared/allpix-squared/-/blob/master/src/objects/MCParticle.hpp, the code for setting the energy should go somewhere here: https://gitlab.cern.ch/allpix-squared/allpix-squared/-/blob/master/src/modules/DepositionGeant4/SensitiveDetectorActionG4.cpp#L143-220

Let me know if you need any help with that!

Cheers,
Simon