File indexing completed on 2025-09-18 09:15:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef G4SubEvent_hh
0033 #define G4SubEvent_hh 1
0034
0035 #include <vector>
0036
0037 class G4Event;
0038
0039 #include "globals.hh"
0040 #include "evtdefs.hh"
0041 #include "G4Allocator.hh"
0042 #include "G4StackedTrack.hh"
0043 #include "G4Types.hh"
0044
0045 class G4SubEvent : public std::vector<G4StackedTrack>
0046 {
0047 public:
0048
0049 G4SubEvent() = default;
0050 explicit G4SubEvent(G4int ty, std::size_t maxEnt)
0051 : fSubEventType(ty), fMaxEnt(maxEnt) {;}
0052 ~G4SubEvent();
0053
0054 G4SubEvent& operator=(const G4SubEvent&) = delete;
0055
0056 inline void *operator new(std::size_t);
0057 inline void operator delete(void* anEvent);
0058
0059 G4bool operator==(const G4SubEvent&) const = delete;
0060 G4bool operator!=(const G4SubEvent&) const = delete;
0061
0062 inline void PushToStack(const G4StackedTrack& aStackedTrack)
0063 { push_back(aStackedTrack); }
0064 G4StackedTrack PopFromStack();
0065
0066 void clearAndDestroy();
0067
0068 inline G4int GetSubEventType() const { return fSubEventType; }
0069 inline std::size_t GetNTrack() const { return size(); }
0070 inline std::size_t GetMaxNTrack() const { return fMaxEnt; }
0071
0072 G4double getTotalEnergy() const;
0073
0074
0075 inline void SetEvent(G4Event* evt) { fpEvent = evt; }
0076 inline G4Event* GetEvent() const { return fpEvent; }
0077
0078 private:
0079
0080 G4int fSubEventType = -1;
0081 std::size_t fMaxEnt = 1000;
0082 G4Event* fpEvent = nullptr;
0083
0084 };
0085
0086 extern G4EVENT_DLL G4Allocator<G4SubEvent>*& aSubEventAllocator();
0087
0088 inline void* G4SubEvent::operator new(std::size_t)
0089 {
0090 if (aSubEventAllocator() == nullptr)
0091 {
0092 aSubEventAllocator() = new G4Allocator<G4SubEvent>;
0093 }
0094 return (void*)aSubEventAllocator()->MallocSingle();
0095 }
0096
0097 inline void G4SubEvent::operator delete(void* aSubEvent)
0098 {
0099 aSubEventAllocator()->FreeSingle((G4SubEvent*)aSubEvent);
0100 }
0101
0102 #endif