Electron cuts and photoelectric process

Dear users, i am working on a application where i am just interested in the number of tracks that cross and deposit energy in a detector (indeed, several detectors like a spectrometer).
I want for example to store the trackID and the energy deposition by the particle in the detector.
By now the counting of tracks are wrong because the electrons created in the detector volume due to ionisations are being counted and their energy is not accounted to the primary particle energy deposition.
Example: gamma photon, lets say 30keV, interacting by photoelectric process in the detector will just release 0.288 keV (K shell from carbon) and the remaining energy of the gamma is deposited by the photoelectron.
In order to avoid the electron track counting and have the full gamma energy deposited by the particle i have defined a electron range cut of 10*cm but it returns the same result and the default cuts. I was expecting that, in case of an high range cut i would have the photon energy deposition assumed to be the initial gamma energy without an electron track, but is clear that it does not work like that.
One solution is to sum the energy deposition of secondaries to the primary one but i am afraid that, when high energy charged particles will be used (muons in GeV region), it will be not an easy task i guess.
Is there a way to get the deposited energy by a particle crossing the detector and its secondaries without counting the ionisation electrons as tracks?
Thanks for any help:


by default no production threshold is applied in gamma processes. To enable production cuts for these processes you can use UI command:

/process/em/applyCuts true


Dear Vladimir, thank you. It does exactly what i need.