00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // Factory class to return pointer to Bertini cross-section table based on 00027 // collision initial state (hadron type codes). 00028 // 00029 // Author: Michael Kelsey (SLAC) 00030 // 00031 // 20110728 M. Kelsey -- Use static instance() function to work around 00032 // "disappearance" bug on Linux (GCC 4.1.2). 00033 // 20110915 M. Kelsey -- Move static implementations (won't work on Windows); 00034 // Add local table instantiating function (to replace self-reg) 00035 // 20110923 M. Kelsey -- Add optional stream& argument to printTable(). 00036 00037 #ifndef G4_CASCADE_CHANNEL_TABLES_HH 00038 #define G4_CASCADE_CHANNEL_TABLES_HH 00039 00040 #include "globals.hh" 00041 #include <iosfwd> 00042 #include <map> 00043 00044 class G4CascadeChannel; 00045 00046 00047 class G4CascadeChannelTables { 00048 public: 00049 // Argument is interaction code, product of G4InuclEP types 00050 static const G4CascadeChannel* GetTable(G4int initialState); 00051 00052 // Arguments are individual G4InuclElementaryParticle types 00053 static const G4CascadeChannel* GetTable(G4int had1, G4int had2); 00054 00055 // Convenience function for diagnostic output 00056 static void PrintTable(G4int initialState, std::ostream& os=G4cout); 00057 00058 // Register cross-section table for later lookup 00059 static void AddTable(G4int initialState, G4CascadeChannel* table); 00060 00061 private: 00062 static G4CascadeChannelTables& instance(); // Singleton 00063 00064 G4CascadeChannelTables() { tables.clear(); } // Must initialize map 00065 ~G4CascadeChannelTables() {} // Tables are created externally, not owned 00066 00067 // Fetch table from map if already registered, or return null 00068 const G4CascadeChannel* FindTable(G4int initialState); 00069 00070 // Save table for specified interaction in map 00071 void SaveTable(G4int initialState, G4CascadeChannel* table); 00072 00073 // Special function to create and store table for specified interaction 00074 const G4CascadeChannel* LoadTable(G4int initialState); 00075 00076 typedef std::map<G4int, G4CascadeChannel*> TableMap; 00077 typedef std::pair<const G4int, G4CascadeChannel*> TableEntry; 00078 TableMap tables; 00079 00080 static void DeleteTable(TableEntry& t); // For use by destructor 00081 }; 00082 00083 #endif /* G4_CASCADE_CHANNEL_TABLES_HH */