Skip to content
Open
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
4 changes: 3 additions & 1 deletion inc/TRestGeant4Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <iostream>
#include <map>
#include <set>
#include <utility>

#include "TRestGeant4Track.h"
Expand Down Expand Up @@ -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<TString> particles = {},
std::set<TString> processes = {}) const;
void PrintEventFilterVolumes(const std::set<std::string>& volumeNames) const;

inline TPad* DrawEvent(const TString& option = "") override { return DrawEvent(option, true); }
Expand Down
4 changes: 2 additions & 2 deletions inc/TRestGeant4Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>& filterVolumes) const;

inline void RemoveHits() { fHits.RemoveHits(); }
Expand Down
16 changes: 12 additions & 4 deletions src/TRestGeant4Event.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<TString> particles,
std::set<TString> processes) const {
TRestEvent::PrintEvent();

cout << "- Total deposited energy: " << ToEnergyString(fTotalDepositedEnergy) << endl;
Expand All @@ -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);
}
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/TRestGeant4Track.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading