Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 7 // 6 // * the Geant4 Collaboration. It is provided << 8 // $Id: G4PhysicsLogVector.cc,v 1.2 1999/11/16 17:46:52 gcosmo Exp $ 7 // * conditions of the Geant4 Software License << 9 // GEANT4 tag $Name: geant4-02-00 $ 8 // * LICENSE and available at http://cern.ch/ << 10 // 9 // * include a list of copyright holders. << 11 // 10 // * << 12 // -------------------------------------------------------------- 11 // * Neither the authors of this software syst << 13 // GEANT 4 class implementation file 12 // * institutes,nor the agencies providing fin << 14 // 13 // * work make any representation or warran << 15 // G4PhysicsLogVector.cc 14 // * regarding this software system or assum << 16 // 15 // * use. Please see the license in the file << 17 // History: first implementation, based on object model of 16 // * for the full disclaimer and the limitatio << 18 // 02 Dec. 1995, G.Cosmo : Structure created based on object model 17 // * << 19 // 15 Feb. 1996, K.Amako : Implemented the 1st version 18 // * This code implementation is the result << 20 // 01 Jul. 1996, K.Amako : Hidden bin from the user introduced 19 // * technical work of the GEANT4 collaboratio << 21 // 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added. 20 // * By using, copying, modifying or distri << 22 // 21 // * any work based on the software) you ag << 23 // -------------------------------------------------------------- 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // << 26 // G4PhysicsLogVector class implementation << 27 // << 28 // Authors: << 29 // - 02 Dec. 1995, G.Cosmo: Structure created << 30 // - 03 Mar. 1996, K.Amako: Implemented the 1s << 31 // Revisions: << 32 // - 11 Nov. 2000, H.Kurashige : Use STL vecto << 33 // ------------------------------------------- << 34 24 35 #include "G4PhysicsLogVector.hh" 25 #include "G4PhysicsLogVector.hh" 36 #include "G4Exp.hh" << 37 #include "G4Log.hh" << 38 26 39 // ------------------------------------------- << 27 40 G4PhysicsLogVector::G4PhysicsLogVector(G4bool << 28 G4PhysicsLogVector::G4PhysicsLogVector() 41 : G4PhysicsVector(spline) << 29 : dBin(0.), baseBin(0.) >> 30 {} >> 31 >> 32 >> 33 G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin) 42 { 34 { 43 type = T_G4PhysicsLogVector; << 44 } << 45 35 46 // ------------------------------------------- << 36 // Add extra one bin (hidden to user) to handle correctly when 47 G4PhysicsLogVector::G4PhysicsLogVector(G4doubl << 37 // Energy=theEmax in getValue. 48 std::si << 38 dataVector.resize(theNbin+1); 49 : G4PhysicsVector(spline) << 39 binVector.resize(theNbin+1); >> 40 >> 41 ptrNextTable = 0; >> 42 numberOfBin = theNbin; >> 43 dBin = 0.; >> 44 baseBin = 0.; >> 45 >> 46 edgeMin = 0.; >> 47 edgeMax = 0.; >> 48 >> 49 lastBin = INT_MAX; >> 50 lastEnergy = -DBL_MAX; >> 51 lastValue = DBL_MAX; >> 52 } >> 53 >> 54 >> 55 G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin, >> 56 G4double theEmax, size_t theNbin) 50 { 57 { 51 numberOfNodes = Nbin + 1; << 52 if (Nbin < 2 || Emin >= Emax || Emin <= 0.0) << 53 { << 54 G4ExceptionDescription ed; << 55 ed << "G4PhysicsLogVector with wrong param << 56 << " Emin= " << Emin << " Emax= " << Em << 57 G4Exception("G4PhysicsLogVector::G4Physics << 58 FatalException, ed, "Nbins sho << 59 } << 60 if (numberOfNodes < 3) << 61 { << 62 numberOfNodes = 3; << 63 } << 64 type = T_G4PhysicsLogVector; << 65 58 66 binVector.resize(numberOfNodes); << 59 // Add extra one bin (hidden to user) to handle correctly when 67 dataVector.resize(numberOfNodes, 0.0); << 60 // Energy=theEmax in getValue. 68 binVector[0] = Emin; << 61 dataVector.resize(theNbin+1); 69 binVector[numberOfNodes - 1] = Emax; << 62 binVector.resize(theNbin+1); 70 Initialise(); << 63 71 << 64 ptrNextTable = 0; 72 for (std::size_t i = 1; i <= idxmax; ++i) << 65 numberOfBin = theNbin; 73 { << 66 dBin = log10(theEmax/theEmin) / numberOfBin; 74 binVector[i] = edgeMin*G4Exp(i / invdBin); << 67 baseBin = log10(theEmin)/dBin; >> 68 >> 69 for (G4int i=0; i<numberOfBin+1; i++) { >> 70 binVector(i) = pow(10., log10(theEmin)+i*dBin); 75 } 71 } 76 } << 77 72 78 // ------------------------------------------- << 73 edgeMin = binVector(0); 79 void G4PhysicsLogVector::Initialise() << 74 edgeMax = binVector(numberOfBin-1); 80 { << 75 81 idxmax = numberOfNodes - 2; << 76 lastBin = INT_MAX; 82 edgeMin = binVector[0]; << 77 lastEnergy = -DBL_MAX; 83 edgeMax = binVector[idxmax + 1]; << 78 lastValue = DBL_MAX; 84 invdBin = (idxmax + 1) / G4Log(edgeMax/edgeM << 79 } 85 logemin = G4Log(edgeMin); << 80 86 } << 87 81 88 // ------------------------------------------- << 82 G4PhysicsLogVector::~G4PhysicsLogVector(){} 89 83