[816] | 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,v 1.17 2007/03/08 23:56:12 asaim Exp $ |
---|
[964] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[816] | 29 | // |
---|
| 30 | |
---|
| 31 | #ifndef G4Event_h |
---|
| 32 | #define G4Event_h 1 |
---|
| 33 | |
---|
| 34 | #include "globals.hh" |
---|
| 35 | #include "G4Allocator.hh" |
---|
| 36 | #include "G4PrimaryVertex.hh" |
---|
| 37 | #include "G4HCofThisEvent.hh" |
---|
| 38 | #include "G4DCofThisEvent.hh" |
---|
| 39 | #include "G4TrajectoryContainer.hh" |
---|
| 40 | #include "G4VUserEventInformation.hh" |
---|
| 41 | |
---|
| 42 | // class description: |
---|
| 43 | // |
---|
| 44 | // This is the class which represents an event. This class is constructed and |
---|
| 45 | // deleted by G4RunManager (or its derived class). When G4Event object is passed |
---|
| 46 | // to G4EventManager, G4Event must have one or more primary vertexes and primary |
---|
| 47 | // particle(s) associated to the vertex(es) as an input of simulating an event. |
---|
| 48 | // As the consequences of simulating an event, G4Event has trajectories, hits |
---|
| 49 | // collections, and/or digi collections. |
---|
| 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 | // event ID |
---|
| 75 | G4int eventID; |
---|
| 76 | |
---|
| 77 | // PrimaryVertex |
---|
| 78 | G4PrimaryVertex* thePrimaryVertex; |
---|
| 79 | G4int numberOfPrimaryVertex; |
---|
| 80 | |
---|
| 81 | // HitsCollection |
---|
| 82 | G4HCofThisEvent* HC; |
---|
| 83 | |
---|
| 84 | // DigiCollection |
---|
| 85 | G4DCofThisEvent* DC; |
---|
| 86 | |
---|
| 87 | // TrajectoryContainer |
---|
| 88 | G4TrajectoryContainer * trajectoryContainer; |
---|
| 89 | |
---|
| 90 | // Boolean flag which shall be set to true if the event is aborted and |
---|
| 91 | // thus the containing information is not to be used. |
---|
| 92 | G4bool eventAborted; |
---|
| 93 | |
---|
| 94 | // UserEventInformation (optional) |
---|
| 95 | G4VUserEventInformation* userInfo; |
---|
| 96 | |
---|
| 97 | // Initial random number engine status before primary particle generation |
---|
| 98 | G4String* randomNumberStatus; |
---|
| 99 | G4bool validRandomNumberStatus; |
---|
| 100 | |
---|
| 101 | // Initial random number engine status before event processing |
---|
| 102 | G4String* randomNumberStatusForProcessing; |
---|
| 103 | G4bool validRandomNumberStatusForProcessing; |
---|
| 104 | |
---|
| 105 | // Flag to keep the event until the end of run |
---|
| 106 | G4bool keepTheEvent; |
---|
| 107 | |
---|
| 108 | public: |
---|
| 109 | inline void SetEventID(G4int i) |
---|
| 110 | { eventID = i; } |
---|
| 111 | inline void SetHCofThisEvent(G4HCofThisEvent*value) |
---|
| 112 | { HC = value; } |
---|
| 113 | inline void SetDCofThisEvent(G4DCofThisEvent*value) |
---|
| 114 | { DC = value; } |
---|
| 115 | inline void SetTrajectoryContainer(G4TrajectoryContainer*value) |
---|
| 116 | { trajectoryContainer = value; } |
---|
| 117 | inline void SetEventAborted() |
---|
| 118 | { eventAborted = true; } |
---|
| 119 | inline void SetRandomNumberStatus(G4String& st) |
---|
| 120 | { |
---|
| 121 | randomNumberStatus = new G4String(st); |
---|
| 122 | validRandomNumberStatus = true; |
---|
| 123 | } |
---|
| 124 | inline void SetRandomNumberStatusForProcessing(G4String& st) |
---|
| 125 | { |
---|
| 126 | randomNumberStatusForProcessing = new G4String(st); |
---|
| 127 | validRandomNumberStatusForProcessing = true; |
---|
| 128 | } |
---|
| 129 | inline void KeepTheEvent(G4bool vl=true) |
---|
| 130 | { keepTheEvent = vl; } |
---|
| 131 | inline G4bool ToBeKept() const |
---|
| 132 | { return keepTheEvent; } |
---|
| 133 | |
---|
| 134 | public: // with description |
---|
| 135 | inline G4int GetEventID() const |
---|
| 136 | { return eventID; } |
---|
| 137 | // Returns the event ID |
---|
| 138 | inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex) |
---|
| 139 | { |
---|
| 140 | if( thePrimaryVertex == 0 ) |
---|
| 141 | { thePrimaryVertex = aPrimaryVertex; } |
---|
| 142 | else |
---|
| 143 | { thePrimaryVertex->SetNext( aPrimaryVertex ); } |
---|
| 144 | numberOfPrimaryVertex++; |
---|
| 145 | } |
---|
| 146 | // This method sets a new primary vertex. This method must be invoked |
---|
| 147 | // exclusively by G4VPrimaryGenerator concrete class. |
---|
| 148 | inline G4int GetNumberOfPrimaryVertex() const |
---|
| 149 | { return numberOfPrimaryVertex; } |
---|
| 150 | // Returns number of primary vertexes the G4Event object has. |
---|
| 151 | inline G4PrimaryVertex* GetPrimaryVertex(G4int i=0) const |
---|
| 152 | { |
---|
| 153 | if( i == 0 ) |
---|
| 154 | { return thePrimaryVertex; } |
---|
| 155 | else if( i > 0 && i < numberOfPrimaryVertex ) |
---|
| 156 | { |
---|
| 157 | G4PrimaryVertex* primaryVertex = thePrimaryVertex; |
---|
| 158 | for( G4int j=0; j<i; j++ ) |
---|
| 159 | { |
---|
| 160 | if( primaryVertex == 0 ) return 0; |
---|
| 161 | primaryVertex = primaryVertex->GetNext(); |
---|
| 162 | } |
---|
| 163 | return primaryVertex; |
---|
| 164 | } |
---|
| 165 | else |
---|
| 166 | { return 0; } |
---|
| 167 | } |
---|
| 168 | // Returns i-th primary vertex of the event. |
---|
| 169 | inline G4HCofThisEvent* GetHCofThisEvent() const |
---|
| 170 | { return HC; } |
---|
| 171 | inline G4DCofThisEvent* GetDCofThisEvent() const |
---|
| 172 | { return DC; } |
---|
| 173 | inline G4TrajectoryContainer* GetTrajectoryContainer() const |
---|
| 174 | { return trajectoryContainer; } |
---|
| 175 | // These three methods returns the pointers to the G4HCofThisEvent |
---|
| 176 | // (hits collections of this event), G4DCofThisEvent (digi collections |
---|
| 177 | // of this event), and G4TrajectoryContainer (trajectory coonainer), |
---|
| 178 | // respectively. |
---|
| 179 | inline G4bool IsAborted() const { return eventAborted; } |
---|
| 180 | // Return a boolean which indicates the event has been aborted and thus |
---|
| 181 | // it should not be used for analysis. |
---|
| 182 | inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; } |
---|
| 183 | inline G4VUserEventInformation* GetUserInformation() const { return userInfo; } |
---|
| 184 | // Set and Get method of G4VUserEventInformation |
---|
| 185 | inline const G4String& GetRandomNumberStatus() const |
---|
| 186 | { |
---|
| 187 | if(!validRandomNumberStatus) |
---|
| 188 | { G4Exception("Random number status is not available for this event."); } |
---|
| 189 | return *randomNumberStatus; |
---|
| 190 | } |
---|
| 191 | inline const G4String& GetRandomNumberStatusForProcessing() const |
---|
| 192 | { |
---|
| 193 | if(!validRandomNumberStatusForProcessing) |
---|
| 194 | { G4Exception("Random number status is not available for this event."); } |
---|
| 195 | return *randomNumberStatusForProcessing; |
---|
| 196 | } |
---|
| 197 | }; |
---|
| 198 | |
---|
| 199 | #if defined G4EVENT_ALLOC_EXPORT |
---|
| 200 | extern G4DLLEXPORT G4Allocator<G4Event> anEventAllocator; |
---|
| 201 | #else |
---|
| 202 | extern G4DLLIMPORT G4Allocator<G4Event> anEventAllocator; |
---|
| 203 | #endif |
---|
| 204 | |
---|
| 205 | inline void* G4Event::operator new(size_t) |
---|
| 206 | { |
---|
| 207 | void* anEvent; |
---|
| 208 | anEvent = (void*)anEventAllocator.MallocSingle(); |
---|
| 209 | return anEvent; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | inline void G4Event::operator delete(void* anEvent) |
---|
| 213 | { |
---|
| 214 | anEventAllocator.FreeSingle((G4Event*)anEvent); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | #endif |
---|
| 218 | |
---|