// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // neutron_hp -- source file // J.P. Wellisch, Nov-1996 // A prototype of the low energy neutron transport model. // // 080612 SampleDiscreteTwoBody contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #3 // #include "G4NeutronHPLegendreStore.hh" #include "G4NeutronHPVector.hh" #include "G4NeutronHPInterpolator.hh" #include "G4NeutronHPFastLegendre.hh" #include "Randomize.hh" #include //080612TK contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #3 G4double G4NeutronHPLegendreStore::SampleDiscreteTwoBody (G4double anEnergy) { G4double result; G4int i0; G4int low(0), high(0); G4NeutronHPFastLegendre theLeg; for (i0=0; i0anEnergy) break; } low = std::max(0, high-1); G4NeutronHPInterpolator theInt; G4double x, x1, x2; x = anEnergy; x1 = theCoeff[low].GetEnergy(); x2 = theCoeff[high].GetEnergy(); G4double theNorm = 0; G4double try01=0, try02=0; G4double max1, max2, costh; max1 = 0; max2 = 0; G4int l,m; for(i0=0; i0<601; i0++) { costh = G4double(i0-300)/300.; try01 = 0.5; for(m=0; mmax1) max1=try01; try02 = 0.5; for(m=0; mmax2) max2=try02; } theNorm = theInt.Interpolate(theManager.GetScheme(high), x, x1, x2, max1, max2); G4double value, random; G4double v1, v2; do { v1 = 0.5; v2 = 0.5; result = 2.*G4UniformRand()-1.; for(m=0; m=theNorm) break; // Workaround for negative cross-section values. @@@@ 31 May 2000 } while(random>value/theNorm); return result; } G4double G4NeutronHPLegendreStore::SampleMax (G4double anEnergy) { G4double result; G4int i0; G4int low(0), high(0); G4NeutronHPFastLegendre theLeg; for (i0=0; i0anEnergy) break; } low = std::max(0, high-1); G4NeutronHPInterpolator theInt; G4double x, x1, x2; x = anEnergy; x1 = theCoeff[low].GetEnergy(); x2 = theCoeff[high].GetEnergy(); G4double theNorm = 0; G4double try01=0, try02=0; G4double max1, max2, costh; max1 = 0; max2 = 0; G4int l; for(i0=0; i0<601; i0++) { costh = G4double(i0-300)/300.; try01 = 0; for(l=0; lmax1) max1=try01; try02 = 0; for(l=0; lmax2) max2=try02; } theNorm = theInt.Interpolate(theManager.GetScheme(high), x, x1, x2, max1, max2); G4double value, random; G4double v1, v2; do { v1 = 0; v2 = 0; result = 2.*G4UniformRand()-1.; for(l=0; l=theNorm) break; // Workaround for negative cross-section values. @@@@ 31 May 2000 } while(random>value/theNorm); return result; } G4double G4NeutronHPLegendreStore::SampleElastic (G4double anEnergy) { G4double result; G4int i0; G4int low(0), high(0); G4NeutronHPFastLegendre theLeg; for (i0=0; i0anEnergy) break; } low = std::max(0, high-1); G4NeutronHPInterpolator theInt; G4double x, x1, x2; x = anEnergy; x1 = theCoeff[low].GetEnergy(); x2 = theCoeff[high].GetEnergy(); G4double theNorm = 0; G4double try01=0, try02=0, try11=0, try12=0; G4double try1, try2; G4int l; for(l=0; lvalue/theNorm); return result; } G4double G4NeutronHPLegendreStore::Sample (G4double energy) // still in interpolation; do not use { G4int i0; G4int low(0), high(0); // G4cout << "G4NeutronHPLegendreStore::Sample "<