Warning, file /include/Geant4/G4Event.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
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
0033
0034
0035
0036
0037
0038
0039
0040 #ifndef G4Event_hh
0041 #define G4Event_hh 1
0042
0043 #include <set>
0044 #include <map>
0045
0046 #include "globals.hh"
0047 #include "evtdefs.hh"
0048 #include "G4Allocator.hh"
0049 #include "G4PrimaryVertex.hh"
0050 #include "G4HCofThisEvent.hh"
0051 #include "G4DCofThisEvent.hh"
0052 #include "G4TrajectoryContainer.hh"
0053 #include "G4VUserEventInformation.hh"
0054
0055 class G4VHitsCollection;
0056 class G4SubEvent;
0057
0058 class G4Event
0059 {
0060 public:
0061 G4Event() = default;
0062 explicit G4Event(G4int evID);
0063 ~G4Event();
0064
0065 G4Event(const G4Event &) = delete;
0066 G4Event& operator=(const G4Event &) = delete;
0067
0068 inline void *operator new(std::size_t);
0069 inline void operator delete(void* anEvent);
0070
0071 G4bool operator==(const G4Event& right) const;
0072 G4bool operator!=(const G4Event& right) const;
0073
0074 void Print() const;
0075
0076 void Draw() const;
0077
0078
0079
0080
0081 inline void SetEventID(G4int i)
0082 { eventID = i; }
0083 inline void SetHCofThisEvent(G4HCofThisEvent* value)
0084 { HC = value; }
0085 inline void SetDCofThisEvent(G4DCofThisEvent* value)
0086 { DC = value; }
0087 inline void SetTrajectoryContainer(G4TrajectoryContainer* value)
0088 { trajectoryContainer = value; }
0089 inline void SetEventAborted()
0090 { eventAborted = true; }
0091 inline void SetRandomNumberStatus(G4String& st)
0092 {
0093 randomNumberStatus = new G4String(st);
0094 validRandomNumberStatus = true;
0095 }
0096 inline void SetRandomNumberStatusForProcessing(G4String& st)
0097 {
0098 randomNumberStatusForProcessing = new G4String(st);
0099 validRandomNumberStatusForProcessing = true;
0100 }
0101 inline void KeepTheEvent(G4bool vl=true) const
0102 { keepTheEvent = vl; }
0103 inline G4bool KeepTheEventFlag() const
0104 { return keepTheEvent; }
0105 inline G4bool ToBeKept() const
0106 {
0107
0108
0109
0110 return keepTheEvent || GetNumberOfRemainingSubEvents()>0;
0111 }
0112 inline void KeepForPostProcessing() const
0113 { ++grips; }
0114 inline void PostProcessingFinished() const
0115 {
0116 --grips;
0117 if (grips<0)
0118 {
0119 G4Exception("G4Event::Release()", "EVENT91001", JustWarning,
0120 "Number of grips is negative. This cannot be correct.");
0121 }
0122 }
0123 inline G4int GetNumberOfGrips() const
0124 { return grips; }
0125
0126 inline G4int GetEventID() const
0127 { return eventID; }
0128
0129 inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
0130 {
0131
0132
0133
0134 if( thePrimaryVertex == nullptr )
0135 { thePrimaryVertex = aPrimaryVertex; }
0136 else
0137 { thePrimaryVertex->SetNext( aPrimaryVertex ); }
0138 ++numberOfPrimaryVertex;
0139 }
0140
0141 inline G4int GetNumberOfPrimaryVertex() const
0142 { return numberOfPrimaryVertex; }
0143
0144
0145 inline G4PrimaryVertex* GetPrimaryVertex(G4int i=0) const
0146 {
0147 if( i == 0 )
0148 { return thePrimaryVertex; }
0149 if( i > 0 && i < numberOfPrimaryVertex )
0150 {
0151 G4PrimaryVertex* primaryVertex = thePrimaryVertex;
0152 for( G4int j=0; j<i; ++j )
0153 {
0154 if( primaryVertex == nullptr ) return nullptr;
0155 primaryVertex = primaryVertex->GetNext();
0156 }
0157 return primaryVertex;
0158 }
0159
0160 return nullptr;
0161 }
0162
0163
0164 inline G4HCofThisEvent* GetHCofThisEvent() const
0165 { return HC; }
0166 inline G4DCofThisEvent* GetDCofThisEvent() const
0167 { return DC; }
0168 inline G4TrajectoryContainer* GetTrajectoryContainer() const
0169 { return trajectoryContainer; }
0170
0171
0172
0173
0174
0175 inline G4bool IsAborted() const { return eventAborted; }
0176
0177
0178
0179 inline void SetUserInformation(G4VUserEventInformation* anInfo)
0180 { userInfo = anInfo; }
0181 inline G4VUserEventInformation* GetUserInformation() const
0182 { return userInfo; }
0183
0184
0185 inline const G4String& GetRandomNumberStatus() const
0186 {
0187 if(!validRandomNumberStatus)
0188 { G4Exception(
0189 "G4Event::GetRandomNumberStatus","Event0701",JustWarning,
0190 "Random number status is not available for this event."); }
0191 return *randomNumberStatus;
0192 }
0193 inline const G4String& GetRandomNumberStatusForProcessing() const
0194 {
0195 if(!validRandomNumberStatusForProcessing)
0196 { G4Exception(
0197 "G4Event::GetRandomNumberStatusForProcessing","Event0702",
0198 JustWarning,
0199 "Random number status is not available for this event."); }
0200 return *randomNumberStatusForProcessing;
0201 }
0202
0203 private:
0204
0205
0206 G4int eventID = 0;
0207
0208
0209 G4PrimaryVertex* thePrimaryVertex = nullptr;
0210 G4int numberOfPrimaryVertex = 0;
0211
0212
0213 G4HCofThisEvent* HC = nullptr;
0214
0215
0216 G4DCofThisEvent* DC = nullptr;
0217
0218
0219 G4TrajectoryContainer* trajectoryContainer = nullptr;
0220
0221
0222
0223 G4bool eventAborted = false;
0224
0225
0226 G4VUserEventInformation* userInfo = nullptr;
0227
0228
0229 G4String* randomNumberStatus = nullptr;
0230 G4bool validRandomNumberStatus = false;
0231
0232
0233 G4String* randomNumberStatusForProcessing = nullptr;
0234 G4bool validRandomNumberStatusForProcessing = false;
0235
0236
0237 mutable G4bool keepTheEvent = false;
0238 mutable G4int grips = 0;
0239
0240
0241
0242
0243 public:
0244 G4SubEvent* PopSubEvent(G4int);
0245
0246
0247 G4int TerminateSubEvent(G4SubEvent*);
0248
0249
0250
0251 G4int StoreSubEvent(G4int,G4SubEvent*);
0252
0253
0254
0255 G4int SpawnSubEvent(G4SubEvent*);
0256
0257 G4int GetNumberOfRemainingSubEvents() const;
0258
0259
0260 inline G4int GetNumberOfCompletedSubEvent() const
0261 { return (G4int)fSubEventGarbageBin.size(); }
0262
0263 void MergeSubEventResults(const G4Event* se);
0264
0265 private:
0266
0267
0268
0269
0270
0271
0272
0273
0274 std::map<G4int,std::set<G4SubEvent*>*> fSubEvtStackMap;
0275 std::set<G4SubEvent*> fSubEvtVector;
0276 std::set<G4SubEvent*> fSubEventGarbageBin;
0277
0278
0279
0280
0281
0282 private:
0283 G4Event* motherEvent = nullptr;
0284 G4int subEventType = -1;
0285
0286 public:
0287 void FlagAsSubEvent(G4Event* me, G4int ty)
0288 {
0289 motherEvent = me;
0290 subEventType = ty;
0291 }
0292 inline G4Event* GetMotherEvent() const
0293 { return motherEvent; }
0294 inline G4int GetSubEventType() const
0295 { return subEventType; }
0296
0297 private:
0298 mutable G4bool scoresRecorded = false;
0299 mutable G4bool eventCompleted = false;
0300 public:
0301 void ScoresRecorded() const { scoresRecorded = true; }
0302 G4bool ScoresAlreadyRecorded() const { return scoresRecorded; }
0303 void EventCompleted() const { eventCompleted = true; }
0304 G4bool IsEventCompleted() const { return eventCompleted; }
0305 };
0306
0307 extern G4EVENT_DLL G4Allocator<G4Event>*& anEventAllocator();
0308
0309 inline void* G4Event::operator new(std::size_t)
0310 {
0311 if (anEventAllocator() == nullptr)
0312 {
0313 anEventAllocator() = new G4Allocator<G4Event>;
0314 }
0315 return (void*)anEventAllocator()->MallocSingle();
0316 }
0317
0318 inline void G4Event::operator delete(void* anEvent)
0319 {
0320 anEventAllocator()->FreeSingle((G4Event*)anEvent);
0321 }
0322
0323 #endif