G4Event.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #ifndef G4Event_h
00031 #define G4Event_h 1
00032 
00033 #include "globals.hh"
00034 #include "G4Allocator.hh"
00035 #include "G4PrimaryVertex.hh"
00036 #include "G4HCofThisEvent.hh"
00037 #include "G4DCofThisEvent.hh"
00038 #include "G4TrajectoryContainer.hh"
00039 #include "G4VUserEventInformation.hh"
00040 
00041 // class description:
00042 //
00043 //  This is the class which represents an event. This class is constructed and
00044 // deleted by G4RunManager (or its derived class). When G4Event object is passed
00045 // to G4EventManager, G4Event must have one or more primary vertexes and primary 
00046 // particle(s) associated to the vertex(es) as an input of simulating an event.
00047 // As the consequences of simulating an event, G4Event has trajectories, hits
00048 // collections, and/or digi collections. 
00049 
00050 class G4VHitsCollection;
00051 class G4Event 
00052 {
00053   public:
00054       G4Event();
00055       G4Event(G4int evID);
00056       ~G4Event();
00057 
00058       inline void *operator new(size_t);
00059       inline void operator delete(void* anEvent);
00060 
00061       G4int operator==(const G4Event &right) const;
00062       G4int operator!=(const G4Event &right) const;
00063 
00064   public: // with description
00065       void Print() const;
00066       // Print the event ID (starts with zero and increments by one) to G4cout.
00067       void Draw() const;
00068       // Invoke Draw() methods of all stored trajectories, hits, and digits.
00069       // For hits and digits, Draw() methods of the concrete classes must be
00070       // implemented. Otherwise nothing will be drawn.
00071 
00072   private:
00073       // These copy constructor and = operator must not be used.
00074       G4Event(const G4Event &) {;}
00075       G4Event& operator=(const G4Event &) { return *this; }
00076 
00077   private:
00078       // event ID
00079       G4int eventID;      
00080 
00081       // PrimaryVertex
00082       G4PrimaryVertex* thePrimaryVertex;
00083       G4int numberOfPrimaryVertex;
00084 
00085       // HitsCollection
00086       G4HCofThisEvent* HC;
00087 
00088       // DigiCollection
00089       G4DCofThisEvent* DC;
00090 
00091       // TrajectoryContainer
00092       G4TrajectoryContainer * trajectoryContainer;
00093 
00094       // Boolean flag which shall be set to true if the event is aborted and 
00095       // thus the containing information is not to be used.
00096       G4bool eventAborted;
00097 
00098       // UserEventInformation (optional)
00099       G4VUserEventInformation* userInfo;
00100 
00101       // Initial random number engine status before primary particle generation
00102       G4String* randomNumberStatus;
00103       G4bool validRandomNumberStatus;
00104 
00105       // Initial random number engine status before event processing
00106       G4String* randomNumberStatusForProcessing;
00107       G4bool validRandomNumberStatusForProcessing;
00108 
00109       // Flag to keep the event until the end of run
00110       G4bool keepTheEvent;
00111 
00112   public:
00113       inline void SetEventID(G4int i)
00114       { eventID =  i; }
00115       inline void SetHCofThisEvent(G4HCofThisEvent*value)
00116       { HC = value; }
00117       inline void SetDCofThisEvent(G4DCofThisEvent*value)
00118       { DC = value; }
00119       inline void SetTrajectoryContainer(G4TrajectoryContainer*value)
00120       { trajectoryContainer = value; }
00121       inline void SetEventAborted()
00122       { eventAborted = true; }
00123       inline void SetRandomNumberStatus(G4String& st)
00124       {
00125         randomNumberStatus = new G4String(st);
00126         validRandomNumberStatus = true;
00127       }
00128       inline void SetRandomNumberStatusForProcessing(G4String& st)
00129       {
00130         randomNumberStatusForProcessing = new G4String(st);
00131         validRandomNumberStatusForProcessing = true;
00132       }
00133       inline void KeepTheEvent(G4bool vl=true)
00134       { keepTheEvent = vl; }
00135       inline G4bool ToBeKept() const
00136       { return keepTheEvent; }
00137 
00138   public: // with description
00139       inline G4int GetEventID() const
00140       { return eventID; }
00141       //  Returns the event ID
00142       inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
00143       {
00144         if( thePrimaryVertex == 0 )
00145         { thePrimaryVertex = aPrimaryVertex; }
00146         else
00147         { thePrimaryVertex->SetNext( aPrimaryVertex ); }
00148         numberOfPrimaryVertex++;
00149       }
00150       //  This method sets a new primary vertex. This method must be invoked 
00151       // exclusively by G4VPrimaryGenerator concrete class.
00152       inline G4int GetNumberOfPrimaryVertex() const
00153       { return numberOfPrimaryVertex; }
00154       //  Returns number of primary vertexes the G4Event object has.
00155       inline G4PrimaryVertex* GetPrimaryVertex(G4int i=0)  const
00156       { 
00157         if( i == 0 )
00158         { return thePrimaryVertex; }
00159         else if( i > 0 && i < numberOfPrimaryVertex )
00160         {
00161           G4PrimaryVertex* primaryVertex = thePrimaryVertex;
00162           for( G4int j=0; j<i; j++ )
00163           {
00164             if( primaryVertex == 0 ) return 0; 
00165             primaryVertex = primaryVertex->GetNext();
00166           }
00167           return primaryVertex;
00168         }
00169         else
00170         { return 0; }
00171       }
00172       //  Returns i-th primary vertex of the event.
00173       inline G4HCofThisEvent* GetHCofThisEvent()  const
00174       { return HC; }
00175       inline G4DCofThisEvent* GetDCofThisEvent()  const
00176       { return DC; }
00177       inline G4TrajectoryContainer* GetTrajectoryContainer() const
00178       { return trajectoryContainer; }
00179       //  These three methods returns the pointers to the G4HCofThisEvent
00180       // (hits collections of this event), G4DCofThisEvent (digi collections
00181       // of this event), and G4TrajectoryContainer (trajectory coonainer),
00182       // respectively.
00183       inline G4bool IsAborted() const { return eventAborted; }
00184       //  Return a boolean which indicates the event has been aborted and thus
00185       // it should not be used for analysis.
00186       inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; }
00187       inline G4VUserEventInformation* GetUserInformation() const { return userInfo; }
00188       //  Set and Get method of G4VUserEventInformation
00189       inline const G4String& GetRandomNumberStatus() const 
00190       {
00191         if(!validRandomNumberStatus)
00192         { G4Exception(
00193               "G4Event::GetRandomNumberStatus","Event0701",JustWarning,
00194               "Random number status is not available for this event."); }
00195         return *randomNumberStatus;
00196       }
00197       inline const G4String& GetRandomNumberStatusForProcessing() const 
00198       {
00199         if(!validRandomNumberStatusForProcessing)
00200         { G4Exception(
00201               "G4Event::GetRandomNumberStatusForProcessing","Event0702",
00202               JustWarning,
00203               "Random number status is not available for this event."); }
00204         return *randomNumberStatusForProcessing;
00205       }
00206 };
00207 
00208 #if defined G4EVENT_ALLOC_EXPORT
00209   extern G4DLLEXPORT G4Allocator<G4Event> anEventAllocator;
00210 #else
00211   extern G4DLLIMPORT G4Allocator<G4Event> anEventAllocator;
00212 #endif
00213 
00214 inline void* G4Event::operator new(size_t)
00215 {
00216   void* anEvent;
00217   anEvent = (void*)anEventAllocator.MallocSingle();
00218   return anEvent;
00219 }
00220 
00221 inline void G4Event::operator delete(void* anEvent)
00222 {
00223   anEventAllocator.FreeSingle((G4Event*)anEvent);
00224 }
00225 
00226 #endif
00227 

Generated on Mon May 27 17:48:13 2013 for Geant4 by  doxygen 1.4.7