Warning, file /include/accel/HepMC3PrimaryGenerator.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <deque>
0010 #include <memory>
0011 #include <mutex>
0012 #include <G4Event.hh>
0013 #include <G4VPrimaryGenerator.hh>
0014
0015 #include "corecel/Config.hh"
0016
0017 #include "corecel/Assert.hh"
0018 #include "corecel/Macros.hh"
0019
0020 class G4VSolid;
0021
0022 namespace HepMC3
0023 {
0024 class Reader;
0025 class GenEvent;
0026 }
0027
0028 namespace celeritas
0029 {
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 class HepMC3PrimaryGenerator final : public G4VPrimaryGenerator
0050 {
0051 public:
0052
0053 explicit HepMC3PrimaryGenerator(std::string const& filename);
0054
0055 CELER_DELETE_COPY_MOVE(HepMC3PrimaryGenerator);
0056 ~HepMC3PrimaryGenerator() final = default;
0057
0058
0059 void GeneratePrimaryVertex(G4Event* g4_event) final;
0060
0061
0062 int NumEvents() { return static_cast<int>(num_events_); }
0063
0064 private:
0065 using SPReader = std::shared_ptr<HepMC3::Reader>;
0066 using SPHepEvt = std::shared_ptr<HepMC3::GenEvent>;
0067 using size_type = std::size_t;
0068
0069 size_type num_events_{0};
0070 G4VSolid* world_solid_{nullptr};
0071
0072 SPReader reader_;
0073 std::mutex read_mutex_;
0074 std::deque<SPHepEvt> event_buffer_;
0075 size_type start_event_{0};
0076 bool warned_mismatched_events_{false};
0077
0078
0079 SPHepEvt read_event(size_type event_id);
0080 };
0081
0082
0083 #if !CELERITAS_USE_HEPMC3
0084 inline HepMC3PrimaryGenerator::HepMC3PrimaryGenerator(std::string const&)
0085 {
0086 CELER_NOT_CONFIGURED("HepMC3");
0087 CELER_DISCARD(num_events_);
0088 CELER_DISCARD(world_solid_);
0089 CELER_DISCARD(reader_);
0090 CELER_DISCARD(read_mutex_);
0091 CELER_DISCARD(event_buffer_);
0092 CELER_DISCARD(start_event_);
0093 CELER_DISCARD(warned_mismatched_events_);
0094 }
0095
0096 inline void HepMC3PrimaryGenerator::GeneratePrimaryVertex(G4Event*)
0097 {
0098 CELER_ASSERT_UNREACHABLE();
0099 }
0100 #endif
0101
0102
0103 }