Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:13

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 // G4TrajectoryContainer
0027 //
0028 // Class description:
0029 //
0030 // This is a container of G4VTrajectory objects and the object of this
0031 // container will be associated to G4Event object.
0032 
0033 // Author: Makoto Asai (SLAC)
0034 // --------------------------------------------------------------------
0035 #ifndef G4TrajectoryContainer_hh
0036 #define G4TrajectoryContainer_hh 1
0037 
0038 #include <vector>
0039 
0040 #include "globals.hh"
0041 #include "evtdefs.hh"
0042 #include "G4VTrajectory.hh"
0043 #include "G4Allocator.hh"
0044 
0045 using TrajectoryVector = std::vector<G4VTrajectory*>;
0046 
0047 class G4TrajectoryContainer
0048 {
0049   public:
0050 
0051     G4TrajectoryContainer();
0052     ~G4TrajectoryContainer();
0053 
0054     G4TrajectoryContainer(const G4TrajectoryContainer&) = delete;
0055     G4TrajectoryContainer& operator=(const G4TrajectoryContainer&) = delete;
0056 
0057     inline void *operator new(std::size_t);
0058     inline void operator delete(void* anEvent);
0059 
0060     G4bool operator==(const G4TrajectoryContainer& right) const;
0061     G4bool operator!=(const G4TrajectoryContainer& right) const;
0062 
0063     inline std::size_t size() const { return vect->size(); }
0064     inline void push_back(G4VTrajectory* p) { vect->push_back(p); }
0065     inline std::size_t entries() const { return size(); }
0066     inline G4bool insert(G4VTrajectory* p) { push_back(p); return true; }
0067     inline void clearAndDestroy()
0068     {
0069       for(std::size_t i=0; i<size(); ++i) delete (*vect)[i];
0070       vect->clear();
0071     }
0072     inline G4VTrajectory* operator[](std::size_t n) { return (*vect)[n]; }
0073     inline TrajectoryVector* GetVector() const { return vect; }
0074 
0075   private:
0076 
0077     TrajectoryVector* vect = nullptr;
0078 };
0079 
0080 extern G4EVENT_DLL
0081 G4Allocator<G4TrajectoryContainer>*& aTrajectoryContainerAllocator();
0082 
0083 inline void* G4TrajectoryContainer::operator new(std::size_t)
0084 {
0085   if (aTrajectoryContainerAllocator() == nullptr)
0086   {
0087     aTrajectoryContainerAllocator() = new G4Allocator<G4TrajectoryContainer>;
0088   }
0089   return (void*)aTrajectoryContainerAllocator()->MallocSingle();
0090 }
0091 
0092 inline void G4TrajectoryContainer::operator delete(void* aTrajectoryContainer)
0093 {
0094   aTrajectoryContainerAllocator()
0095    ->FreeSingle((G4TrajectoryContainer*)aTrajectoryContainer);
0096 }
0097 
0098 #endif