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 void SetStoreStageID(bool flag) { fStoreStageID = flag; }
88
89 private:
90
91 std::unique_ptr<G4GenericMessenger> fMessenger;
92 void DefineCommands();
93
94 bool fStoreSinglePrecisionEnergy = false;
95 bool fStoreSinglePrecisionPosition = false;
96 bool fStoreAlways = false;
97 bool fStoreOpticalPhotons = false;
98 bool fStoreStageID = false;
99
100 std::map<std::string, uint32_t> fProcessMap;
101 std::set<int> fStoredProcessIDs; // This set keeps track of the process IDs that have not been discarded.
102
103 std::set<std::string> fFilterProcess;
104 std::set<int> fFilterParticle;
105 double fFilterEnergy = -1;
106
107 struct RMGTrackEntry {
108 int event_id;
109 int track_id;
110 int parent_id;
111 int proc_id;
112 int particle_pdg;
113 double global_time;
114 double x_position;
115 double y_position;
116 double z_position;
117 double x_momentum;
118 double y_momentum;
119 double z_momentum;
120 double kinetic_energy;
121 int stage_id;
122 };
123
124 std::vector<RMGTrackEntry> fTrackEntries;
125};
126
127#endif
128
129// vim: tabstop=2 shiftwidth=2 expandtab
void EndOfRunAction(const G4Run *) override
handles the storage of the process map.
Definition RMGTrackOutputScheme.cc:172
void TrackingActionPre(const G4Track *) override
Called in RMGTrackingAction::PreUserTrackingAction to collect information about the track before it i...
Definition RMGTrackOutputScheme.cc:63
void AssignOutputNames(G4AnalysisManager *) override
Sets the names of the output columns, invoked in RMGRunAction::SetupAnalysisManager.
Definition RMGTrackOutputScheme.cc:34
void StoreEvent(const G4Event *) override
Store the information from the event, invoked in RMGEventAction::EndOfEventAction.
Definition RMGTrackOutputScheme.cc:132
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:170
Metadata describing one detector instance registered with RMGHardware.
Definition RMGDetectorMetadata.hh:32