Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4ParticlesWorkspace
0027 //
0028 // Class description:
0029 //
0030 // Class managing the per-thread state of particles, those which
0031 // have a per-thread state and dependent classes (if any).
0032 // In particular, it owns the arrays that implement 'split' classes
0033 // and classes/objects which are owned by the split classes.
0034 // The classes/objects affected are
0035 //   - 'split' classes part of its state is per-thread,
0036 //   - per-thread objects, in particular those which are owned
0037 //     by the split classes.
0038 // Goal: Take ownership and control of per-thread state of classes
0039 //       to work with multi-threading.
0040 
0041 // Authors: J.Apostolakis & A.Dotti, 4 October 2013
0042 // --------------------------------------------------------------------
0043 #ifndef G4PARTICLESWORKSPACE_HH
0044 #define G4PARTICLESWORKSPACE_HH
0045 
0046 #include "G4ParticleDefinition.hh"
0047 #include "G4TWorkspacePool.hh"
0048 
0049 class G4ParticlesWorkspace
0050 {
0051   public:
0052     using pool_type = G4TWorkspacePool<G4ParticlesWorkspace>;
0053 
0054     G4ParticlesWorkspace(G4bool verbose = false);
0055     ~G4ParticlesWorkspace() = default;
0056 
0057     // Take ownership
0058     void UseWorkspace();
0059 
0060     // Release ownership
0061     void ReleaseWorkspace();
0062 
0063     // Release ownership and destroy
0064     void DestroyWorkspace();
0065 
0066     // To be called at start of each run (especially 2nd and further runs)
0067     void InitialiseWorkspace();
0068 
0069     void SetVerbose(G4bool v) { fVerbose = v; }
0070     G4bool GetVerbose() { return fVerbose; }
0071 
0072     static pool_type* GetPool();
0073 
0074   protected:  // Implementation methods
0075     void InitialiseParticles();
0076 
0077   private:
0078     // Helper pointer - can be per instance or shared
0079     G4PDefManager* fpPDefSIM = nullptr;
0080 
0081     // Per Instance variables
0082     // NOTE: the ownership of the Data Arrays is IN this object
0083 
0084     // Store SubInstanceManager object pointers (SIM pointers)
0085     G4PDefData* fpPDefOffset = nullptr;
0086 
0087     G4bool fVerbose = false;
0088 };
0089 
0090 #endif