Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4PhysicsTable
0027 //
0028 // Class description:
0029 //
0030 // G4PhysicsTable is an utility class for storage of pointers
0031 // to G4PhysicsVector containers. It derives all functionalities
0032 // of STL vector containers with the addition of few methods for
0033 // compatibility with previous implementation based on Rogue-Wave
0034 // pointer collections.
0035 // The constructor given the 'capacity' of the table, pre-allocates
0036 // memory for the specified value by invoking the STL's reserve()
0037 // function, in order to avoid reallocation during insertions.
0038 // G4PhysicsTable has a vector of Boolean which are used
0039 // as 'recalc-needed' flags when processes calculate physics tables.
0040 
0041 // Author: G.Cosmo, 2 December 1995
0042 //         First implementation based on object model
0043 // Revisions:
0044 // - 1st March 1996, K.Amako: modified
0045 // - 24th February 2001, H.Kurashige: migration to STL vectors
0046 // --------------------------------------------------------------------
0047 #ifndef G4PhysicsTable_hh
0048 #define G4PhysicsTable_hh 1
0049 
0050 #include "G4PhysicsVector.hh"
0051 #include "G4ios.hh"
0052 #include "globals.hh"
0053 #include <vector>
0054 
0055 class G4PhysicsTable : public std::vector<G4PhysicsVector*>
0056 {
0057   using G4PhysCollection = std::vector<G4PhysicsVector*>;
0058   using G4FlagCollection = std::vector<G4bool>;
0059 
0060  public:
0061   G4PhysicsTable() = default;
0062   // Default constructor
0063 
0064   explicit G4PhysicsTable(size_t cap);
0065   // Constructor with capacity. Reserves memory for the specified capacity
0066 
0067   virtual ~G4PhysicsTable();
0068   // Destructor. Does not invoke deletion of contained pointed collections
0069 
0070   G4PhysicsTable(const G4PhysicsTable&) = delete;
0071   G4PhysicsTable& operator=(const G4PhysicsTable&) = delete;
0072 
0073   G4PhysicsVector*& operator()(std::size_t);
0074   G4PhysicsVector* const& operator()(std::size_t) const;
0075   // Access operators
0076 
0077   void clearAndDestroy();
0078   // Removes all items and deletes them at the same time
0079 
0080   void push_back(G4PhysicsVector*);
0081   void insert(G4PhysicsVector*);
0082   // Pushes new element to collection
0083 
0084   void insertAt(std::size_t, G4PhysicsVector*);
0085   // Insert element at the specified position in the collection
0086 
0087   void resize(std::size_t, G4PhysicsVector* vec = nullptr);
0088   // Resize collection
0089 
0090   std::size_t entries() const;
0091   std::size_t length() const;
0092   // Return collection's size
0093 
0094   G4bool isEmpty() const;
0095   // Flags if collection is empty or not
0096 
0097   G4bool ExistPhysicsTable(const G4String& fileName) const;
0098   // Check if the specified file exists or not
0099 
0100   G4bool StorePhysicsTable(const G4String& filename, G4bool ascii = false);
0101   // Stores PhysicsTable in a file (returns false in case of failure)
0102 
0103   G4bool RetrievePhysicsTable(const G4String& filename, G4bool ascii = false, G4bool spline = false);
0104   // Retrieves Physics from a file (returns false in case of failure)
0105 
0106   void ResetFlagArray();
0107   // Reset the array of flags and all flags are set "true".
0108   // This flag is supposed to be used as "recalc-needed" flag
0109   // associated with each physics vector
0110 
0111   G4bool GetFlag(std::size_t i) const;
0112   void ClearFlag(std::size_t i);
0113   // Get/Clear the flag for the 'i-th' physics vector
0114 
0115   friend std::ostream& operator<<(std::ostream& out, G4PhysicsTable& table);
0116 
0117  protected:
0118   G4PhysicsVector* CreatePhysicsVector(G4int type, G4bool spline);
0119   G4FlagCollection vecFlag;
0120 };
0121 
0122 #include "G4PhysicsTable.icc"
0123 
0124 #endif