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

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