Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:23

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 //
0027 //
0028 
0029 #ifndef G4HCofThisEvent_h
0030 #define G4HCofThisEvent_h 1
0031 
0032 #include "G4Allocator.hh"
0033 #include "G4VHitsCollection.hh"
0034 #include "globals.hh"
0035 
0036 #include <vector>
0037 
0038 // class description:
0039 //
0040 //  This is a class which stores hits collections generated at one event.
0041 // This class is exclusively constructed by G4SDManager when the first
0042 // hits collection of an event is passed to the manager, and this class
0043 // object is deleted by G4RunManager when a G4Event class object is deleted.
0044 //  Almost all public methods must be used by Geant4 kernel classes and
0045 // the user should not invoke them. The user can use two const methods,
0046 // GetHC() and GetNumberOfCollections() for accessing to the stored hits
0047 // collection(s).
0048 
0049 class G4HCofThisEvent
0050 {
0051  public:
0052   G4HCofThisEvent();
0053   explicit G4HCofThisEvent(G4int cap);
0054   ~G4HCofThisEvent();
0055   G4HCofThisEvent(const G4HCofThisEvent&);
0056   G4HCofThisEvent& operator=(const G4HCofThisEvent&);
0057 
0058   inline void* operator new(size_t);
0059   inline void operator delete(void* anHCoTE);
0060 
0061   void AddHitsCollection(G4int HCID, G4VHitsCollection* aHC);
0062 
0063   //  Returns a pointer to a hits collection. Null will be returned
0064   // if the particular collection is not stored at the current event.
0065   // The integer argument is ID number which is assigned by G4SDManager
0066   // and the number can be obtained by G4SDManager::GetHitsCollectionID()
0067   // method.
0068   inline G4VHitsCollection* GetHC(G4int i) { return (*HC)[i]; }
0069 
0070   // Return number of hits collections which are stored in this class
0071   // object.
0072   inline G4int GetNumberOfCollections()
0073   {
0074     G4int n = 0;
0075     for (const G4VHitsCollection* h : *HC) {
0076       if (h != nullptr) n++;
0077     }
0078     return n;
0079   }
0080 
0081   inline size_t GetCapacity() { return HC->size(); }
0082 
0083  private:
0084   std::vector<G4VHitsCollection*>* HC;
0085 };
0086 
0087 #if defined G4DIGI_ALLOC_EXPORT
0088 extern G4DLLEXPORT G4Allocator<G4HCofThisEvent>*& anHCoTHAllocator_G4MT_TLS_();
0089 #else
0090 extern G4DLLIMPORT G4Allocator<G4HCofThisEvent>*& anHCoTHAllocator_G4MT_TLS_();
0091 #endif
0092 
0093 inline void* G4HCofThisEvent::operator new(size_t)
0094 {
0095   if (anHCoTHAllocator_G4MT_TLS_() == nullptr) {
0096     anHCoTHAllocator_G4MT_TLS_() = new G4Allocator<G4HCofThisEvent>;
0097   }
0098   return (void*)anHCoTHAllocator_G4MT_TLS_()->MallocSingle();
0099 }
0100 
0101 inline void G4HCofThisEvent::operator delete(void* anHCoTH)
0102 {
0103   anHCoTHAllocator_G4MT_TLS_()->FreeSingle((G4HCofThisEvent*)anHCoTH);
0104 }
0105 
0106 #endif