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 // GEANT 4 class implementation file 00032 // 00033 // G4PhysicsLnVector.cc 00034 // 00035 // 27 Apr 1999 - M.G.Pia: Created from G4PhysicsLogVector 00036 // 19 Jun 2009 - V.Ivanchenko : removed hidden bin 00037 // 00038 // -------------------------------------------------------------- 00039 00040 #include "G4PhysicsLnVector.hh" 00041 00042 G4PhysicsLnVector::G4PhysicsLnVector() 00043 : G4PhysicsVector() 00044 { 00045 type = T_G4PhysicsLnVector; 00046 } 00047 00048 G4PhysicsLnVector::G4PhysicsLnVector(size_t theNbin) 00049 : G4PhysicsVector() 00050 { 00051 type = T_G4PhysicsLnVector; 00052 00053 numberOfNodes = theNbin + 1; 00054 dataVector.reserve(numberOfNodes); 00055 binVector.reserve(numberOfNodes); 00056 00057 for (size_t i=0; i<numberOfNodes; i++) 00058 { 00059 binVector.push_back(0.0); 00060 dataVector.push_back(0.0); 00061 } 00062 } 00063 00064 G4PhysicsLnVector::G4PhysicsLnVector(G4double theEmin, 00065 G4double theEmax, size_t theNbin) 00066 : G4PhysicsVector() 00067 { 00068 type = T_G4PhysicsLnVector; 00069 00070 dBin = std::log(theEmax/theEmin)/theNbin; 00071 baseBin = std::log(theEmin)/dBin; 00072 numberOfNodes = theNbin + 1; 00073 dataVector.reserve(numberOfNodes); 00074 binVector.reserve(numberOfNodes); 00075 00076 binVector.push_back(theEmin); 00077 dataVector.push_back(0.0); 00078 00079 for (size_t i=1; i<numberOfNodes-1; i++) 00080 { 00081 binVector.push_back(std::exp((baseBin+i)*dBin)); 00082 dataVector.push_back(0.0); 00083 } 00084 binVector.push_back(theEmax); 00085 dataVector.push_back(0.0); 00086 00087 edgeMin = binVector[0]; 00088 edgeMax = binVector[numberOfNodes-1]; 00089 } 00090 00091 G4PhysicsLnVector::~G4PhysicsLnVector(){} 00092 00093 G4bool G4PhysicsLnVector::Retrieve(std::ifstream& fIn, G4bool ascii) 00094 { 00095 G4bool success = G4PhysicsVector::Retrieve(fIn, ascii); 00096 if (success) 00097 { 00098 G4double theEmin = binVector[0]; 00099 dBin = std::log(binVector[1]/theEmin); 00100 baseBin = std::log(theEmin)/dBin; 00101 } 00102 return success; 00103 } 00104 00105 void G4PhysicsLnVector::ScaleVector(G4double factorE, G4double factorV) 00106 { 00107 G4PhysicsVector::ScaleVector(factorE, factorV); 00108 G4double theEmin = binVector[0]; 00109 dBin = std::log(binVector[1]/theEmin); 00110 baseBin = std::log(theEmin)/dBin; 00111 } 00112 00113 size_t G4PhysicsLnVector::FindBinLocation(G4double theEnergy) const 00114 { 00115 00116 // For G4PhysicsLnVector, FindBinLocation is implemented using 00117 // a simple arithmetic calculation. 00118 // 00119 // Because this is a virtual function, it is accessed through a 00120 // pointer to the G4PhyiscsVector object for most usages. In this 00121 // case, 'inline' will not be invoked. However, there is a possibility 00122 // that the user access to the G4PhysicsLnVector object directly and 00123 // not through pointers or references. In this case, the 'inline' will 00124 // be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6) 00125 00126 return size_t( std::log(theEnergy)/dBin - baseBin ); 00127 }