00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef G4_CASCADE_FUNCTIONS_ICC
00027 #define G4_CASCADE_FUNCTIONS_ICC
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "G4CascadeChannelTables.hh"
00043 #include "globals.hh"
00044
00045
00046
00047
00048 template <class DATA, class SAMP>
00049 G4CascadeFunctions<DATA,SAMP>::G4CascadeFunctions() : SAMP() {}
00050
00051
00052
00053
00054
00055 template <class DATA, class SAMP>
00056 G4int G4CascadeFunctions<DATA,SAMP>::getMultiplicity(G4double ke) const {
00057
00058 if (&DATA::data.sum != &DATA::data.tot) {
00059 G4double summed = this->findCrossSection(ke, DATA::data.sum);
00060 G4double total = this->findCrossSection(ke, DATA::data.tot);
00061 if (G4UniformRand() > summed/total) return DATA::data.maxMultiplicity();
00062 }
00063
00064 return this->findMultiplicity(ke, DATA::data.multiplicities);
00065 }
00066
00067
00068
00069
00070 template <class DATA, class SAMP>
00071 void G4CascadeFunctions<DATA,SAMP>::
00072 getOutgoingParticleTypes(std::vector<G4int>& kinds,
00073 G4int mult, G4double ke) const {
00074 const G4int maxMult = DATA::data.maxMultiplicity();
00075
00076 if (mult > maxMult) {
00077 G4cerr << " Illegal multiplicity " << mult << " > " << maxMult << G4endl;
00078 mult = maxMult;
00079 }
00080
00081 kinds.clear();
00082 kinds.reserve(mult);
00083
00084 G4int channel = this->findFinalStateIndex(mult, ke, DATA::data.index,
00085 DATA::data.crossSections);
00086 #ifdef G4CASCADE_DEBUG_SAMPLER
00087 G4cout << " getOutgoingParticleTypes: mult=" << mult << " KE=" << ke
00088 << ": channel=" << channel << G4endl;
00089 #endif
00090
00091
00092 const G4int* chan = 0;
00093 if (mult == 2) chan = DATA::data.x2bfs[channel];
00094 if (mult == 3) chan = DATA::data.x3bfs[channel];
00095 if (mult == 4) chan = DATA::data.x4bfs[channel];
00096 if (mult == 5) chan = DATA::data.x5bfs[channel];
00097 if (mult == 6) chan = DATA::data.x6bfs[channel];
00098 if (mult == 7) chan = DATA::data.x7bfs[channel];
00099 if (mult == 8) chan = DATA::data.x8bfs[channel];
00100 if (mult == 9) chan = DATA::data.x9bfs[channel];
00101
00102 if (!chan) {
00103 G4cerr << " getOutgoingParticleTypes: invalid multiplicity " << mult
00104 << G4endl;
00105 return;
00106 }
00107
00108 kinds.insert(kinds.begin(), chan, chan+mult);
00109 return;
00110 }
00111
00112
00113
00114
00115 template <class DATA, class SAMP>
00116 void G4CascadeFunctions<DATA,SAMP>::printTable(std::ostream& os) const {
00117 os << " ---------- " << DATA::data.name << " ----------" << G4endl;
00118 SAMP::print(os);
00119 DATA::data.print(os);
00120 os << " ------------------------------" << G4endl;
00121 }
00122
00123 #endif