ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Event.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Event.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // class description:
30 //
31 // This is the class which represents an event. A G4Event is constructed and
32 // deleted by G4RunManager (or its derived class). When a G4Event object is
33 // passed to G4EventManager, G4Event must have one or more primary verteces
34 // and primary particle(s) associated to the vertex(es) as an input of
35 // simulating an event.
36 // G4Event has trajectories, hits collections, and/or digi collections.
37 
38 #ifndef G4Event_h
39 #define G4Event_h 1
40 
41 #include "globals.hh"
42 #include "evtdefs.hh"
43 #include "G4Allocator.hh"
44 #include "G4PrimaryVertex.hh"
45 #include "G4HCofThisEvent.hh"
46 #include "G4DCofThisEvent.hh"
47 #include "G4TrajectoryContainer.hh"
49 
50 class G4VHitsCollection;
51 class G4Event
52 {
53  public:
54  G4Event();
55  G4Event(G4int evID);
56  ~G4Event();
57 
58  inline void *operator new(size_t);
59  inline void operator delete(void* anEvent);
60 
61  G4bool operator==(const G4Event &right) const;
62  G4bool operator!=(const G4Event &right) const;
63 
64  public: // with description
65  void Print() const;
66  // Print the event ID (starts with zero and increments by one) to G4cout.
67  void Draw() const;
68  // Invoke Draw() methods of all stored trajectories, hits, and digits.
69  // For hits and digits, Draw() methods of the concrete classes must be
70  // implemented. Otherwise nothing will be drawn.
71 
72  private:
73  // Copy constructor and = operator must not be used.
74  G4Event(const G4Event &) {;}
75  G4Event& operator=(const G4Event &) { return *this; }
76 
77  private:
78  // event ID
80 
81  // PrimaryVertex
84 
85  // HitsCollection
87 
88  // DigiCollection
90 
91  // TrajectoryContainer
93 
94  // Boolean flag which shall be set to true if the event is aborted and
95  // thus the containing information is not to be used.
97 
98  // UserEventInformation (optional)
100 
101  // Initial random number engine status before primary particle generation
104 
105  // Initial random number engine status before event processing
108 
109  // Flag to keep the event until the end of run
111  mutable G4int grips;
112 
113  public:
114  inline void SetEventID(G4int i)
115  { eventID = i; }
117  { HC = value; }
119  { DC = value; }
122  inline void SetEventAborted()
123  { eventAborted = true; }
125  {
126  randomNumberStatus = new G4String(st);
128  }
130  {
133  }
134  inline void KeepTheEvent(G4bool vl=true)
135  { keepTheEvent = vl; }
136  inline G4bool ToBeKept() const
137  { return keepTheEvent; }
138  inline void KeepForPostProcessing() const
139  { grips++; }
140  inline void PostProcessingFinished() const
141  { grips--;
142  if(grips<0)
143  { G4Exception("G4Event::Release()","EVENT91001",FatalException,
144  "Number of grips became negative. This cannot be correct."); }
145  }
146  inline G4int GetNumberOfGrips() const
147  { return grips; }
148 
149  public: // with description
150  inline G4int GetEventID() const
151  { return eventID; }
152  // Returns the event ID
153  inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
154  {
155  if( thePrimaryVertex == nullptr )
156  { thePrimaryVertex = aPrimaryVertex; }
157  else
158  { thePrimaryVertex->SetNext( aPrimaryVertex ); }
160  }
161  // This method sets a new primary vertex. This method must be invoked
162  // exclusively by G4VPrimaryGenerator concrete class.
164  { return numberOfPrimaryVertex; }
165  // Returns number of primary vertexes the G4Event object has.
167  {
168  if( i == 0 )
169  { return thePrimaryVertex; }
170  else if( i > 0 && i < numberOfPrimaryVertex )
171  {
172  G4PrimaryVertex* primaryVertex = thePrimaryVertex;
173  for( G4int j=0; j<i; j++ )
174  {
175  if( !primaryVertex ) return nullptr;
176  primaryVertex = primaryVertex->GetNext();
177  }
178  return primaryVertex;
179  }
180  else
181  { return nullptr; }
182  }
183  // Returns i-th primary vertex of the event.
185  { return HC; }
187  { return DC; }
189  { return trajectoryContainer; }
190  // These three methods returns the pointers to the G4HCofThisEvent
191  // (hits collections of this event), G4DCofThisEvent (digi collections
192  // of this event), and G4TrajectoryContainer (trajectory coonainer),
193  // respectively.
194  inline G4bool IsAborted() const { return eventAborted; }
195  // Return a boolean which indicates the event has been aborted and thus
196  // it should not be used for analysis.
197  inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; }
199  // Set and Get method of G4VUserEventInformation
200  inline const G4String& GetRandomNumberStatus() const
201  {
203  { G4Exception(
204  "G4Event::GetRandomNumberStatus","Event0701",JustWarning,
205  "Random number status is not available for this event."); }
206  return *randomNumberStatus;
207  }
209  {
211  { G4Exception(
212  "G4Event::GetRandomNumberStatusForProcessing","Event0702",
213  JustWarning,
214  "Random number status is not available for this event."); }
216  }
217 };
218 
220 
221 inline void* G4Event::operator new(size_t)
222 {
224  return (void*)anEventAllocator()->MallocSingle();
225 }
226 
227 inline void G4Event::operator delete(void* anEvent)
228 {
229  anEventAllocator()->FreeSingle((G4Event*)anEvent);
230 }
231 
232 #endif