Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
28 //
29 
30 #ifndef G4Event_h
31 #define G4Event_h 1
32 
33 #include "globals.hh"
34 #include "G4Allocator.hh"
35 #include "G4PrimaryVertex.hh"
36 #include "G4HCofThisEvent.hh"
37 #include "G4DCofThisEvent.hh"
38 #include "G4TrajectoryContainer.hh"
40 
41 // class description:
42 //
43 // This is the class which represents an event. This class is constructed and
44 // deleted by G4RunManager (or its derived class). When G4Event object is passed
45 // to G4EventManager, G4Event must have one or more primary vertexes and primary
46 // particle(s) associated to the vertex(es) as an input of simulating an event.
47 // As the consequences of simulating an event, G4Event has trajectories, hits
48 // collections, and/or digi collections.
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  G4int operator==(const G4Event &right) const;
62  G4int 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  // These 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
79  G4int eventID;
80 
81  // PrimaryVertex
82  G4PrimaryVertex* thePrimaryVertex;
83  G4int numberOfPrimaryVertex;
84 
85  // HitsCollection
86  G4HCofThisEvent* HC;
87 
88  // DigiCollection
89  G4DCofThisEvent* DC;
90 
91  // TrajectoryContainer
92  G4TrajectoryContainer * 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.
96  G4bool eventAborted;
97 
98  // UserEventInformation (optional)
99  G4VUserEventInformation* userInfo;
100 
101  // Initial random number engine status before primary particle generation
102  G4String* randomNumberStatus;
103  G4bool validRandomNumberStatus;
104 
105  // Initial random number engine status before event processing
106  G4String* randomNumberStatusForProcessing;
107  G4bool validRandomNumberStatusForProcessing;
108 
109  // Flag to keep the event until the end of run
110  G4bool keepTheEvent;
111 
112  public:
113  inline void SetEventID(G4int i)
114  { eventID = i; }
116  { HC = value; }
118  { DC = value; }
120  { trajectoryContainer = value; }
121  inline void SetEventAborted()
122  { eventAborted = true; }
124  {
125  randomNumberStatus = new G4String(st);
126  validRandomNumberStatus = true;
127  }
129  {
130  randomNumberStatusForProcessing = new G4String(st);
131  validRandomNumberStatusForProcessing = true;
132  }
133  inline void KeepTheEvent(G4bool vl=true)
134  { keepTheEvent = vl; }
135  inline G4bool ToBeKept() const
136  { return keepTheEvent; }
137 
138  public: // with description
139  inline G4int GetEventID() const
140  { return eventID; }
141  // Returns the event ID
142  inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
143  {
144  if( thePrimaryVertex == 0 )
145  { thePrimaryVertex = aPrimaryVertex; }
146  else
147  { thePrimaryVertex->SetNext( aPrimaryVertex ); }
148  numberOfPrimaryVertex++;
149  }
150  // This method sets a new primary vertex. This method must be invoked
151  // exclusively by G4VPrimaryGenerator concrete class.
153  { return numberOfPrimaryVertex; }
154  // Returns number of primary vertexes the G4Event object has.
156  {
157  if( i == 0 )
158  { return thePrimaryVertex; }
159  else if( i > 0 && i < numberOfPrimaryVertex )
160  {
161  G4PrimaryVertex* primaryVertex = thePrimaryVertex;
162  for( G4int j=0; j<i; j++ )
163  {
164  if( primaryVertex == 0 ) return 0;
165  primaryVertex = primaryVertex->GetNext();
166  }
167  return primaryVertex;
168  }
169  else
170  { return 0; }
171  }
172  // Returns i-th primary vertex of the event.
174  { return HC; }
176  { return DC; }
178  { return trajectoryContainer; }
179  // These three methods returns the pointers to the G4HCofThisEvent
180  // (hits collections of this event), G4DCofThisEvent (digi collections
181  // of this event), and G4TrajectoryContainer (trajectory coonainer),
182  // respectively.
183  inline G4bool IsAborted() const { return eventAborted; }
184  // Return a boolean which indicates the event has been aborted and thus
185  // it should not be used for analysis.
186  inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; }
187  inline G4VUserEventInformation* GetUserInformation() const { return userInfo; }
188  // Set and Get method of G4VUserEventInformation
189  inline const G4String& GetRandomNumberStatus() const
190  {
191  if(!validRandomNumberStatus)
192  { G4Exception(
193  "G4Event::GetRandomNumberStatus","Event0701",JustWarning,
194  "Random number status is not available for this event."); }
195  return *randomNumberStatus;
196  }
198  {
199  if(!validRandomNumberStatusForProcessing)
200  { G4Exception(
201  "G4Event::GetRandomNumberStatusForProcessing","Event0702",
202  JustWarning,
203  "Random number status is not available for this event."); }
204  return *randomNumberStatusForProcessing;
205  }
206 };
207 
208 #if defined G4EVENT_ALLOC_EXPORT
210 #else
212 #endif
213 
214 inline void* G4Event::operator new(size_t)
215 {
216  void* anEvent;
217  anEvent = (void*)anEventAllocator.MallocSingle();
218  return anEvent;
219 }
220 
221 inline void G4Event::operator delete(void* anEvent)
222 {
223  anEventAllocator.FreeSingle((G4Event*)anEvent);
224 }
225 
226 #endif
227