00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // Factory to return pointer to Bertini cross-section table based on 00027 // collision initial state (hadron type codes). 00028 // 00029 // Author: Michael Kelsey (SLAC) 00030 // 00031 // 20110729 M. Kelsey -- Use static instance() function to work around 00032 // "disappearance" bug on Linux (GCC 4.1.2). Add diagnostics. 00033 // 20110916 M. Kelsey -- Add "load on demand" to GetTable(), with full set 00034 // of channel .hh files for use with LoadTable(). 00035 // 20110923 M. Kelsey -- Add optional stream& argument to printTable(), 00036 // pass through. 00037 // 20111007 M. Kelsey -- Add new gamma-n and gamma-p tables. 00038 00039 #include "G4CascadeChannelTables.hh" 00040 #include "G4CascadeChannel.hh" 00041 #include <iostream> 00042 #include <map> 00043 00044 00045 // Singleton is created at first invocation 00046 00047 G4CascadeChannelTables& G4CascadeChannelTables::instance() { 00048 static G4CascadeChannelTables theInstance; 00049 return theInstance; 00050 } 00051 00052 00053 // Argument is interaction code, product of G4InuclEP types 00054 00055 const G4CascadeChannel* G4CascadeChannelTables::GetTable(G4int initialState) { 00056 const G4CascadeChannel* theTable = instance().FindTable(initialState); 00057 if (!theTable) theTable = instance().LoadTable(initialState); 00058 return theTable; 00059 } 00060 00061 // Arguments are individual G4InuclElementaryParticle types 00062 00063 const G4CascadeChannel* 00064 G4CascadeChannelTables::GetTable(G4int had1, G4int had2) { 00065 return GetTable(had1*had2); 00066 } 00067 00068 // Register cross-section table for later lookup 00069 00070 void 00071 G4CascadeChannelTables::AddTable(G4int initialState, G4CascadeChannel* table) { 00072 instance().SaveTable(initialState, table); 00073 } 00074 00075 // Return cross-section table requested by user 00076 00077 const G4CascadeChannel* 00078 G4CascadeChannelTables::FindTable(G4int initialState) { 00079 #ifdef G4CASCADE_DEBUG_SAMPLER 00080 G4cout << "G4CascadeChannelTables::FindTable " << initialState << G4endl; 00081 #endif 00082 return (tables.find(initialState)!=tables.end()) ? tables[initialState] : 0; 00083 } 00084 00085 00086 // Register specified table in list, replacing previous version 00087 00088 void 00089 G4CascadeChannelTables::SaveTable(G4int initialState, G4CascadeChannel* table) { 00090 #ifdef G4CASCADE_DEBUG_SAMPLER 00091 G4cout << "G4CascadeChannelTables::SaveTable " << initialState << G4endl; 00092 #endif 00093 if (!table) return; // Avoid unnecessary work 00094 00095 if (FindTable(initialState)) delete tables[initialState]; 00096 tables[initialState] = table; 00097 } 00098 00099 00100 // Convenience function for diagnostic output 00101 00102 void G4CascadeChannelTables::PrintTable(G4int initialState, std::ostream& os) { 00103 const G4CascadeChannel* tbl = GetTable(initialState); 00104 if (tbl) tbl->printTable(os); 00105 } 00106 00107 00108 // Special function to create and store table for specified interaction 00109 00110 #include "G4CascadeGamNChannel.hh" 00111 #include "G4CascadeGamPChannel.hh" 00112 #include "G4CascadeKminusNChannel.hh" 00113 #include "G4CascadeKminusPChannel.hh" 00114 #include "G4CascadeKplusNChannel.hh" 00115 #include "G4CascadeKplusPChannel.hh" 00116 #include "G4CascadeKzeroBarNChannel.hh" 00117 #include "G4CascadeKzeroBarPChannel.hh" 00118 #include "G4CascadeKzeroNChannel.hh" 00119 #include "G4CascadeKzeroPChannel.hh" 00120 #include "G4CascadeLambdaNChannel.hh" 00121 #include "G4CascadeLambdaPChannel.hh" 00122 #include "G4CascadeNNChannel.hh" 00123 #include "G4CascadeNPChannel.hh" 00124 #include "G4CascadePPChannel.hh" 00125 #include "G4CascadePiMinusNChannel.hh" 00126 #include "G4CascadePiMinusPChannel.hh" 00127 #include "G4CascadePiPlusNChannel.hh" 00128 #include "G4CascadePiPlusPChannel.hh" 00129 #include "G4CascadePiZeroNChannel.hh" 00130 #include "G4CascadePiZeroPChannel.hh" 00131 #include "G4CascadeSigmaMinusNChannel.hh" 00132 #include "G4CascadeSigmaMinusPChannel.hh" 00133 #include "G4CascadeSigmaPlusNChannel.hh" 00134 #include "G4CascadeSigmaPlusPChannel.hh" 00135 #include "G4CascadeSigmaZeroNChannel.hh" 00136 #include "G4CascadeSigmaZeroPChannel.hh" 00137 #include "G4CascadeXiMinusNChannel.hh" 00138 #include "G4CascadeXiMinusPChannel.hh" 00139 #include "G4CascadeXiZeroNChannel.hh" 00140 #include "G4CascadeXiZeroPChannel.hh" 00141 #include "G4CascadeOmegaMinusNChannel.hh" 00142 #include "G4CascadeOmegaMinusPChannel.hh" 00143 #include "G4InuclParticleNames.hh" 00144 using namespace G4InuclParticleNames; 00145 00146 const G4CascadeChannel* G4CascadeChannelTables::LoadTable(G4int initialState) { 00147 #ifdef G4CASCADE_DEBUG_SAMPLER 00148 G4cout << "G4CascadeChannelTables::LoadTable " << initialState << G4endl; 00149 #endif 00150 00151 G4CascadeChannel* tbl = 0; 00152 switch (initialState) { 00153 case gam*neu: tbl = new G4CascadeGamNChannel; break; 00154 case gam*pro: tbl = new G4CascadeGamPChannel; break; 00155 case k0*neu: tbl = new G4CascadeKzeroNChannel; break; 00156 case k0*pro: tbl = new G4CascadeKzeroPChannel; break; 00157 case k0b*neu: tbl = new G4CascadeKzeroBarNChannel; break; 00158 case k0b*pro: tbl = new G4CascadeKzeroBarPChannel; break; 00159 case kmi*neu: tbl = new G4CascadeKminusNChannel; break; 00160 case kmi*pro: tbl = new G4CascadeKminusPChannel; break; 00161 case kpl*neu: tbl = new G4CascadeKplusNChannel; break; 00162 case kpl*pro: tbl = new G4CascadeKplusPChannel; break; 00163 case lam*neu: tbl = new G4CascadeLambdaNChannel; break; 00164 case lam*pro: tbl = new G4CascadeLambdaPChannel; break; 00165 case neu*neu: tbl = new G4CascadeNNChannel; break; 00166 case neu*pro: tbl = new G4CascadeNPChannel; break; 00167 case pi0*neu: tbl = new G4CascadePiZeroNChannel; break; 00168 case pi0*pro: tbl = new G4CascadePiZeroPChannel; break; 00169 case pim*neu: tbl = new G4CascadePiMinusNChannel; break; 00170 case pim*pro: tbl = new G4CascadePiMinusPChannel; break; 00171 case pip*neu: tbl = new G4CascadePiPlusNChannel; break; 00172 case pip*pro: tbl = new G4CascadePiPlusPChannel; break; 00173 case pro*pro: tbl = new G4CascadePPChannel; break; 00174 case s0*neu: tbl = new G4CascadeSigmaZeroNChannel; break; 00175 case s0*pro: tbl = new G4CascadeSigmaZeroPChannel; break; 00176 case sm*neu: tbl = new G4CascadeSigmaMinusNChannel; break; 00177 case sm*pro: tbl = new G4CascadeSigmaMinusPChannel; break; 00178 case sp*neu: tbl = new G4CascadeSigmaPlusNChannel; break; 00179 case sp*pro: tbl = new G4CascadeSigmaPlusPChannel; break; 00180 case xi0*neu: tbl = new G4CascadeXiZeroNChannel; break; 00181 case xi0*pro: tbl = new G4CascadeXiZeroPChannel; break; 00182 case xim*neu: tbl = new G4CascadeXiMinusNChannel; break; 00183 case xim*pro: tbl = new G4CascadeXiMinusPChannel; break; 00184 case om*neu: tbl = new G4CascadeOmegaMinusNChannel; break; 00185 case om*pro: tbl = new G4CascadeOmegaMinusPChannel; break; 00186 default: tbl = 0; 00187 } 00188 00189 SaveTable(initialState, tbl); 00190 return tbl; 00191 }