Geant4  10.00.p01
G4Event.hh
Go to the documentation of this file.
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 // $Id: G4Event.hh 69010 2013-04-15 09:34:16Z gcosmo $
28 //
29 //
30 // class description:
31 //
32 // This is the class which represents an event. A G4Event is constructed and
33 // deleted by G4RunManager (or its derived class). When a G4Event object is
34 // passed to G4EventManager, G4Event must have one or more primary verteces
35 // and primary particle(s) associated to the vertex(es) as an input of
36 // simulating an event.
37 // G4Event has trajectories, hits collections, and/or digi collections.
38 
39 #ifndef G4Event_h
40 #define G4Event_h 1
41 
42 #include "globals.hh"
43 #include "evtdefs.hh"
44 #include "G4Allocator.hh"
45 #include "G4PrimaryVertex.hh"
46 #include "G4HCofThisEvent.hh"
47 #include "G4DCofThisEvent.hh"
48 #include "G4TrajectoryContainer.hh"
50 
51 class G4VHitsCollection;
52 class G4Event
53 {
54  public:
55  G4Event();
56  G4Event(G4int evID);
57  ~G4Event();
58 
59  inline void *operator new(size_t);
60  inline void operator delete(void* anEvent);
61 
62  G4int operator==(const G4Event &right) const;
63  G4int operator!=(const G4Event &right) const;
64 
65  public: // with description
66  void Print() const;
67  // Print the event ID (starts with zero and increments by one) to G4cout.
68  void Draw() const;
69  // Invoke Draw() methods of all stored trajectories, hits, and digits.
70  // For hits and digits, Draw() methods of the concrete classes must be
71  // implemented. Otherwise nothing will be drawn.
72 
73  private:
74  // Copy constructor and = operator must not be used.
75  G4Event(const G4Event &) {;}
76  G4Event& operator=(const G4Event &) { return *this; }
77 
78  private:
79  // event ID
81 
82  // PrimaryVertex
85 
86  // HitsCollection
88 
89  // DigiCollection
91 
92  // TrajectoryContainer
94 
95  // Boolean flag which shall be set to true if the event is aborted and
96  // thus the containing information is not to be used.
98 
99  // UserEventInformation (optional)
101 
102  // Initial random number engine status before primary particle generation
105 
106  // Initial random number engine status before event processing
109 
110  // Flag to keep the event until the end of run
112 
113  public:
114  inline void SetEventID(G4int i)
115  { eventID = i; }
117  { HC = value; }
119  { DC = value; }
121  { trajectoryContainer = value; }
122  inline void SetEventAborted()
123  { eventAborted = true; }
125  {
126  randomNumberStatus = new G4String(st);
127  validRandomNumberStatus = true;
128  }
130  {
131  randomNumberStatusForProcessing = new G4String(st);
132  validRandomNumberStatusForProcessing = true;
133  }
134  inline void KeepTheEvent(G4bool vl=true)
135  { keepTheEvent = vl; }
136  inline G4bool ToBeKept() const
137  { return keepTheEvent; }
138 
139  public: // with description
140  inline G4int GetEventID() const
141  { return eventID; }
142  // Returns the event ID
143  inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
144  {
145  if( thePrimaryVertex == 0 )
146  { thePrimaryVertex = aPrimaryVertex; }
147  else
148  { thePrimaryVertex->SetNext( aPrimaryVertex ); }
149  numberOfPrimaryVertex++;
150  }
151  // This method sets a new primary vertex. This method must be invoked
152  // exclusively by G4VPrimaryGenerator concrete class.
154  { return numberOfPrimaryVertex; }
155  // Returns number of primary vertexes the G4Event object has.
157  {
158  if( i == 0 )
159  { return thePrimaryVertex; }
160  else if( i > 0 && i < numberOfPrimaryVertex )
161  {
162  G4PrimaryVertex* primaryVertex = thePrimaryVertex;
163  for( G4int j=0; j<i; j++ )
164  {
165  if( primaryVertex == 0 ) return 0;
166  primaryVertex = primaryVertex->GetNext();
167  }
168  return primaryVertex;
169  }
170  else
171  { return 0; }
172  }
173  // Returns i-th primary vertex of the event.
175  { return HC; }
177  { return DC; }
179  { return trajectoryContainer; }
180  // These three methods returns the pointers to the G4HCofThisEvent
181  // (hits collections of this event), G4DCofThisEvent (digi collections
182  // of this event), and G4TrajectoryContainer (trajectory coonainer),
183  // respectively.
184  inline G4bool IsAborted() const { return eventAborted; }
185  // Return a boolean which indicates the event has been aborted and thus
186  // it should not be used for analysis.
187  inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; }
189  // Set and Get method of G4VUserEventInformation
190  inline const G4String& GetRandomNumberStatus() const
191  {
192  if(!validRandomNumberStatus)
193  { G4Exception(
194  "G4Event::GetRandomNumberStatus","Event0701",JustWarning,
195  "Random number status is not available for this event."); }
196  return *randomNumberStatus;
197  }
199  {
200  if(!validRandomNumberStatusForProcessing)
201  { G4Exception(
202  "G4Event::GetRandomNumberStatusForProcessing","Event0702",
203  JustWarning,
204  "Random number status is not available for this event."); }
206  }
207 };
208 
210 
211 inline void* G4Event::operator new(size_t)
212 {
214  return (void*)anEventAllocator->MallocSingle();
215 }
216 
217 inline void G4Event::operator delete(void* anEvent)
218 {
219  anEventAllocator->FreeSingle((G4Event*)anEvent);
220 }
221 
222 #endif
G4VUserEventInformation * GetUserInformation() const
Definition: G4Event.hh:188
const G4String & GetRandomNumberStatusForProcessing() const
Definition: G4Event.hh:198
G4bool validRandomNumberStatusForProcessing
Definition: G4Event.hh:108
G4int GetNumberOfPrimaryVertex() const
Definition: G4Event.hh:153
#define G4EVENT_DLL
Definition: evtdefs.hh:48
G4int operator==(const G4Event &right) const
Definition: G4Event.cc:77
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
Definition: G4Event.hh:143
void SetRandomNumberStatusForProcessing(G4String &st)
Definition: G4Event.hh:129
void SetHCofThisEvent(G4HCofThisEvent *value)
Definition: G4Event.hh:116
void Print() const
Definition: G4Event.cc:87
G4EVENT_DLL G4ThreadLocal G4Allocator< G4Event > * anEventAllocator
Definition: G4Event.cc:40
G4bool keepTheEvent
Definition: G4Event.hh:111
~G4Event()
Definition: G4Event.cc:62
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:178
const G4String & GetRandomNumberStatus() const
Definition: G4Event.hh:190
G4bool eventAborted
Definition: G4Event.hh:97
G4int GetEventID() const
Definition: G4Event.hh:140
G4Event(const G4Event &)
Definition: G4Event.hh:75
G4bool ToBeKept() const
Definition: G4Event.hh:136
G4String * randomNumberStatus
Definition: G4Event.hh:103
G4int numberOfPrimaryVertex
Definition: G4Event.hh:84
void SetUserInformation(G4VUserEventInformation *anInfo)
Definition: G4Event.hh:187
G4Event()
Definition: G4Event.cc:42
bool G4bool
Definition: G4Types.hh:79
G4VUserEventInformation * userInfo
Definition: G4Event.hh:100
G4PrimaryVertex * thePrimaryVertex
Definition: G4Event.hh:83
G4DCofThisEvent * DC
Definition: G4Event.hh:90
void SetNext(G4PrimaryVertex *nv)
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:156
G4String * randomNumberStatusForProcessing
Definition: G4Event.hh:107
void SetEventAborted()
Definition: G4Event.hh:122
G4PrimaryVertex * GetNext() const
void Draw() const
Definition: G4Event.cc:92
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:124
G4Event & operator=(const G4Event &)
Definition: G4Event.hh:76
void SetDCofThisEvent(G4DCofThisEvent *value)
Definition: G4Event.hh:118
G4int eventID
Definition: G4Event.hh:80
G4bool validRandomNumberStatus
Definition: G4Event.hh:104
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174
void SetTrajectoryContainer(G4TrajectoryContainer *value)
Definition: G4Event.hh:120
G4DCofThisEvent * GetDCofThisEvent() const
Definition: G4Event.hh:176
void KeepTheEvent(G4bool vl=true)
Definition: G4Event.hh:134
G4HCofThisEvent * HC
Definition: G4Event.hh:87
G4int operator!=(const G4Event &right) const
Definition: G4Event.cc:82
void SetEventID(G4int i)
Definition: G4Event.hh:114
G4TrajectoryContainer * trajectoryContainer
Definition: G4Event.hh:93
G4bool IsAborted() const
Definition: G4Event.hh:184