diff --git a/inc/TRestGeant4Event.h b/inc/TRestGeant4Event.h index a936852..88f13fc 100644 --- a/inc/TRestGeant4Event.h +++ b/inc/TRestGeant4Event.h @@ -34,6 +34,7 @@ #include #include +#include #include #include "TRestGeant4Track.h" @@ -243,7 +244,8 @@ class TRestGeant4Event : public TRestEvent { /// maxTracks : number of tracks to print, 0 = all void PrintActiveVolumes() const; - void PrintEvent(int maxTracks = 0, int maxHits = 0) const; + void PrintEvent(int maxTracks = -1, int maxHits = -1, std::set particles = {}, + std::set processes = {}) const; void PrintEventFilterVolumes(const std::set& volumeNames) const; inline TPad* DrawEvent(const TString& option = "") override { return DrawEvent(option, true); } diff --git a/inc/TRestGeant4Track.h b/inc/TRestGeant4Track.h index 0a76336..2900827 100644 --- a/inc/TRestGeant4Track.h +++ b/inc/TRestGeant4Track.h @@ -126,8 +126,8 @@ class TRestGeant4Track { TString GetLastProcessName() const; - /// Prints the track information. N number of hits to print, 0 = all - void PrintTrack(size_t maxHits = 0) const; + /// Prints the track information. N number of hits to print, -1 = all + void PrintTrack(size_t maxHits = -1) const; void PrintTrackFilterVolumes(const std::set& filterVolumes) const; inline void RemoveHits() { fHits.RemoveHits(); } diff --git a/src/TRestGeant4Event.cxx b/src/TRestGeant4Event.cxx index 21d3393..d48a823 100644 --- a/src/TRestGeant4Event.cxx +++ b/src/TRestGeant4Event.cxx @@ -1134,7 +1134,8 @@ void TRestGeant4Event::PrintActiveVolumes() const { } } -void TRestGeant4Event::PrintEvent(int maxTracks, int maxHits) const { +void TRestGeant4Event::PrintEvent(int maxTracks, int maxHits, std::set particles, + std::set processes) const { TRestEvent::PrintEvent(); cout << "- Total deposited energy: " << ToEnergyString(fTotalDepositedEnergy) << endl; @@ -1156,13 +1157,20 @@ void TRestGeant4Event::PrintEvent(int maxTracks, int maxHits) const { cout << "Total number of tracks: " << GetNumberOfTracks() << endl; int nTracks = GetNumberOfTracks(); - if (maxTracks > 0 && (unsigned int)maxTracks < GetNumberOfTracks()) { + if (maxTracks >= 0 && (unsigned int)maxTracks < GetNumberOfTracks()) { nTracks = min(maxTracks, int(GetNumberOfTracks())); - cout << "Printing only the first " << nTracks << " tracks" << endl; + // cout << "Printing only the first " << nTracks << " tracks" << endl; } for (int i = 0; i < nTracks; i++) { - GetTrack(i).PrintTrack(maxHits); + auto tck = GetTrack(i); + if (particles.empty() && processes.empty()) { + tck.PrintTrack(maxHits); + } else if (particles.find(tck.GetParticleName()) != particles.end()) { + tck.PrintTrack(maxHits); + } else if (processes.find(tck.GetCreatorProcess()) != processes.end()) { + tck.PrintTrack(maxHits); + } } } diff --git a/src/TRestGeant4Track.cxx b/src/TRestGeant4Track.cxx index de401e5..6d28152 100644 --- a/src/TRestGeant4Track.cxx +++ b/src/TRestGeant4Track.cxx @@ -118,21 +118,17 @@ void TRestGeant4Track::PrintTrack(size_t maxHits) const { << (GetParentTrack() != nullptr ? TString::Format(" - Parent particle: %s", GetParentTrack()->GetParticleName().Data()).Data() : "") - << " - Created by '" << fCreatorProcess << "' in volume '" << GetInitialVolume() - << "' with initial KE of " << ToEnergyString(fInitialKineticEnergy) << " - Initial position " - << VectorToString(fInitialPosition) << " mm at time " << ToTimeString(fGlobalTimestamp) - << " - Time length of " << ToTimeString(fTimeLength) << " and spatial length of " - << ToLengthString(fLength) << endl; + << " - Created by '" << fCreatorProcess << "' in '" << GetInitialVolume() << "' with KE of " + << ToEnergyString(fInitialKineticEnergy) << endl; - cout << " Initial position " << VectorToString(fInitialPosition) << " mm at time " + cout << " Initial position " << VectorToString(fInitialPosition) << " mm at time " << ToTimeString(fGlobalTimestamp) << " - Time offset " << ToTimeString(fTimeOffset) - << " - Time length of " << ToTimeString(fTimeLength) << " and spatial length of " - << ToLengthString(fLength) << endl; + << " - Length of " << ToTimeString(fTimeLength) << " and " << ToLengthString(fLength) << endl; size_t nHits = GetNumberOfHits(); - if (maxHits > 0 && maxHits < nHits) { + if (maxHits >= 0 && maxHits < nHits) { nHits = min(maxHits, nHits); - cout << "Printing only the first " << nHits << " hits of the track" << endl; + // cout << "Printing only the first " << nHits << " hits of the track" << endl; } const TRestGeant4Metadata* metadata = GetGeant4Metadata();