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