Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CascadeChannelTables.hh
Go to the documentation of this file.
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 // Factory class to return pointer to Bertini cross-section table based on
27 // collision initial state (hadron type codes).
28 //
29 // Author: Michael Kelsey (SLAC)
30 //
31 // 20110728 M. Kelsey -- Use static instance() function to work around
32 // "disappearance" bug on Linux (GCC 4.1.2).
33 // 20110915 M. Kelsey -- Move static implementations (won't work on Windows);
34 // Add local table instantiating function (to replace self-reg)
35 // 20110923 M. Kelsey -- Add optional stream& argument to printTable().
36 
37 #ifndef G4_CASCADE_CHANNEL_TABLES_HH
38 #define G4_CASCADE_CHANNEL_TABLES_HH
39 
40 #include "globals.hh"
41 #include <iosfwd>
42 #include <map>
43 
44 class G4CascadeChannel;
45 
46 
48 public:
49  // Argument is interaction code, product of G4InuclEP types
50  static const G4CascadeChannel* GetTable(G4int initialState);
51 
52  // Arguments are individual G4InuclElementaryParticle types
53  static const G4CascadeChannel* GetTable(G4int had1, G4int had2);
54 
55  // Convenience function for diagnostic output
56  static void PrintTable(G4int initialState, std::ostream& os=G4cout);
57 
58  // Register cross-section table for later lookup
59  static void AddTable(G4int initialState, G4CascadeChannel* table);
60 
61 private:
62  static G4CascadeChannelTables& instance(); // Singleton
63 
64  G4CascadeChannelTables() { tables.clear(); } // Must initialize map
65  ~G4CascadeChannelTables() {} // Tables are created externally, not owned
66 
67  // Fetch table from map if already registered, or return null
68  const G4CascadeChannel* FindTable(G4int initialState);
69 
70  // Save table for specified interaction in map
71  void SaveTable(G4int initialState, G4CascadeChannel* table);
72 
73  // Special function to create and store table for specified interaction
74  const G4CascadeChannel* LoadTable(G4int initialState);
75 
76  typedef std::map<G4int, G4CascadeChannel*> TableMap;
77  typedef std::pair<const G4int, G4CascadeChannel*> TableEntry;
78  TableMap tables;
79 
80  static void DeleteTable(TableEntry& t); // For use by destructor
81 };
82 
83 #endif /* G4_CASCADE_CHANNEL_TABLES_HH */