diff --git a/inc/TRestGeant4Event.h b/inc/TRestGeant4Event.h index 2b12702..a936852 100644 --- a/inc/TRestGeant4Event.h +++ b/inc/TRestGeant4Event.h @@ -186,6 +186,8 @@ class TRestGeant4Event : public TRestEvent { return energyMap[volumeName]; } + std::pair GetTimeRangeOfIonizationInVolume(const std::string& volumeName) const; + inline void ClearTracks() { fTracks.clear(); } TRestHits GetHits(Int_t volID = -1) const; diff --git a/src/TRestGeant4Event.cxx b/src/TRestGeant4Event.cxx index b74baa4..21d3393 100644 --- a/src/TRestGeant4Event.cxx +++ b/src/TRestGeant4Event.cxx @@ -1340,3 +1340,21 @@ void TRestGeant4Event::AddEnergyInVolumeForParticleForProcess(Double_t energy, c fEnergyInVolumePerParticlePerProcess[volumeName][particleName][processName] += energy; fTotalDepositedEnergy += energy; } + +std::pair TRestGeant4Event::GetTimeRangeOfIonizationInVolume(const string& volumeName) const { + std::pair result = {std::numeric_limits::max(), + std::numeric_limits::min()}; + + for (const auto& track : fTracks) { + const auto& hits = track.GetHits(); + for (int i = 0; i < int(hits.GetNumberOfHits()); i++) { + if (hits.GetVolumeName(i) == volumeName && hits.GetEnergy(i) > 0) { + const double time = hits.GetTime(i); + result.first = std::min(result.first, time); + result.second = std::max(result.second, time); + } + } + } + + return result; +}