Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // G4PhysListRegistry 27 // 28 // Class Description 29 // 30 // This is a singleton keeping pointers to all physics lists. 31 // Based on G4PhysicsConstructorRegistry. 32 // 33 // Author: R. Hatcher, 2014-10-15 34 // -------------------------------------------------------------------- 35 #ifndef G4PhysListRegistry_hh 36 #define G4PhysListRegistry_hh 1 37 38 #include <vector> 39 #include <map> 40 41 #include "globals.hh" 42 43 class G4VModularPhysicsList; 44 class G4VBasePhysListStamper; 45 46 class G4PhysListRegistry 47 { 48 public: 49 50 static G4PhysListRegistry* Instance(); 51 // access 52 53 ~G4PhysListRegistry(); 54 55 void AddFactory(G4String name, G4VBasePhysListStamper*); 56 void AddPhysicsExtension(G4String name, G4String procname); 57 // mapping from extension name to actual physics contructor process name 58 59 G4VModularPhysicsList* GetModularPhysicsList(const G4String& name); 60 G4VModularPhysicsList* GetModularPhysicsListFromEnv(); 61 62 G4bool IsReferencePhysList(G4String nam) const; 63 64 const std::vector<G4String>& AvailablePhysLists() const; 65 const std::vector<G4String>& AvailablePhysicsExtensions() const; 66 const std::vector<G4String>& AvailablePhysListsEM() const; 67 68 void PrintAvailablePhysLists() const; 69 70 G4bool DeconstructPhysListName(const G4String& name, G4String& plBase, 71 std::vector<G4String>& physExt, 72 std::vector<G4int>& replace, 73 G4int verbose=0) const; 74 75 G4bool FindLongestMatch(const G4String& workName, 76 const G4String& searchName, 77 const std::vector<G4String>& validNames, 78 G4String& bestMatch, 79 G4int verbose=0) const; 80 81 inline void SetVerbose(G4int val) { verbose = val; } 82 inline G4int GetVerbose() const { return verbose; } 83 84 inline void SetUnknownFatal(G4int val) { unknownFatal = val; } 85 inline G4int GetUnknownFatal() const { return unknownFatal; } 86 87 void SetUserDefaultPhysList(const G4String& name=""); 88 inline G4String GetUserDefaultPhysList() const { return userDefault; } 89 // set a prefered list in case where $PHYSLIST isn't defined 90 // if not set (or called with "") this falls back to system default 91 92 inline G4String GetSystemDefaultPhysList() const { return systemDefault; } 93 94 private: 95 96 G4PhysListRegistry(); 97 98 static G4ThreadLocal G4PhysListRegistry* theInstance; 99 100 std::map <G4String, G4VBasePhysListStamper*> factories; 101 std::map <G4String, G4String> physicsExtensions; 102 103 G4int verbose; 104 G4int unknownFatal; /// throw an exception if unsatisfiable? 105 G4String userDefault; /// use this if $PHYSLIST isn't set 106 G4String systemDefault; /// use this if user hasn't set userDefault 107 /// or attempts to set the userDefault="" 108 109 // Make these mutable and update them on each request because the map might 110 // have been updated by the addition of new entries 111 // The only reason to have them at all is that that original interface 112 // returned a const reference and so we can't pass back a local object 113 // created upon the call of the method 114 mutable std::vector<G4String> availBasePhysLists; 115 mutable std::vector<G4String> availExtensions; 116 }; 117 118 #endif 119