File indexing completed on 2025-02-22 10:31:24
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <array>
0011
0012 #include "corecel/Macros.hh"
0013 #include "celeritas/ext/RootFileManager.hh"
0014 #include "celeritas/phys/Primary.hh"
0015
0016 #include "EventIOInterface.hh"
0017
0018 namespace celeritas
0019 {
0020 class ParticleParams;
0021
0022
0023
0024
0025
0026
0027
0028 class RootEventWriter : public EventWriterInterface
0029 {
0030 public:
0031
0032
0033 using SPConstParticles = std::shared_ptr<ParticleParams const>;
0034 using SPRootFileManager = std::shared_ptr<RootFileManager>;
0035
0036
0037
0038 RootEventWriter(SPRootFileManager root_file_manager,
0039 SPConstParticles params);
0040
0041
0042 CELER_DELETE_COPY_MOVE(RootEventWriter);
0043
0044
0045 void operator()(VecPrimary const& primaries);
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
0068
0069
0070
0071 char const* tree_name() { return "primaries"; }
0072 };
0073
0074
0075 #if !CELERITAS_USE_ROOT
0076 inline RootEventWriter::RootEventWriter(SPRootFileManager, SPConstParticles)
0077 {
0078 CELER_DISCARD(tfile_mgr_);
0079 CELER_DISCARD(params_);
0080 CELER_DISCARD(event_id_);
0081 CELER_DISCARD(ttree_);
0082 CELER_DISCARD(primary_);
0083 CELER_NOT_CONFIGURED("ROOT");
0084 }
0085
0086 inline void RootEventWriter::operator()(VecPrimary const&)
0087 {
0088 CELER_ASSERT_UNREACHABLE();
0089 }
0090 #endif
0091
0092
0093 }