File indexing completed on 2025-09-15 08:54:50
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <array>
0010
0011 #include "corecel/Config.hh"
0012
0013 #include "corecel/Assert.hh"
0014 #include "celeritas/ext/RootUniquePtr.hh"
0015
0016 #include "RootStepWriterInput.hh"
0017 #include "StepInterface.hh"
0018
0019 class TTree;
0020
0021 namespace celeritas
0022 {
0023
0024 class ParticleParams;
0025 class RootFileManager;
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 class RootStepWriter final : public StepInterface
0040 {
0041 public:
0042
0043 static constexpr size_type unspecified{static_cast<size_type>(-1)};
0044
0045
0046 struct TStepPoint
0047 {
0048 size_type volume_id = unspecified;
0049 real_type energy = 0;
0050 real_type time = 0;
0051 std::array<real_type, 3> pos{0, 0, 0};
0052 std::array<real_type, 3> dir{0, 0, 0};
0053 };
0054
0055
0056 struct TStepData
0057 {
0058 size_type event_id = unspecified;
0059 size_type track_id = unspecified;
0060 size_type parent_id = unspecified;
0061 size_type action_id = unspecified;
0062 size_type track_step_count = unspecified;
0063 int particle = 0;
0064 real_type energy_deposition = 0;
0065 real_type step_length = 0;
0066 EnumArray<StepPoint, TStepPoint> points;
0067 };
0068
0069 public:
0070
0071
0072 using SPRootFileManager = std::shared_ptr<RootFileManager>;
0073 using SPParticleParams = std::shared_ptr<ParticleParams const>;
0074 using WriteFilter = std::function<bool(TStepData const&)>;
0075
0076
0077
0078 RootStepWriter(SPRootFileManager root_manager,
0079 SPParticleParams particle_params,
0080 StepSelection selection,
0081 WriteFilter filter);
0082
0083
0084 RootStepWriter(SPRootFileManager root_manager,
0085 SPParticleParams particle_params,
0086 StepSelection selection);
0087
0088
0089 void set_auto_flush(long num_entries);
0090
0091
0092 void process_steps(HostStepState) final;
0093
0094
0095 void process_steps(DeviceStepState) final
0096 {
0097 CELER_NOT_IMPLEMENTED("RootStepWriter with device data");
0098 }
0099
0100
0101 StepSelection selection() const final { return selection_; }
0102
0103
0104 Filters filters() const final { return {}; }
0105
0106 private:
0107
0108 void make_tree();
0109
0110 private:
0111 SPRootFileManager root_manager_;
0112 SPParticleParams particles_;
0113 StepSelection selection_;
0114 UPRootTreeWritable tstep_tree_;
0115 TStepData tstep_;
0116 std::function<bool(TStepData const&)> filter_;
0117 };
0118
0119
0120
0121
0122
0123 RootStepWriter::WriteFilter make_write_filter(SimpleRootFilterInput const&);
0124
0125
0126 #if !CELERITAS_USE_ROOT
0127 inline RootStepWriter::RootStepWriter(SPRootFileManager,
0128 SPParticleParams,
0129 StepSelection,
0130 WriteFilter)
0131 {
0132 CELER_NOT_CONFIGURED("ROOT");
0133 }
0134
0135 inline void RootStepWriter::process_steps(HostStepState)
0136 {
0137 CELER_NOT_CONFIGURED("ROOT");
0138 }
0139
0140 inline RootStepWriter::WriteFilter
0141 make_write_filter(SimpleRootFilterInput const&)
0142 {
0143 return nullptr;
0144 }
0145
0146 #endif
0147
0148
0149 }