- 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/G4CascadeData.hh
r967 r1315 23 23 // * acceptance of all terms of the Geant4 Software license. * 24 24 // ******************************************************************** 25 // $Id: G4CascadeData.hh,v 1.5 2010/05/16 05:18:36 mkelsey Exp $ 26 // GEANT4 tag: $Name: geant4-09-04-beta-cand-01 $ 25 27 // 28 // 20100507 M. Kelsey -- Use template arguments to dimension const-refs 29 // to arrays,for use in passing to functions as dimensioned. 30 // Add two additional optional(!) template args for piN/NN. 31 // Add new data member "sum" to separate summed xsec values 32 // from measured inclusive (tot) cross-sections. Add two 33 // ctors to pass inclusive xsec array as input (for piN/NN). 34 26 35 #ifndef G4_CASCADE_DATA_HH 27 36 #define G4_CASCADE_DATA_HH 28 37 29 38 #include "globals.hh" 39 #include "G4CascadeSampler.hh" /* To get number of energy bins */ 30 40 31 template <int n2, int n3, int n4, int n5, int n6, int n7, int nxs>41 template <int NE,int N2,int N3,int N4,int N5,int N6,int N7,int N8=0,int N9=0> 32 42 struct G4CascadeData 33 43 { 34 G4double * tot; 44 // NOTE: Need access to N2 by value to initialize index array 45 enum { N02=N2, N23=N2+N3, N24=N23+N4, N25=N24+N5, N26=N25+N6, N27=N26+N7, 46 N28=N27+N8, N29=N28+N9 }; 35 47 36 typedef G4double multiplicities_t[31]; 37 multiplicities_t * multiplicities; 48 enum { N8D=N8?N8:1, N9D=N9?N9:1 }; // SPECIAL: Can't dimension arrays [0] 38 49 39 typedef G4int index_t[2]; 40 index_t const * index; 50 enum { NM=N9?8:N8?7:6, NXS=N29 }; // Multiplicity and cross-section bins 41 51 42 typedef G4int x2bfs_t[2];43 x2bfs_t const * x2bfs;52 G4int index[NM+1]; // Start and stop indices to xsec's 53 G4double multiplicities[NM][NE]; // Multiplicity distributions 44 54 45 typedef G4int x3bfs_t[3]; 46 x3bfs_t const * x3bfs; 55 const G4int (&x2bfs)[N2][2]; // Initialized from file-scope inputs 56 const G4int (&x3bfs)[N3][3]; 57 const G4int (&x4bfs)[N4][4]; 58 const G4int (&x5bfs)[N5][5]; 59 const G4int (&x6bfs)[N6][6]; 60 const G4int (&x7bfs)[N7][7]; 61 const G4int (&x8bfs)[N8D][8]; // These may not be used if mult==7 62 const G4int (&x9bfs)[N9D][9]; 63 const G4double (&crossSections)[NXS][NE]; 47 64 48 typedef G4int x4bfs_t[4];49 x4bfs_t const * x4bfs;65 G4double sum[NE]; // Summed cross-sections, computed 66 const G4double (&tot)[NE]; // Inclusive cross-sections (from input) 50 67 51 typedef G4int x5bfs_t[5];52 x5bfs_t const * x5bfs;68 static const G4int empty8bfs[1][8]; // For multiplicity==7 case 69 static const G4int empty9bfs[1][9]; 53 70 54 typedef G4int x6bfs_t[6]; 55 x6bfs_t const * x6bfs; 71 G4int maxMultiplicity() const { return NM+1; } // Used by G4CascadeFunctions 56 72 57 typedef G4int x7bfs_t[7]; 58 x7bfs_t const * x7bfs; 73 // Constructor for kaon/hyperon channels, with multiplicity <= 7 74 G4CascadeData(const G4int (&the2bfs)[N2][2], const G4int (&the3bfs)[N3][3], 75 const G4int (&the4bfs)[N4][4], const G4int (&the5bfs)[N5][5], 76 const G4int (&the6bfs)[N6][6], const G4int (&the7bfs)[N7][7], 77 const G4double (&xsec)[NXS][NE]) 78 : x2bfs(the2bfs), x3bfs(the3bfs), x4bfs(the4bfs), x5bfs(the5bfs), 79 x6bfs(the6bfs), x7bfs(the7bfs), x8bfs(empty8bfs), x9bfs(empty9bfs), 80 crossSections(xsec), tot(sum) { initialize(); } 59 81 60 typedef G4float crossSections_t[31]; 61 crossSections_t const * crossSections; 82 // Constructor for kaon/hyperon channels, with multiplicity <= 7 and inclusive 83 G4CascadeData(const G4int (&the2bfs)[N2][2], const G4int (&the3bfs)[N3][3], 84 const G4int (&the4bfs)[N4][4], const G4int (&the5bfs)[N5][5], 85 const G4int (&the6bfs)[N6][6], const G4int (&the7bfs)[N7][7], 86 const G4double (&xsec)[NXS][NE], const G4double (&theTot)[NE]) 87 : x2bfs(the2bfs), x3bfs(the3bfs), x4bfs(the4bfs), x5bfs(the5bfs), 88 x6bfs(the6bfs), x7bfs(the7bfs), x8bfs(empty8bfs), x9bfs(empty9bfs), 89 crossSections(xsec), tot(theTot) { initialize(); } 62 90 63 void initialize(); 91 // Constructor for pion/nuleon channels, with multiplicity > 7 92 G4CascadeData(const G4int (&the2bfs)[N2][2], const G4int (&the3bfs)[N3][3], 93 const G4int (&the4bfs)[N4][4], const G4int (&the5bfs)[N5][5], 94 const G4int (&the6bfs)[N6][6], const G4int (&the7bfs)[N7][7], 95 const G4int (&the8bfs)[N8D][8], const G4int (&the9bfs)[N9D][9], 96 const G4double (&xsec)[NXS][NE]) 97 : x2bfs(the2bfs), x3bfs(the3bfs), x4bfs(the4bfs), x5bfs(the5bfs), 98 x6bfs(the6bfs), x7bfs(the7bfs), x8bfs(the8bfs), x9bfs(the9bfs), 99 crossSections(xsec), tot(sum) { initialize(); } 64 100 65 // G4double tot[31]; 66 // G4double multiplicities[6][31]; 67 68 // G4int index[6][2]; 69 // G4int x2bfs[n2][2]; 70 // G4int x3bfs[n3][3]; 71 // G4int x4bfs[n4][4]; 72 // G4int x5bfs[n5][5]; 73 // G4int x6bfs[n6][6]; 74 // G4int x7bfs[n7][7]; 75 76 // G4float crossSections[nxs][31]; 101 // Constructor for pion/nuleon channels, with multiplicity > 7 and inclusive 102 G4CascadeData(const G4int (&the2bfs)[N2][2], const G4int (&the3bfs)[N3][3], 103 const G4int (&the4bfs)[N4][4], const G4int (&the5bfs)[N5][5], 104 const G4int (&the6bfs)[N6][6], const G4int (&the7bfs)[N7][7], 105 const G4int (&the8bfs)[N8D][8], const G4int (&the9bfs)[N9D][9], 106 const G4double (&xsec)[NXS][NE], const G4double (&theTot)[NE]) 107 : x2bfs(the2bfs), x3bfs(the3bfs), x4bfs(the4bfs), x5bfs(the5bfs), 108 x6bfs(the6bfs), x7bfs(the7bfs), x8bfs(the8bfs), x9bfs(the9bfs), 109 crossSections(xsec), tot(theTot) { initialize(); } 110 void initialize(); // Fill summed arrays from input 77 111 }; 78 112 79 template <int n2, int n3, int n4, int n5, int n6, int n7, int nxs> 80 inline 81 void 82 G4CascadeData<n2, n3, n4, n5, n6, n7, nxs>::initialize() 83 { 113 template <int NE,int N2,int N3,int N4,int N5,int N6,int N7,int N8,int N9> inline 114 void G4CascadeData<NE,N2,N3,N4,N5,N6,N7,N8,N9>::initialize() { 115 // Initialize index offsets for cross-section array (can't do globally) 116 index[0] = 0; index[1] = N02; index[2] = N23; index[3] = N24; 117 index[4] = N25; index[5] = N26; index[6] = N27; 118 if (NM>6) index[7]=N28; 119 if (NM>7) index[8]=N29; 120 84 121 // Initialize multiplicity array 85 86 for (G4int m = 0; m < 6; m++) { 87 G4int start = index[m][0]; 88 G4int stop = index[m][1]; 89 for (G4int k = 0; k < 31; k++) { 122 for (G4int m = 0; m < NM; m++) { 123 G4int start = index[m]; 124 G4int stop = index[m+1]; 125 for (G4int k = 0; k < NE; k++) { 90 126 multiplicities[m][k] = 0.0; 91 127 for (G4int i = start; i < stop; i++) { … … 96 132 97 133 // Initialize total cross section array 98 99 for (G4int k = 0; k < 31; k++) { 100 tot[k] = 0.0; 101 for (G4int m = 0; m < 6; m++) { 102 tot[k] += multiplicities[m][k]; 134 for (G4int k = 0; k < NE; k++) { 135 sum[k] = 0.0; 136 for (G4int m = 0; m < NM; m++) { 137 sum[k] += multiplicities[m][k]; 103 138 } 104 139 } 105 140 } 106 141 142 // Dummy arrays for use when optional template arguments are skipped 143 template <int NE,int N2,int N3,int N4,int N5,int N6,int N7,int N8,int N9> 144 const G4int G4CascadeData<NE,N2,N3,N4,N5,N6,N7,N8,N9>::empty8bfs[1][8] = {{0}}; 145 146 template <int NE,int N2,int N3,int N4,int N5,int N6,int N7,int N8,int N9> 147 const G4int G4CascadeData<NE,N2,N3,N4,N5,N6,N7,N8,N9>::empty9bfs[1][9] = {{0}}; 148 107 149 #endif
Note: See TracChangeset
for help on using the changeset viewer.