00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // -------------------------------------------------------------------- 00031 // Class G4LPhysicsFreeVector 00032 // Derived from base class G4PhysicsVector 00033 // This is a free vector for Low Energy Physics cross section data 00034 // 00035 // F.W. Jones, TRIUMF, 04-JUN-96 00036 // 00037 // Modified: 00038 // 19 Jun. 2009, V.Ivanchenko : removed hidden bin 00039 // 00040 // -------------------------------------------------------------------- 00041 00042 #include "G4LPhysicsFreeVector.hh" 00043 #include "G4SystemOfUnits.hh" 00044 #include "G4ios.hh" 00045 00046 // -------------------------------------------------------------------- 00047 00048 G4LPhysicsFreeVector::G4LPhysicsFreeVector() 00049 : G4PhysicsVector() 00050 { 00051 type = T_G4LPhysicsFreeVector; 00052 } 00053 00054 // -------------------------------------------------------------------- 00055 00056 G4LPhysicsFreeVector::G4LPhysicsFreeVector(size_t nbin, 00057 G4double binmin, 00058 G4double binmax) 00059 : G4PhysicsVector() 00060 { 00061 type = T_G4LPhysicsFreeVector; 00062 00063 edgeMin = binmin; 00064 edgeMax = binmax; 00065 numberOfNodes = nbin; 00066 binVector.reserve(numberOfNodes); 00067 dataVector.reserve(numberOfNodes); 00068 for (size_t i=0; i<numberOfNodes; i++) 00069 { 00070 binVector.push_back(0.0); 00071 dataVector.push_back(0.0); 00072 } 00073 } 00074 00075 // -------------------------------------------------------------------- 00076 00077 G4LPhysicsFreeVector::~G4LPhysicsFreeVector() 00078 { 00079 } 00080 00081 // -------------------------------------------------------------------- 00082 00083 void G4LPhysicsFreeVector::DumpValues() 00084 { 00085 for (size_t i = 0; i < numberOfNodes; i++) 00086 { 00087 G4cout << binVector[i] << " " << dataVector[i]/millibarn << G4endl; 00088 } 00089 } 00090 00091 // -------------------------------------------------------------------- 00092 00093 size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const 00094 { 00095 G4int n1 = 0; 00096 G4int n2 = numberOfNodes/2; 00097 G4int n3 = numberOfNodes - 1; 00098 while (n1 != n3 - 1) 00099 { 00100 if (theEnergy > binVector[n2]) 00101 { n1 = n2; } 00102 else 00103 { n3 = n2; } 00104 n2 = n1 + (n3 - n1 + 1)/2; 00105 } 00106 #ifdef G4VERBOSE 00107 if (verboseLevel > 1) 00108 { 00109 G4cout << "G4LPhysicsFreeVector::FindBinLocation: returning " 00110 << n1 << G4endl; 00111 } 00112 #endif 00113 return (size_t)n1; 00114 }