ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CascadeChannelTables.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4CascadeChannelTables.cc
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"
46 #include "G4CascadeGamNChannel.hh"
47 #include "G4CascadeGamPChannel.hh"
58 #include "G4CascadeNNChannel.hh"
59 #include "G4CascadeNPChannel.hh"
60 #include "G4CascadePPChannel.hh"
80 #include "G4InuclParticleNames.hh"
81 #include <iostream>
82 #include <map>
83 using namespace G4InuclParticleNames;
84 
85 
86 // Singleton is created at first invocation
87 
89 
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 
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 
158 const G4CascadeChannel*
160  return GetTable(had1*had2);
161 }
162 
163 // Return cross-section table requested by user
164 
165 const G4CascadeChannel*
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 
177 void 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 
185 void G4CascadeChannelTables::PrintTable(G4int initialState, std::ostream& os) {
186  const G4CascadeChannel* tbl = GetTable(initialState);
187  if (tbl) tbl->printTable(os);
188 }