Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get time range of ionization #133

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading