Skip to content

Commit

Permalink
Merge pull request #133 from rest-for-physics/time
Browse files Browse the repository at this point in the history
Get time range of ionization
  • Loading branch information
lobis authored Oct 12, 2024
2 parents e16e5cd + 9f293c9 commit 7d2419f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inc/TRestGeant4Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class TRestGeant4Event : public TRestEvent {
return energyMap[volumeName];
}

std::pair<double, double> GetTimeRangeOfIonizationInVolume(const std::string& volumeName) const;

inline void ClearTracks() { fTracks.clear(); }

TRestHits GetHits(Int_t volID = -1) const;
Expand Down
18 changes: 18 additions & 0 deletions src/TRestGeant4Event.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1340,3 +1340,21 @@ void TRestGeant4Event::AddEnergyInVolumeForParticleForProcess(Double_t energy, c
fEnergyInVolumePerParticlePerProcess[volumeName][particleName][processName] += energy;
fTotalDepositedEnergy += energy;
}

std::pair<double, double> TRestGeant4Event::GetTimeRangeOfIonizationInVolume(const string& volumeName) const {
std::pair<double, double> result = {std::numeric_limits<double>::max(),
std::numeric_limits<double>::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;
}

0 comments on commit 7d2419f

Please sign in to comment.