Geant4 Cross Reference |
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 // G4Run 27 // 28 // Class description: 29 // 30 // This class represents a run. An object of this class is constructed 31 // and deleted by G4RunManager. Basically the user should use only the 32 // accessors (get methods). All properties are set by G4RunManager. 33 34 // Author: M.Asai, 1996 35 // -------------------------------------------------------------------- 36 #ifndef G4Run_hh 37 #define G4Run_hh 1 38 39 #include "globals.hh" 40 41 #include <vector> 42 43 class G4Event; 44 class G4HCtable; 45 class G4DCtable; 46 47 class G4Run 48 { 49 public: 50 G4Run(); 51 virtual ~G4Run(); 52 G4Run(const G4Run&) = delete; 53 G4Run& operator=(const G4Run&) = delete; 54 55 // Method to be overwritten by the user for recording events in this run. 56 // In such a case, it is the user's responsibility to increment 57 // numberOfEvent. Also, user's run class object must be instantiated in 58 // user's runAction. 59 virtual void RecordEvent(const G4Event*); 60 61 // Method to be overwritten by the user for merging local G4Run object 62 // to the global G4Run object. 63 virtual void Merge(const G4Run*); 64 65 // Method to be overwritten by the user for merging sub-event results 66 // (e.g. hits) into the master G4Event. 67 // [N.B.] Trajectories are merged in the base-class method. So, the user 68 // should invoke the base-class method at the end of his/her overwriting 69 // method. 70 virtual void MergeSubEvent(G4Event* masterEv, const G4Event* subEv); 71 72 // Store a G4Event object until this run object is deleted. 73 // Given the potential large memory size of G4Event and its data-member 74 // objects stored in G4Event, the user must be careful and responsible 75 // for not storing too many G4Event objects. This method is invoked by 76 // G4RunManager if the user invokes G4EventManager::KeepTheCurrentEvent() 77 // or "/event/keepCurrentEvent" UI command while the particular event is 78 // in being processed (typically in EndOfEventAction). 79 void StoreEvent(G4Event* evt); 80 81 // Returns the run ID. Run ID is set by G4RunManager. 82 inline G4int GetRunID() const { return runID; } 83 84 // Returns number of events processed in this run. The number is 85 // incremented at the end of each event processing. 86 inline G4int GetNumberOfEvent() const { return numberOfEvent; } 87 88 inline G4int GetNumberOfEventToBeProcessed() const { return numberOfEventToBeProcessed; } 89 90 // Returns hits collection. 91 inline const G4HCtable* GetHCtable() const { return HCtable; } 92 93 // Returns digi collection. 94 inline const G4DCtable* GetDCtable() const { return DCtable; } 95 96 // Returns random number status at the beginning of this run. 97 inline const G4String& GetRandomNumberStatus() const { return randomNumberStatus; } 98 99 // Returns the event vector and related numbers. 100 inline std::vector<const G4Event*>* GetEventVector() const { return eventVector; } 101 inline G4int GetEventVectorSize() const 102 { return (eventVector!=nullptr) ? (G4int)(eventVector->size()) : 0; } 103 G4int GetNumberOfKeptEvents() const; 104 105 inline void SetRunID(G4int id) { runID = id; } 106 inline void SetNumberOfEventToBeProcessed(G4int n_ev) { numberOfEventToBeProcessed = n_ev; } 107 inline void SetHCtable(G4HCtable* HCtbl) { HCtable = HCtbl; } 108 inline void SetDCtable(G4DCtable* DCtbl) { DCtable = DCtbl; } 109 inline void SetRandomNumberStatus(G4String& st) { randomNumberStatus = st; } 110 111 protected: 112 G4int runID = 0; 113 G4int numberOfEvent = 0; 114 G4int numberOfEventToBeProcessed = 0; 115 G4HCtable* HCtable = nullptr; 116 G4DCtable* DCtable = nullptr; 117 G4String randomNumberStatus = ""; 118 std::vector<const G4Event*>* eventVector = nullptr; 119 }; 120 121 #endif 122