| [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 | //
|
|---|
| [921] | 27 | // $Id: G4PhysicsLogVector.cc,v 1.21 2008/09/22 08:26:33 gcosmo Exp $
|
|---|
| [1058] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| [833] | 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // --------------------------------------------------------------
|
|---|
| 32 | // GEANT 4 class implementation file
|
|---|
| 33 | //
|
|---|
| 34 | // G4PhysicsLogVector.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 : Hidden bin from the user introduced
|
|---|
| 40 | // 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added
|
|---|
| 41 | // 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector
|
|---|
| [921] | 42 | // 9 Mar. 2001, H.Kurashige : added PhysicsVector type and Retrieve
|
|---|
| [850] | 43 | // 05 Sep. 2008, V.Ivanchenko : added protections for zero-length vector
|
|---|
| [833] | 44 | //
|
|---|
| 45 | // --------------------------------------------------------------
|
|---|
| 46 |
|
|---|
| 47 | #include "G4PhysicsLogVector.hh"
|
|---|
| 48 |
|
|---|
| 49 | G4PhysicsLogVector::G4PhysicsLogVector()
|
|---|
| [850] | 50 | : G4PhysicsVector(), dBin(0.), baseBin(0.)
|
|---|
| [833] | 51 | {
|
|---|
| 52 | type = T_G4PhysicsLogVector;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | G4PhysicsLogVector::G4PhysicsLogVector(size_t theNbin)
|
|---|
| [850] | 56 | : G4PhysicsVector(), dBin(0.), baseBin(0.)
|
|---|
| [833] | 57 | {
|
|---|
| 58 | type = T_G4PhysicsLogVector;
|
|---|
| 59 |
|
|---|
| 60 | // Add extra one bin (hidden to user) to handle correctly when
|
|---|
| 61 | // Energy=theEmax in getValue.
|
|---|
| [921] | 62 | dataVector.reserve(theNbin+1);
|
|---|
| 63 | binVector.reserve(theNbin+1);
|
|---|
| [833] | 64 |
|
|---|
| 65 | numberOfBin = theNbin;
|
|---|
| 66 |
|
|---|
| [921] | 67 | for (size_t i=0; i<=numberOfBin; i++)
|
|---|
| 68 | {
|
|---|
| 69 | binVector.push_back(0.0);
|
|---|
| 70 | dataVector.push_back(0.0);
|
|---|
| [833] | 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | G4PhysicsLogVector::G4PhysicsLogVector(G4double theEmin,
|
|---|
| 75 | G4double theEmax, size_t theNbin)
|
|---|
| [850] | 76 | : G4PhysicsVector(), dBin(std::log10(theEmax/theEmin)/theNbin),
|
|---|
| [833] | 77 | baseBin(std::log10(theEmin)/dBin)
|
|---|
| 78 | {
|
|---|
| 79 | type = T_G4PhysicsLogVector;
|
|---|
| 80 |
|
|---|
| 81 | // Add extra one bin (hidden to user) to handle correctly when
|
|---|
| 82 | // Energy=theEmax in getValue.
|
|---|
| [921] | 83 | dataVector.reserve(theNbin+1);
|
|---|
| 84 | binVector.reserve(theNbin+1);
|
|---|
| [833] | 85 |
|
|---|
| 86 | numberOfBin = theNbin;
|
|---|
| 87 |
|
|---|
| [921] | 88 | for (size_t i=0; i<numberOfBin+1; i++)
|
|---|
| 89 | {
|
|---|
| 90 | binVector.push_back(std::pow(10., std::log10(theEmin)+i*dBin));
|
|---|
| 91 | dataVector.push_back(0.0);
|
|---|
| [833] | 92 | }
|
|---|
| [921] | 93 | edgeMin = binVector[0];
|
|---|
| 94 | edgeMax = binVector[numberOfBin-1];
|
|---|
| [833] | 95 | }
|
|---|
| 96 |
|
|---|
| [921] | 97 | G4PhysicsLogVector::~G4PhysicsLogVector()
|
|---|
| 98 | {
|
|---|
| 99 | }
|
|---|
| [833] | 100 |
|
|---|
| 101 | G4bool G4PhysicsLogVector::Retrieve(std::ifstream& fIn, G4bool ascii)
|
|---|
| 102 | {
|
|---|
| 103 | G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
|
|---|
| 104 | if (success)
|
|---|
| 105 | {
|
|---|
| 106 | G4double theEmin = binVector[0];
|
|---|
| 107 | dBin = std::log10(binVector[1]/theEmin);
|
|---|
| 108 | baseBin = std::log10(theEmin)/dBin;
|
|---|
| 109 | }
|
|---|
| 110 | return success;
|
|---|
| 111 | }
|
|---|
| [921] | 112 |
|
|---|
| 113 | G4PhysicsLogVector::G4PhysicsLogVector(const G4PhysicsLogVector& right)
|
|---|
| 114 | : G4PhysicsVector(right)
|
|---|
| 115 | {
|
|---|
| 116 | dBin = right.dBin;
|
|---|
| 117 | baseBin = right.baseBin;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | G4PhysicsLogVector&
|
|---|
| 121 | G4PhysicsLogVector::operator=(const G4PhysicsLogVector& right)
|
|---|
| 122 | {
|
|---|
| 123 | // Check assignment to self
|
|---|
| 124 | //
|
|---|
| 125 | if(this == &right) { return *this; }
|
|---|
| 126 |
|
|---|
| 127 | DeleteData();
|
|---|
| 128 | CopyData(right);
|
|---|
| 129 |
|
|---|
| 130 | dBin = right.dBin;
|
|---|
| 131 | baseBin = right.baseBin;
|
|---|
| 132 | return *this;
|
|---|
| 133 | }
|
|---|