Geant4  10.03
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 // 20141121 Use G4AutoDelete to avoid end-of-thread memory leaks
43 
45 #include "G4AutoDelete.hh"
46 #include "G4CascadeChannel.hh"
47 #include "G4CascadeGamNChannel.hh"
48 #include "G4CascadeGamPChannel.hh"
59 #include "G4CascadeNNChannel.hh"
60 #include "G4CascadeNPChannel.hh"
61 #include "G4CascadePPChannel.hh"
81 #include "G4InuclParticleNames.hh"
82 #include <iostream>
83 #include <map>
84 using namespace G4InuclParticleNames;
85 
86 
87 // Singleton is created at first invocation
88 
90 
92  if (!theInstance) {
93  theInstance = new G4CascadeChannelTables;
94  G4AutoDelete::Register(theInstance);
95  }
96 
97  return *theInstance;
98 }
99 
100 
101 // Constructor and destructor fully populate tables
102 
104  tables.clear();
105  tables[gam*neu] = new G4CascadeGamNChannel;
106  tables[gam*pro] = new G4CascadeGamPChannel;
107  tables[k0*neu] = new G4CascadeKzeroNChannel;
108  tables[k0*pro] = new G4CascadeKzeroPChannel;
109  tables[k0b*neu] = new G4CascadeKzeroBarNChannel;
110  tables[k0b*pro] = new G4CascadeKzeroBarPChannel;
111  tables[kmi*neu] = new G4CascadeKminusNChannel;
112  tables[kmi*pro] = new G4CascadeKminusPChannel;
113  tables[kpl*neu] = new G4CascadeKplusNChannel;
114  tables[kpl*pro] = new G4CascadeKplusPChannel;
115  tables[lam*neu] = new G4CascadeLambdaNChannel;
116  tables[lam*pro] = new G4CascadeLambdaPChannel;
117  tables[neu*neu] = new G4CascadeNNChannel;
118  tables[neu*pro] = new G4CascadeNPChannel;
119  tables[pi0*neu] = new G4CascadePiZeroNChannel;
120  tables[pi0*pro] = new G4CascadePiZeroPChannel;
121  tables[pim*neu] = new G4CascadePiMinusNChannel;
122  tables[pim*pro] = new G4CascadePiMinusPChannel;
123  tables[pip*neu] = new G4CascadePiPlusNChannel;
124  tables[pip*pro] = new G4CascadePiPlusPChannel;
125  tables[pro*pro] = new G4CascadePPChannel;
126  tables[s0*neu] = new G4CascadeSigmaZeroNChannel;
127  tables[s0*pro] = new G4CascadeSigmaZeroPChannel;
128  tables[sm*neu] = new G4CascadeSigmaMinusNChannel;
129  tables[sm*pro] = new G4CascadeSigmaMinusPChannel;
130  tables[sp*neu] = new G4CascadeSigmaPlusNChannel;
131  tables[sp*pro] = new G4CascadeSigmaPlusPChannel;
132  tables[xi0*neu] = new G4CascadeXiZeroNChannel;
133  tables[xi0*pro] = new G4CascadeXiZeroPChannel;
134  tables[xim*neu] = new G4CascadeXiMinusNChannel;
135  tables[xim*pro] = new G4CascadeXiMinusPChannel;
136  tables[om*neu] = new G4CascadeOmegaMinusNChannel;
137  tables[om*pro] = new G4CascadeOmegaMinusPChannel;
138  tables[mum*pro] = new G4CascadeMuMinusPChannel;
139 }
140 
142  TableMap::iterator entry;
143  for (entry = tables.begin(); entry != tables.end(); ++entry) {
144  delete entry->second; entry->second = 0;
145  }
146 
147  tables.clear();
148 }
149 
150 
151 // Argument is interaction code, product of G4InuclEP types
152 
154  return instance().FindTable(initialState);
155 }
156 
157 // Arguments are individual G4InuclElementaryParticle types
158 
159 const G4CascadeChannel*
161  return GetTable(had1*had2);
162 }
163 
164 // Return cross-section table requested by user
165 
166 const G4CascadeChannel*
168 #ifdef G4CASCADE_DEBUG_SAMPLER
169  G4cout << "G4CascadeChannelTables::FindTable " << initialState << G4endl;
170 #endif
171  TableMap::const_iterator entry = tables.find(initialState);
172  return (entry != tables.end()) ? entry->second : 0;
173 }
174 
175 
176 // Convenience functions for diagnostic output
177 
178 void G4CascadeChannelTables::Print(std::ostream& os) {
179  const TableMap& theTables = instance().tables; // For convenience
180  TableMap::const_iterator entry;
181  for (entry = theTables.begin(); entry != theTables.end(); ++entry) {
182  if (entry->second) entry->second->printTable(os);
183  }
184 }
185 
186 void G4CascadeChannelTables::PrintTable(G4int initialState, std::ostream& os) {
187  const G4CascadeChannel* tbl = GetTable(initialState);
188  if (tbl) tbl->printTable(os);
189 }
static const G4CascadeChannel * GetTable(G4int initialState)
G4CascadeFunctions< G4CascadeKplusNChannelData, G4KaonSampler > G4CascadeKplusNChannel
G4CascadeFunctions< G4CascadePiPlusNChannelData, G4PionNucSampler > G4CascadePiPlusNChannel
G4CascadeFunctions< G4CascadeXiZeroNChannelData, G4KaonHypSampler > G4CascadeXiZeroNChannel
G4CascadeFunctions< G4CascadeKzeroBarPChannelData, G4KaonSampler > G4CascadeKzeroBarPChannel
G4CascadeFunctions< G4CascadeSigmaPlusPChannelData, G4KaonHypSampler > G4CascadeSigmaPlusPChannel
G4CascadeFunctions< G4CascadePiZeroNChannelData, G4PionNucSampler > G4CascadePiZeroNChannel
G4CascadeFunctions< G4CascadeKminusNChannelData, G4KaonSampler > G4CascadeKminusNChannel
G4CascadeFunctions< G4CascadeSigmaPlusNChannelData, G4KaonHypSampler > G4CascadeSigmaPlusNChannel
virtual void printTable(std::ostream &os=G4cout) const =0
#define G4ThreadLocal
Definition: tls.hh:89
std::map< G4int, G4CascadeChannel * > TableMap
int G4int
Definition: G4Types.hh:78
G4CascadeFunctions< G4CascadeLambdaPChannelData, G4KaonHypSampler > G4CascadeLambdaPChannel
G4CascadeFunctions< G4CascadeSigmaMinusNChannelData, G4KaonHypSampler > G4CascadeSigmaMinusNChannel
G4CascadeFunctions< G4CascadeGamPChannelData, G4PionNucSampler > G4CascadeGamPChannel
G4CascadeFunctions< G4CascadeKzeroNChannelData, G4KaonSampler > G4CascadeKzeroNChannel
G4CascadeFunctions< G4CascadeSigmaZeroPChannelData, G4KaonHypSampler > G4CascadeSigmaZeroPChannel
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4CascadeFunctions< G4CascadePiMinusNChannelData, G4PionNucSampler > G4CascadePiMinusNChannel
G4GLOB_DLL std::ostream G4cout
G4CascadeFunctions< G4CascadeSigmaMinusPChannelData, G4KaonHypSampler > G4CascadeSigmaMinusPChannel
G4CascadeFunctions< G4CascadeXiMinusPChannelData, G4KaonHypSampler > G4CascadeXiMinusPChannel
G4CascadeFunctions< G4CascadeKzeroBarNChannelData, G4KaonSampler > G4CascadeKzeroBarNChannel
G4CascadeFunctions< G4CascadePiZeroPChannelData, G4PionNucSampler > G4CascadePiZeroPChannel
G4CascadeFunctions< G4CascadeKzeroPChannelData, G4KaonSampler > G4CascadeKzeroPChannel
static G4ThreadLocal G4CascadeChannelTables * theInstance
static void Print(std::ostream &os=G4cout)
G4CascadeFunctions< G4CascadeGamNChannelData, G4PionNucSampler > G4CascadeGamNChannel
G4CascadeFunctions< G4CascadeOmegaMinusNChannelData, G4KaonHypSampler > G4CascadeOmegaMinusNChannel
G4CascadeFunctions< G4CascadeXiMinusNChannelData, G4KaonHypSampler > G4CascadeXiMinusNChannel
G4CascadeFunctions< G4CascadeXiZeroPChannelData, G4KaonHypSampler > G4CascadeXiZeroPChannel
G4CascadeFunctions< G4CascadeOmegaMinusPChannelData, G4KaonHypSampler > G4CascadeOmegaMinusPChannel
G4CascadeFunctions< G4CascadeKminusPChannelData, G4KaonSampler > G4CascadeKminusPChannel
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
G4CascadeFunctions< G4CascadeKplusPChannelData, G4KaonSampler > G4CascadeKplusPChannel
const G4CascadeChannel * FindTable(G4int initialState) const
G4CascadeFunctions< G4CascadePiPlusPChannelData, G4PionNucSampler > G4CascadePiPlusPChannel