Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:13:38

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 // G4FieldManagerStore
0027 //
0028 // Class description:
0029 //
0030 // Container for all FieldManagers, with functionality derived
0031 // from std::vector<T>. The class is a 'singleton', in that only
0032 // one can exist, and access is provided via the static function
0033 // G4FieldManagerStore::GetInstance().
0034 //
0035 // All FieldManagers should be registered with G4FieldManagerStore,
0036 // and removed on their destruction. 
0037 // Intended principally to enable resetting of 'state' at start of event.
0038 // The underlying container initially has a capacity of 100.
0039 
0040 // Author: John Apostolakis (CERN), 07.12.2007 - Initial version
0041 // --------------------------------------------------------------------
0042 #ifndef G4FIELDMANAGERSTORE_HH
0043 #define G4FIELDMANAGERSTORE_HH
0044 
0045 #include <vector>
0046 
0047 #include "G4FieldManager.hh"
0048 
0049 /**
0050  * @brief G4FieldManagerStore is a container for all field managers, with
0051  * functionality derived from std::vector<T>. The class is a singleton.
0052  * All field managers should be registered with G4FieldManagerStore,
0053  * and removed on their destruction. Intended principally to enable resetting
0054  * of 'state' at start of an event.
0055  */
0056 
0057 class G4FieldManagerStore : public std::vector<G4FieldManager*>
0058 {
0059   public:
0060 
0061     /**
0062      * Gets a pointer to the unique G4FieldManagerStore, creating it if
0063      * necessary.
0064      */
0065     static G4FieldManagerStore* GetInstance();
0066     static G4FieldManagerStore* GetInstanceIfExist();
0067 
0068     /**
0069      * Adds the field manager to the collection.
0070      */
0071     static void Register(G4FieldManager* pFieldMan);
0072 
0073     /**
0074      * Removes the field manager from the collection.
0075      */
0076     static void DeRegister(G4FieldManager* pFieldMan);
0077 
0078     /**
0079      * Deletes all managers from the store.
0080      */
0081     static void Clean();
0082 
0083     /**
0084      * Loops over all field managers and calls each one to reset step estimate.
0085      */
0086     void ClearAllChordFindersState();
0087 
0088     /**
0089      * Destructor: takes care to delete the allocated field managers.
0090      */
0091     ~G4FieldManagerStore();
0092 
0093   private:
0094   
0095     /**
0096      * Private constructor.
0097      */
0098     G4FieldManagerStore();
0099 
0100   private:
0101 
0102     static G4ThreadLocal G4FieldManagerStore* fgInstance;
0103     static G4ThreadLocal G4bool locked;
0104 };
0105 
0106 #endif