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