Geant4  10.00.p02
G4CascadeChannelTables.cc
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 // $Id: G4CascadeChannelTables.cc 69632 2013-05-09 01:17:48Z dwright $
27 //
28 // Factory to return pointer to Bertini cross-section table based on
29 // collision initial state (hadron type codes).
30 //
31 // Author: Michael Kelsey (SLAC)
32 //
33 // 20110729 M. Kelsey -- Use static instance() function to work around
34 // "disappearance" bug on Linux (GCC 4.1.2). Add diagnostics.
35 // 20110916 M. Kelsey -- Add "load on demand" to GetTable(), with full set
36 // of channel .hh files for use with LoadTable().
37 // 20110923 M. Kelsey -- Add optional stream& argument to printTable(),
38 // pass through.
39 // 20111007 M. Kelsey -- Add new gamma-n and gamma-p tables.
40 // 20130129 M. Kelsey -- Drop load-on-demand interfaces, fill in ctor
41 // 20130429 M. Kelsey -- Change instance to thread-local pointer.
42 
44 #include "G4CascadeChannel.hh"
45 #include "G4CascadeGamNChannel.hh"
46 #include "G4CascadeGamPChannel.hh"
57 #include "G4CascadeNNChannel.hh"
58 #include "G4CascadeNPChannel.hh"
59 #include "G4CascadePPChannel.hh"
79 #include "G4InuclParticleNames.hh"
80 #include <iostream>
81 #include <map>
82 using namespace G4InuclParticleNames;
83 
84 
85 // Singleton is created at first invocation
86 
88 
90  if (!theInstance) theInstance = new G4CascadeChannelTables;
91  return *theInstance;
92 }
93 
94 
95 // Constructor and destructor fully populate tables
96 
98  tables.clear();
99  tables[gam*neu] = new G4CascadeGamNChannel;
100  tables[gam*pro] = new G4CascadeGamPChannel;
101  tables[k0*neu] = new G4CascadeKzeroNChannel;
102  tables[k0*pro] = new G4CascadeKzeroPChannel;
103  tables[k0b*neu] = new G4CascadeKzeroBarNChannel;
104  tables[k0b*pro] = new G4CascadeKzeroBarPChannel;
105  tables[kmi*neu] = new G4CascadeKminusNChannel;
106  tables[kmi*pro] = new G4CascadeKminusPChannel;
107  tables[kpl*neu] = new G4CascadeKplusNChannel;
108  tables[kpl*pro] = new G4CascadeKplusPChannel;
109  tables[lam*neu] = new G4CascadeLambdaNChannel;
110  tables[lam*pro] = new G4CascadeLambdaPChannel;
111  tables[neu*neu] = new G4CascadeNNChannel;
112  tables[neu*pro] = new G4CascadeNPChannel;
113  tables[pi0*neu] = new G4CascadePiZeroNChannel;
114  tables[pi0*pro] = new G4CascadePiZeroPChannel;
115  tables[pim*neu] = new G4CascadePiMinusNChannel;
116  tables[pim*pro] = new G4CascadePiMinusPChannel;
117  tables[pip*neu] = new G4CascadePiPlusNChannel;
118  tables[pip*pro] = new G4CascadePiPlusPChannel;
119  tables[pro*pro] = new G4CascadePPChannel;
120  tables[s0*neu] = new G4CascadeSigmaZeroNChannel;
121  tables[s0*pro] = new G4CascadeSigmaZeroPChannel;
122  tables[sm*neu] = new G4CascadeSigmaMinusNChannel;
123  tables[sm*pro] = new G4CascadeSigmaMinusPChannel;
124  tables[sp*neu] = new G4CascadeSigmaPlusNChannel;
125  tables[sp*pro] = new G4CascadeSigmaPlusPChannel;
126  tables[xi0*neu] = new G4CascadeXiZeroNChannel;
127  tables[xi0*pro] = new G4CascadeXiZeroPChannel;
128  tables[xim*neu] = new G4CascadeXiMinusNChannel;
129  tables[xim*pro] = new G4CascadeXiMinusPChannel;
130  tables[om*neu] = new G4CascadeOmegaMinusNChannel;
131  tables[om*pro] = new G4CascadeOmegaMinusPChannel;
132  tables[mum*pro] = new G4CascadeMuMinusPChannel;
133 }
134 
136  TableMap::iterator entry;
137  for (entry = tables.begin(); entry != tables.end(); ++entry) {
138  delete entry->second; entry->second = 0;
139  }
140 
141  tables.clear();
142 }
143 
144 
145 // Argument is interaction code, product of G4InuclEP types
146 
148  return instance().FindTable(initialState);
149 }
150 
151 // Arguments are individual G4InuclElementaryParticle types
152 
153 const G4CascadeChannel*
155  return GetTable(had1*had2);
156 }
157 
158 // Return cross-section table requested by user
159 
160 const G4CascadeChannel*
162 #ifdef G4CASCADE_DEBUG_SAMPLER
163  G4cout << "G4CascadeChannelTables::FindTable " << initialState << G4endl;
164 #endif
165  TableMap::const_iterator entry = tables.find(initialState);
166  return (entry != tables.end()) ? entry->second : 0;
167 }
168 
169 
170 // Convenience functions for diagnostic output
171 
172 void G4CascadeChannelTables::Print(std::ostream& os) {
173  const TableMap& theTables = instance().tables; // For convenience
174  TableMap::const_iterator entry;
175  for (entry = theTables.begin(); entry != theTables.end(); ++entry) {
176  if (entry->second) entry->second->printTable(os);
177  }
178 }
179 
180 void G4CascadeChannelTables::PrintTable(G4int initialState, std::ostream& os) {
181  const G4CascadeChannel* tbl = GetTable(initialState);
182  if (tbl) tbl->printTable(os);
183 }
static const G4CascadeChannel * GetTable(G4int initialState)
G4CascadeFunctions< G4CascadePiPlusNChannelData, G4PionNucSampler > G4CascadePiPlusNChannel
G4CascadeFunctions< G4CascadeXiZeroNChannelData, G4KaonHypSampler > G4CascadeXiZeroNChannel
G4CascadeFunctions< G4CascadeSigmaPlusPChannelData, G4KaonHypSampler > G4CascadeSigmaPlusPChannel
G4CascadeFunctions< G4CascadePiZeroNChannelData, G4PionNucSampler > G4CascadePiZeroNChannel
G4CascadeFunctions< G4CascadeKzeroPChannelData, G4KaonHypSampler > G4CascadeKzeroPChannel
G4CascadeFunctions< G4CascadeKzeroBarNChannelData, G4KaonHypSampler > G4CascadeKzeroBarNChannel
G4CascadeFunctions< G4CascadeSigmaPlusNChannelData, G4KaonHypSampler > G4CascadeSigmaPlusNChannel
virtual void printTable(std::ostream &os=G4cout) const =0
#define G4ThreadLocal
Definition: tls.hh:52
G4CascadeFunctions< G4CascadeKplusNChannelData, G4KaonHypSampler > G4CascadeKplusNChannel
std::map< G4int, G4CascadeChannel * > TableMap
int G4int
Definition: G4Types.hh:78
G4CascadeFunctions< G4CascadeLambdaPChannelData, G4KaonHypSampler > G4CascadeLambdaPChannel
G4CascadeFunctions< G4CascadeSigmaMinusNChannelData, G4KaonHypSampler > G4CascadeSigmaMinusNChannel
G4CascadeFunctions< G4CascadeGamPChannelData, G4PionNucSampler > G4CascadeGamPChannel
G4CascadeFunctions< G4CascadeKminusNChannelData, G4KaonHypSampler > G4CascadeKminusNChannel
G4CascadeFunctions< G4CascadeSigmaZeroPChannelData, G4KaonHypSampler > G4CascadeSigmaZeroPChannel
G4CascadeFunctions< G4CascadePiMinusNChannelData, G4PionNucSampler > G4CascadePiMinusNChannel
G4GLOB_DLL std::ostream G4cout
G4CascadeFunctions< G4CascadeKzeroNChannelData, G4KaonHypSampler > G4CascadeKzeroNChannel
G4CascadeFunctions< G4CascadeSigmaMinusPChannelData, G4KaonHypSampler > G4CascadeSigmaMinusPChannel
G4CascadeFunctions< G4CascadeXiMinusPChannelData, G4KaonHypSampler > G4CascadeXiMinusPChannel
G4CascadeFunctions< G4CascadePiZeroPChannelData, G4PionNucSampler > G4CascadePiZeroPChannel
G4CascadeFunctions< G4CascadeKplusPChannelData, G4KaonHypSampler > G4CascadeKplusPChannel
static G4ThreadLocal G4CascadeChannelTables * theInstance
static void Print(std::ostream &os=G4cout)
G4CascadeFunctions< G4CascadeGamNChannelData, G4PionNucSampler > G4CascadeGamNChannel
G4CascadeFunctions< G4CascadeOmegaMinusNChannelData, G4KaonHypSampler > G4CascadeOmegaMinusNChannel
G4CascadeFunctions< G4CascadeKminusPChannelData, G4KaonHypSampler > G4CascadeKminusPChannel
G4CascadeFunctions< G4CascadeXiMinusNChannelData, G4KaonHypSampler > G4CascadeXiMinusNChannel
G4CascadeFunctions< G4CascadeXiZeroPChannelData, G4KaonHypSampler > G4CascadeXiZeroPChannel
G4CascadeFunctions< G4CascadeOmegaMinusPChannelData, G4KaonHypSampler > G4CascadeOmegaMinusPChannel
static const G4CascadeChannelTables & instance()
G4CascadeFunctions< G4CascadeMuMinusPChannelData, G4PionNucSampler > G4CascadeMuMinusPChannel
static void PrintTable(G4int initialState, std::ostream &os=G4cout)
G4CascadeFunctions< G4CascadeLambdaNChannelData, G4KaonHypSampler > G4CascadeLambdaNChannel
#define G4endl
Definition: G4ios.hh:61
G4CascadeFunctions< G4CascadePiMinusPChannelData, G4PionNucSampler > G4CascadePiMinusPChannel
static MCTruthManager * instance
G4CascadeFunctions< G4CascadeSigmaZeroNChannelData, G4KaonHypSampler > G4CascadeSigmaZeroNChannel
const G4CascadeChannel * FindTable(G4int initialState) const
G4CascadeFunctions< G4CascadeKzeroBarPChannelData, G4KaonHypSampler > G4CascadeKzeroBarPChannel
G4CascadeFunctions< G4CascadePiPlusPChannelData, G4PionNucSampler > G4CascadePiPlusPChannel