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 G4DCofThisEvent_h 00031 #define G4DCofThisEvent_h 1 00032 00033 #include "globals.hh" 00034 #include "G4Allocator.hh" 00035 #include "G4VDigiCollection.hh" 00036 //#include "g4rw/tpordvec.h" 00037 #include <vector> 00038 00039 // class description: 00040 // 00041 // This is a class which stores digi collections generated at one event. 00042 // This class is exclusively constructed by G4DigiManager when the first 00043 // digi collection of an event is passed to the manager, and this class 00044 // object is deleted by G4RunManager when a G4Event class object is deleted. 00045 // Almost all public methods must be used by Geant4 kernel classes and 00046 // the user should not invoke them. The user can use two const methods, 00047 // GetDC() and GetNumberOfCollections() for accessing to the stored digi 00048 // collection(s). 00049 00050 class G4DCofThisEvent 00051 { 00052 public: 00053 G4DCofThisEvent(); 00054 G4DCofThisEvent(G4int cap); 00055 ~G4DCofThisEvent(); 00056 inline void *operator new(size_t); 00057 inline void operator delete(void* anDCoTE); 00058 00059 void AddDigiCollection(G4int DCID,G4VDigiCollection * aDC); 00060 00061 private: 00062 std::vector<G4VDigiCollection*> * DC; 00063 00064 public: // with description 00065 inline G4VDigiCollection* GetDC(G4int i) const 00066 { return (*DC)[i]; } 00067 // Returns a pointer to a digi collection. Null will be returned 00068 // if the particular collection is not stored at the current event. 00069 // The integer argument is ID number which is assigned by G4DigiManager 00070 // and the number can be obtained by G4DigiManager::GetDigiCollectionID() 00071 // method. 00072 inline G4int GetNumberOfCollections() const 00073 { 00074 G4int n = 0; 00075 for(size_t i=0;i<DC->size();i++) 00076 { 00077 if((*DC)[i]) n++; 00078 } 00079 return n; 00080 } 00081 // Returns the number of digi collections which are stored in this class 00082 // object. 00083 public: 00084 inline G4int GetCapacity() const 00085 { 00086 return DC->size(); 00087 } 00088 }; 00089 00090 #if defined G4DIGI_ALLOC_EXPORT 00091 extern G4DLLEXPORT G4Allocator<G4DCofThisEvent> anDCoTHAllocator; 00092 #else 00093 extern G4DLLIMPORT G4Allocator<G4DCofThisEvent> anDCoTHAllocator; 00094 #endif 00095 00096 inline void* G4DCofThisEvent::operator new(size_t) 00097 { 00098 void* anDCoTH; 00099 anDCoTH = (void*)anDCoTHAllocator.MallocSingle(); 00100 return anDCoTH; 00101 } 00102 00103 inline void G4DCofThisEvent::operator delete(void* anDCoTH) 00104 { 00105 anDCoTHAllocator.FreeSingle((G4DCofThisEvent*)anDCoTH); 00106 } 00107 00108 #endif 00109