[833] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4PhysicsLinearVector.cc,v 1.12 2006/06/29 19:04:13 gunter Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[833] | 29 | // |
---|
| 30 | // |
---|
| 31 | //-------------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class implementation file |
---|
| 33 | // |
---|
| 34 | // G4PhysicsLinearVector.cc |
---|
| 35 | // |
---|
| 36 | // History: |
---|
| 37 | // 02 Dec. 1995, G.Cosmo : Structure created based on object model |
---|
| 38 | // 15 Feb. 1996, K.Amako : Implemented the 1st version |
---|
| 39 | // 01 Jul. 1996, K.Amako : Cache mechanism and hidden bin from the |
---|
| 40 | // user introduced. |
---|
| 41 | // 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added. |
---|
| 42 | // 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector |
---|
| 43 | // 9 Mar. 2001, H.Kurashige : add PhysicsVector type and Retrieve |
---|
| 44 | // |
---|
| 45 | //-------------------------------------------------------------------- |
---|
| 46 | |
---|
| 47 | #include "G4PhysicsLinearVector.hh" |
---|
| 48 | |
---|
| 49 | G4PhysicsLinearVector::G4PhysicsLinearVector() |
---|
| 50 | : dBin(0.), baseBin(0.) |
---|
| 51 | { |
---|
| 52 | edgeMin = 0.0; |
---|
| 53 | edgeMax = 0.0; |
---|
| 54 | numberOfBin = 0; |
---|
| 55 | type = T_G4PhysicsLinearVector; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin) |
---|
| 59 | : dBin(0.), baseBin(0.) |
---|
| 60 | { |
---|
| 61 | type = T_G4PhysicsLinearVector; |
---|
| 62 | |
---|
| 63 | // Add extra one bin (hidden to user) to handle correctly when |
---|
| 64 | // Energy=theEmax in getValue. |
---|
| 65 | dataVector.reserve(theNbin+1); |
---|
| 66 | binVector.reserve(theNbin+1); |
---|
| 67 | |
---|
| 68 | numberOfBin = theNbin; |
---|
| 69 | |
---|
| 70 | edgeMin = 0.; |
---|
| 71 | edgeMax = 0.; |
---|
| 72 | |
---|
| 73 | lastBin = INT_MAX; |
---|
| 74 | lastEnergy = -DBL_MAX; |
---|
| 75 | lastValue = DBL_MAX; |
---|
| 76 | |
---|
| 77 | for (size_t i=0; i<=numberOfBin; i++) |
---|
| 78 | { |
---|
| 79 | binVector.push_back(0.0); |
---|
| 80 | dataVector.push_back(0.0); |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin, |
---|
| 85 | G4double theEmax, size_t theNbin) |
---|
| 86 | : dBin((theEmax-theEmin)/theNbin), |
---|
| 87 | baseBin(theEmin/dBin) |
---|
| 88 | { |
---|
| 89 | type = T_G4PhysicsLinearVector; |
---|
| 90 | |
---|
| 91 | // Add extra one bin (hidden to user) to handle correctly when |
---|
| 92 | // Energy=theEmax in getValue. |
---|
| 93 | dataVector.reserve(theNbin+1); |
---|
| 94 | binVector.reserve(theNbin+1); |
---|
| 95 | |
---|
| 96 | numberOfBin = theNbin; |
---|
| 97 | |
---|
| 98 | for (size_t i=0; i<numberOfBin+1; i++) |
---|
| 99 | { |
---|
| 100 | binVector.push_back( theEmin + i*dBin ); |
---|
| 101 | dataVector.push_back(0.0); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | edgeMin = binVector[0]; |
---|
| 105 | edgeMax = binVector[numberOfBin-1]; |
---|
| 106 | |
---|
| 107 | lastBin = INT_MAX; |
---|
| 108 | lastEnergy = -DBL_MAX; |
---|
| 109 | lastValue = DBL_MAX; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | G4PhysicsLinearVector::~G4PhysicsLinearVector(){} |
---|
| 113 | |
---|
| 114 | G4bool G4PhysicsLinearVector::Retrieve(std::ifstream& fIn, G4bool ascii) |
---|
| 115 | { |
---|
| 116 | G4bool success = G4PhysicsVector::Retrieve(fIn, ascii); |
---|
| 117 | if (success) |
---|
| 118 | { |
---|
| 119 | G4double theEmin = binVector[0]; |
---|
| 120 | dBin = binVector[1]-theEmin; |
---|
| 121 | baseBin = theEmin/dBin; |
---|
| 122 | } |
---|
| 123 | return success; |
---|
| 124 | } |
---|