- Timestamp:
- May 28, 2009, 4:26:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/utils/src/G4EmElementSelector.cc
r1007 r1055 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmElementSelector.cc,v 1. 4 2008/08/21 18:53:32vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 2$26 // $Id: G4EmElementSelector.cc,v 1.10 2009/05/26 16:59:35 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 58 58 G4double emin, 59 59 G4double emax, 60 G4bool spline):60 G4bool /*spline*/): 61 61 model(mod), material(mat), nbins(bins), cutEnergy(-1.0), 62 62 lowEnergy(emin), highEnergy(emax) … … 65 65 nElmMinusOne = n - 1; 66 66 theElementVector = material->GetElementVector(); 67 element = (*theElementVector)[0]; 67 68 if(nElmMinusOne > 0) { 68 for(G4int i=0; i<nElmMinusOne; i++) { 69 xSections.reserve(n); 70 for(G4int i=0; i<n; i++) { 69 71 G4PhysicsLogVector* v = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins); 70 v->SetSpline(spline);72 //v->SetSpline(spline); 71 73 xSections.push_back(v); 72 74 } … … 80 82 { 81 83 if(nElmMinusOne > 0) { 82 for(G4int i=0; i< nElmMinusOne; i++) {84 for(G4int i=0; i<=nElmMinusOne; i++) { 83 85 delete xSections[i]; 84 86 } … … 101 103 102 104 G4int i; 103 G4int n = nElmMinusOne + 1;104 G4double* xsec = new G4double[n];105 105 106 106 // loop over bins … … 110 110 cross = 0.0; 111 111 //G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl; 112 for (i=0; i< n; i++) {112 for (i=0; i<=nElmMinusOne; i++) { 113 113 cross += theAtomNumDensityVector[i]* 114 114 model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e, 115 115 cutEnergy, e); 116 xsec[i] = cross; 117 } 118 if(DBL_MIN >= cross) cross = 1.0; 119 // normalise cross section sum 120 for (i=0; i<nElmMinusOne; i++) { 121 xSections[i]->PutValue(j, xsec[i]/cross); 122 //G4cout << "i= " << i << " xs= " << xsec[i]/cross << G4endl; 116 xSections[i]->PutValue(j, cross); 123 117 } 124 118 } 125 delete [] xsec; 119 120 // xSections start from null, so use probabilities from the next bin 121 if(DBL_MIN >= (*xSections[nElmMinusOne])[0]) { 122 for (i=0; i<=nElmMinusOne; i++) { 123 xSections[i]->PutValue(0, (*xSections[i])[1]); 124 } 125 } 126 // xSections ends with null, so use probabilities from the previous bin 127 if(DBL_MIN >= (*xSections[nElmMinusOne])[nbins-1]) { 128 for (i=0; i<=nElmMinusOne; i++) { 129 xSections[i]->PutValue(nbins-1, (*xSections[i])[nbins-2]); 130 } 131 } 132 // perform normalization 133 for(G4int j=0; j<nbins; j++) { 134 cross = (*xSections[nElmMinusOne])[j]; 135 // only for positive X-section 136 if(cross > DBL_MIN) { 137 for (i=0; i<nElmMinusOne; i++) { 138 xSections[i]->PutValue(j, (*xSections[i])[j]/cross); 139 } 140 } 141 } 126 142 } 127 143 … … 139 155 } 140 156 } 141 G4cout << "Last Element in element vector "157 G4cout << "Last Element in element vector " 142 158 << (*theElementVector)[nElmMinusOne]->GetName() 143 159 << G4endl;
Note: See TracChangeset
for help on using the changeset viewer.