Back to home page

EIC code displayed by LXR

 
 

    


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

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 G4DCofThisEvent_h
0030 #define G4DCofThisEvent_h 1
0031 
0032 #include "G4Allocator.hh"
0033 #include "G4VDigiCollection.hh"
0034 #include "globals.hh"
0035 
0036 #include <vector>
0037 
0038 // class description:
0039 //
0040 //  This is a class which stores digi collections generated at one event.
0041 // This class is exclusively constructed by G4DigiManager when the first
0042 // digi 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 // GetDC() and GetNumberOfCollections() for accessing to the stored digi
0047 // collection(s).
0048 
0049 class G4DCofThisEvent
0050 {
0051  public:
0052   G4DCofThisEvent();
0053   explicit G4DCofThisEvent(G4int cap);
0054   ~G4DCofThisEvent();
0055   G4DCofThisEvent(const G4DCofThisEvent&);
0056   G4DCofThisEvent& operator=(const G4DCofThisEvent&);
0057 
0058   inline void* operator new(size_t);
0059   inline void operator delete(void* anDCoTE);
0060 
0061   void AddDigiCollection(G4int DCID, G4VDigiCollection* aDC);
0062 
0063   //  Returns a pointer to a digi collection.
0064   // Returns `nullptr` if the particular collection is not stored in the current event.
0065   // The integer argument is ID number which is assigned by G4DigiManager
0066   // and the number can be obtained by G4DigiManager::GetDigiCollectionID()
0067   // method.
0068   inline G4VDigiCollection* GetDC(G4int i) const { return (*DC)[i]; }
0069 
0070   // Return number of digi collections stored
0071   inline G4int GetNumberOfCollections() const
0072   {
0073     G4int n = 0;
0074     for (const G4VDigiCollection* dc : *DC) {
0075       if (dc != nullptr) n++;
0076     }
0077     return n;
0078   }
0079 
0080   inline size_t GetCapacity() const { return DC->size(); }
0081 
0082  private:
0083   std::vector<G4VDigiCollection*>* DC;
0084 };
0085 
0086 #if defined G4DIGI_ALLOC_EXPORT
0087 extern G4DLLEXPORT G4Allocator<G4DCofThisEvent>*& anDCoTHAllocator_G4MT_TLS_();
0088 #else
0089 extern G4DLLIMPORT G4Allocator<G4DCofThisEvent>*& anDCoTHAllocator_G4MT_TLS_();
0090 #endif
0091 
0092 inline void* G4DCofThisEvent::operator new(size_t)
0093 {
0094   if (anDCoTHAllocator_G4MT_TLS_() == nullptr) {
0095     anDCoTHAllocator_G4MT_TLS_() = new G4Allocator<G4DCofThisEvent>;
0096   }
0097   return (void*)anDCoTHAllocator_G4MT_TLS_()->MallocSingle();
0098 }
0099 
0100 inline void G4DCofThisEvent::operator delete(void* anDCoTH)
0101 {
0102   anDCoTHAllocator_G4MT_TLS_()->FreeSingle((G4DCofThisEvent*)anDCoTH);
0103 }
0104 
0105 #endif