File indexing completed on 2025-12-16 10:12:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef DDG4_GEANT4PRIMARY_H
0015 #define DDG4_GEANT4PRIMARY_H
0016
0017
0018 #include <DD4hep/Memory.h>
0019 #include <DDG4/Geant4Vertex.h>
0020 #include <DDG4/Geant4Particle.h>
0021
0022
0023 #include <set>
0024 #include <map>
0025 #include <vector>
0026 #include <memory>
0027
0028
0029 class G4PrimaryParticle;
0030
0031
0032 namespace dd4hep {
0033
0034
0035 namespace sim {
0036
0037
0038 class Geant4Particle;
0039 class Geant4Vertex;
0040
0041
0042
0043
0044
0045
0046
0047 class PrimaryExtension {
0048 public:
0049
0050 PrimaryExtension() = default;
0051
0052 virtual ~PrimaryExtension();
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 class Geant4PrimaryMap {
0065 public:
0066 typedef std::map<const G4PrimaryParticle*,Geant4Particle*> Primaries;
0067 private:
0068
0069 Primaries m_primaryMap;
0070
0071 public:
0072
0073 Geant4PrimaryMap() = default;
0074
0075 virtual ~Geant4PrimaryMap();
0076
0077 void insert(G4PrimaryParticle* g4_particle,Geant4Particle* particle);
0078
0079 Geant4Particle* get(const G4PrimaryParticle* particle);
0080
0081 const Geant4Particle* get(const G4PrimaryParticle* particle) const;
0082
0083 Primaries& primaries() { return m_primaryMap; }
0084
0085 const Primaries& primaries() const { return m_primaryMap; }
0086 };
0087
0088
0089
0090
0091
0092
0093
0094
0095 class Geant4PrimaryInteraction {
0096 private:
0097
0098 Geant4PrimaryInteraction(const Geant4PrimaryInteraction& c) = delete;
0099
0100 Geant4PrimaryInteraction& operator=(const Geant4PrimaryInteraction& c) = delete;
0101
0102 public:
0103 typedef Geant4Particle Particle;
0104 typedef Geant4Vertex Vertex;
0105 typedef std::map<int,Particle*> ParticleMap;
0106 typedef std::map<int,std::vector<Vertex*>> VertexMap;
0107 typedef dd4hep_ptr<PrimaryExtension> ExtensionHandle;
0108
0109
0110 VertexMap vertices;
0111
0112 ParticleMap particles;
0113
0114 ExtensionHandle extension;
0115
0116 int mask = 0;
0117
0118 int locked = 0;
0119
0120 int next_particle_identifier = -1;
0121
0122 public:
0123
0124 Geant4PrimaryInteraction() = default;
0125
0126 virtual ~Geant4PrimaryInteraction();
0127
0128 int nextPID();
0129
0130 void setNextPID(int value);
0131
0132 bool applyMask();
0133 };
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 class Geant4PrimaryEvent {
0144 private:
0145
0146 Geant4PrimaryEvent(const Geant4PrimaryEvent& c) = delete;
0147
0148 Geant4PrimaryEvent& operator=(const Geant4PrimaryEvent& c) = delete;
0149
0150 public:
0151 typedef Geant4PrimaryInteraction Interaction;
0152 typedef std::map<int,Interaction*> Interactions;
0153 typedef dd4hep_ptr<PrimaryExtension> ExtensionHandle;
0154
0155 protected:
0156
0157 Interactions m_interactions;
0158
0159 public:
0160
0161 ExtensionHandle extension;
0162
0163 public:
0164
0165 Geant4PrimaryEvent() = default;
0166
0167 virtual ~Geant4PrimaryEvent();
0168
0169 void add(int id, Geant4PrimaryInteraction* interaction);
0170
0171 Geant4PrimaryInteraction* get(int id) const;
0172
0173 size_t size() const { return m_interactions.size(); }
0174
0175 std::vector<Geant4PrimaryInteraction*> interactions() const;
0176 };
0177
0178 }
0179 }
0180 #endif