Changeset 1315 for trunk/source/processes/hadronic/models/cascade/cascade/include/G4CascadeFunctions.hh
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/cascade/cascade/include/G4CascadeFunctions.hh
r967 r1315 23 23 // * acceptance of all terms of the Geant4 Software license. * 24 24 // ******************************************************************** 25 // $Id: G4CascadeFunctions.hh,v 1.5 2010/05/14 21:05:03 mkelsey Exp $ 26 // GEANT4 tag: $Name: geant4-09-04-beta-cand-01 $ 25 27 // 28 // 20100407 M. Kelsey -- Return particle types std::vector<> by const ref, 29 // using a static variable in the function as a buffer. 30 // 20100505 M. Kelsey -- Use new interpolator class, drop std::pair<>, move 31 // sampleFlat(...) from G4CascadeChannel, move functionality 32 // to new base class, to allow data-member buffers. Move 33 // function definitions to .icc file (needed with templating). 34 // 20100510 M. Kelsey -- Use both summed and inclusive cross-sections for 35 // multiplicity, as done in G4{Pion,Nucleon}Sampler. Support 36 // up to 9-body final states. Add second argument specifying 37 // which Sampler is used. Move implementations to .icc file. 38 // 20100511 M. Kelsey -- Pass "kinds" buffer as input to getOutputPartTypes 39 26 40 #ifndef G4_CASCADE_FUNCTIONS_HH 27 41 #define G4_CASCADE_FUNCTIONS_HH 28 42 43 #include "globals.hh" 44 #include "Randomize.hh" 29 45 #include <vector> 30 #include "globals.hh"31 #include "G4CascadeChannel.hh"32 46 33 template <class T> 34 class G4CascadeFunctions 35 {47 48 template <class DATA, class SAMP> 49 class G4CascadeFunctions : public SAMP { 36 50 public: 37 static G4double getCrossSection(double ke); 51 static G4double getCrossSection(double ke) { 52 return instance.findCrossSection(ke, DATA::data.tot); 53 } 54 55 static G4double getCrossSectionSum(double ke) { 56 return instance.findCrossSection(ke, DATA::data.sum); 57 } 58 38 59 static G4int getMultiplicity(G4double ke); 39 static std::vector<G4int> getOutgoingParticleTypes(G4int mult, G4double ke); 60 61 static void 62 getOutgoingParticleTypes(std::vector<G4int>& kinds, G4int mult, G4double ke); 63 64 private: 65 G4CascadeFunctions() : SAMP() {} 66 static const G4CascadeFunctions<DATA,SAMP> instance; 40 67 }; 41 68 42 template <class T> 43 inline 44 G4double 45 G4CascadeFunctions<T>::getCrossSection(double ke) 46 { 47 std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); 48 G4int k = epair.first; 49 G4double fraction = epair.second; 50 return T::data.tot[k] + fraction*(T::data.tot[k+1] - T::data.tot[k]); 51 } 69 #include "G4CascadeFunctions.icc" 52 70 53 template <class T> 54 inline 55 G4int 56 G4CascadeFunctions<T>::getMultiplicity(G4double ke) 57 { 58 G4double multint(0.0); 59 std::vector<G4double> sigma; 60 61 std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); 62 G4int k = epair.first; 63 G4double fraction = epair.second; 64 65 for (G4int m = 0; m < 6; ++m) 66 { 67 multint = T::data.multiplicities[m][k] 68 + fraction * (T::data.multiplicities[m][k+1] - T::data.multiplicities[m][k]); 69 sigma.push_back(multint); 70 } 71 72 return G4CascadeChannel::sampleFlat(sigma); 73 } 74 75 template <class T> 76 inline 77 std::vector<G4int> 78 G4CascadeFunctions<T>::getOutgoingParticleTypes(G4int mult, G4double ke) 79 { 80 G4int i; 81 G4double sigint(0.); 82 std::vector<G4double> sigma; 83 84 std::pair<G4int, G4double> epair = G4CascadeChannel::interpolateEnergy(ke); 85 G4int k = epair.first; 86 G4double fraction = epair.second; 87 88 G4int start = T::data.index[mult-2][0]; 89 G4int stop = T::data.index[mult-2][1]; 90 91 for (i = start; i < stop; i++) { 92 sigint = T::data.crossSections[i][k] 93 + fraction*(T::data.crossSections[i][k+1] - T::data.crossSections[i][k]); 94 sigma.push_back(sigint); 95 } 96 97 G4int channel = G4CascadeChannel::sampleFlat(sigma); 98 99 std::vector<G4int> kinds; 100 101 if (mult == 2) { 102 for(i = 0; i < mult; i++) kinds.push_back(T::data.x2bfs[channel][i]); 103 } else if (mult == 3) { 104 for(i = 0; i < mult; i++) kinds.push_back(T::data.x3bfs[channel][i]); 105 } else if (mult == 4) { 106 for(i = 0; i < mult; i++) kinds.push_back(T::data.x4bfs[channel][i]); 107 } else if (mult == 5) { 108 for(i = 0; i < mult; i++) kinds.push_back(T::data.x5bfs[channel][i]); 109 } else if (mult == 6) { 110 for(i = 0; i < mult; i++) kinds.push_back(T::data.x6bfs[channel][i]); 111 } else if (mult == 7) { 112 for(i = 0; i < mult; i++) kinds.push_back(T::data.x7bfs[channel][i]); 113 } else { 114 G4cout << " Illegal multiplicity " << G4endl; 115 } 116 117 return kinds; 118 } 119 120 121 #endif 71 #endif /* G4_CASCADE_FUNCTIONS_HH */
Note: See TracChangeset
for help on using the changeset viewer.