File indexing completed on 2025-09-18 09:09:07
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <array>
0010
0011 #include "corecel/Macros.hh"
0012 #include "celeritas/ext/RootFileManager.hh"
0013 #include "celeritas/phys/Primary.hh"
0014
0015 #include "EventIOInterface.hh"
0016
0017 namespace celeritas
0018 {
0019 class ParticleParams;
0020
0021
0022
0023
0024
0025
0026
0027 class RootEventWriter : public EventWriterInterface
0028 {
0029 public:
0030
0031
0032 using SPConstParticles = std::shared_ptr<ParticleParams const>;
0033 using SPRootFileManager = std::shared_ptr<RootFileManager>;
0034
0035
0036
0037 RootEventWriter(SPRootFileManager root_file_manager,
0038 SPConstParticles params);
0039
0040
0041 CELER_DELETE_COPY_MOVE(RootEventWriter);
0042 ~RootEventWriter() override = default;
0043
0044
0045 void operator()(VecPrimary const& primaries) override;
0046
0047 private:
0048
0049
0050
0051 struct RootOffloadPrimary
0052 {
0053 std::size_t event_id;
0054 std::size_t track_id;
0055 int particle;
0056 double energy;
0057 double time;
0058 std::array<double, 3> pos;
0059 std::array<double, 3> dir;
0060 };
0061
0062 SPRootFileManager tfile_mgr_;
0063 SPConstParticles params_;
0064 size_type event_id_;
0065 UPRootTreeWritable ttree_;
0066 RootOffloadPrimary primary_;
0067 bool warned_mismatched_events_{false};
0068
0069
0070
0071
0072 char const* tree_name() { return "primaries"; }
0073 };
0074
0075
0076 #if !CELERITAS_USE_ROOT
0077 inline RootEventWriter::RootEventWriter(SPRootFileManager, SPConstParticles)
0078 {
0079 CELER_DISCARD(tfile_mgr_);
0080 CELER_DISCARD(params_);
0081 CELER_DISCARD(event_id_);
0082 CELER_DISCARD(ttree_);
0083 CELER_DISCARD(primary_);
0084 CELER_DISCARD(warned_mismatched_events_);
0085 CELER_NOT_CONFIGURED("ROOT");
0086 }
0087
0088 inline void RootEventWriter::operator()(VecPrimary const&)
0089 {
0090 CELER_ASSERT_UNREACHABLE();
0091 }
0092 #endif
0093
0094
0095 }