![]() |
|
|||
File indexing completed on 2025-09-17 08:58:35
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4HCofThisEvent 0027 // 0028 // Class description: 0029 // 0030 // This is a class which stores hits collections generated at one event. 0031 // This class is exclusively constructed by G4SDManager when the first 0032 // hits collection of an event is passed to the manager, and this class 0033 // object is deleted by G4RunManager when a G4Event class object is deleted. 0034 // Almost all public methods must be used by Geant4 kernel classes and 0035 // the user should not invoke them. The user can use two const methods, 0036 // GetHC() and GetNumberOfCollections() for accessing to the stored hits 0037 // collection(s). 0038 // 0039 // Author: Makoto Asai 0040 // -------------------------------------------------------------------- 0041 #ifndef G4HCofThisEvent_h 0042 #define G4HCofThisEvent_h 1 0043 0044 #include "G4Allocator.hh" 0045 #include "G4VHitsCollection.hh" 0046 #include "globals.hh" 0047 0048 #include <vector> 0049 0050 class G4HCofThisEvent 0051 { 0052 public: 0053 0054 G4HCofThisEvent(); 0055 explicit G4HCofThisEvent(G4int cap); 0056 ~G4HCofThisEvent(); 0057 G4HCofThisEvent(const G4HCofThisEvent&); 0058 G4HCofThisEvent& operator=(const G4HCofThisEvent&); 0059 0060 inline void* operator new(std::size_t); 0061 inline void operator delete(void* anHCoTE); 0062 0063 void AddHitsCollection(G4int HCID, G4VHitsCollection* aHC); 0064 0065 // Returns a pointer to a hits collection. Null will be returned 0066 // if the particular collection is not stored at the current event. 0067 // The integer argument is ID number which is assigned by G4SDManager 0068 // and the number can be obtained by G4SDManager::GetHitsCollectionID() 0069 // method. 0070 inline G4VHitsCollection* GetHC(G4int i) { return (*HC)[i]; } 0071 0072 // Return number of hits collections which are stored in this class 0073 // object. 0074 inline G4int GetNumberOfCollections() 0075 { 0076 G4int n = 0; 0077 for (const G4VHitsCollection* h : *HC) { 0078 if (h != nullptr) ++n; 0079 } 0080 return n; 0081 } 0082 0083 inline std::size_t GetCapacity() { return HC->size(); } 0084 0085 private: 0086 0087 std::vector<G4VHitsCollection*>* HC; 0088 }; 0089 0090 #if defined G4DIGI_ALLOC_EXPORT 0091 extern G4DLLEXPORT G4Allocator<G4HCofThisEvent>*& anHCoTHAllocator_G4MT_TLS_(); 0092 #else 0093 extern G4DLLIMPORT G4Allocator<G4HCofThisEvent>*& anHCoTHAllocator_G4MT_TLS_(); 0094 #endif 0095 0096 inline void* G4HCofThisEvent::operator new(std::size_t) 0097 { 0098 if (anHCoTHAllocator_G4MT_TLS_() == nullptr) { 0099 anHCoTHAllocator_G4MT_TLS_() = new G4Allocator<G4HCofThisEvent>; 0100 } 0101 return (void*)anHCoTHAllocator_G4MT_TLS_()->MallocSingle(); 0102 } 0103 0104 inline void G4HCofThisEvent::operator delete(void* anHCoTH) 0105 { 0106 anHCoTHAllocator_G4MT_TLS_()->FreeSingle((G4HCofThisEvent*)anHCoTH); 0107 } 0108 0109 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |