remage
Simulation framework for HPGe-based experiments
 
Loading...
Searching...
No Matches
RMGTrackOutputScheme.hh
1// Copyright (C) 2024 Manuel Huber <https://orcid.org/0009-0000-5212-2999>
2//
3// This program is free software: you can redistribute it and/or modify it under
4// the terms of the GNU Lesser General Public License as published by the Free
5// Software Foundation, either version 3 of the License, or (at your option) any
6// later version.
7//
8// This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11// details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16#ifndef _RMG_TRACK_OUTPUT_SCHEME_HH_
17#define _RMG_TRACK_OUTPUT_SCHEME_HH_
18
19#include <map>
20#include <set>
21#include <vector>
22
23#include "G4AnalysisManager.hh"
24#include "G4GenericMessenger.hh"
25
26#include "RMGVOutputScheme.hh"
27
28class G4Event;
29class G4Track;
49class RMGTrackOutputScheme : public RMGVOutputScheme {
50
51 public:
52
53 RMGTrackOutputScheme();
54
56 void AssignOutputNames(G4AnalysisManager*) override;
57
61 void TrackingActionPre(const G4Track*) override;
62
64 void EndOfRunAction(const G4Run*) override;
65
67 void ClearBeforeEvent() override;
68
73 void StoreEvent(const G4Event*) override;
74
76 [[nodiscard]] bool StoreAlways() const override { return fStoreAlways; }
77
78 protected:
79
80 [[nodiscard]] std::string GetNtupleName(RMGDetectorMetadata) const override {
81 throw std::logic_error("step output scheme has no detectors");
82 }
83
84 void AddParticleFilter(const int pdg) { fFilterParticle.insert(pdg); }
85 void AddProcessFilter(const std::string proc) { fFilterProcess.insert(proc); }
86 void SetEnergyFilter(double energy) { fFilterEnergy = energy; }
87
88 private:
89
90 std::unique_ptr<G4GenericMessenger> fMessenger;
91 void DefineCommands();
92
93 bool fStoreSinglePrecisionEnergy = false;
94 bool fStoreSinglePrecisionPosition = false;
95 bool fStoreAlways = false;
96 bool fStoreOpticalPhotons = false;
97
98 std::map<std::string, uint32_t> fProcessMap;
99 std::set<int> fStoredProcessIDs; // This set keeps track of the process IDs that have not been discarded.
100
101 std::set<std::string> fFilterProcess;
102 std::set<int> fFilterParticle;
103 double fFilterEnergy = -1;
104
105 struct RMGTrackEntry {
106 int event_id;
107 int track_id;
108 int parent_id;
109 int proc_id;
110 int particle_pdg;
111 double global_time;
112 double x_position;
113 double y_position;
114 double z_position;
115 double x_momentum;
116 double y_momentum;
117 double z_momentum;
118 double kinetic_energy;
119 };
120
121 std::vector<RMGTrackEntry> fTrackEntries;
122};
123
124#endif
125
126// vim: tabstop=2 shiftwidth=2 expandtab
void EndOfRunAction(const G4Run *) override
handles the storage of the process map.
Definition RMGTrackOutputScheme.cc:157
void TrackingActionPre(const G4Track *) override
Called in RMGTrackingAction::PreUserTrackingAction to collect information about the track before it i...
Definition RMGTrackOutputScheme.cc:60
void AssignOutputNames(G4AnalysisManager *) override
Sets the names of the output columns, invoked in RMGRunAction::SetupAnalysisManager.
Definition RMGTrackOutputScheme.cc:32
void StoreEvent(const G4Event *) override
Store the information from the event, invoked in RMGEventAction::EndOfEventAction.
Definition RMGTrackOutputScheme.cc:119
bool StoreAlways() const override
Invoked in RMGEventAction::EndOfEventAction and decides whether to always store this OutputScheme.
Definition RMGTrackOutputScheme.hh:76
void ClearBeforeEvent() override
Clears the event data and frees memory before the next event is processed.
Definition RMGTrackOutputScheme.cc:155
Metadata describing one detector instance registered with RMGHardware.
Definition RMGDetectorMetadata.hh:31