Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PhysicsLnVector.cc
Go to the documentation of this file.
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$
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // G4PhysicsLnVector.cc
34 //
35 // 27 Apr 1999 - M.G.Pia: Created from G4PhysicsLogVector
36 // 19 Jun 2009 - V.Ivanchenko : removed hidden bin
37 //
38 // --------------------------------------------------------------
39 
40 #include "G4PhysicsLnVector.hh"
41 
43  : G4PhysicsVector()
44 {
46 }
47 
49  : G4PhysicsVector()
50 {
52 
53  numberOfNodes = theNbin + 1;
54  dataVector.reserve(numberOfNodes);
55  binVector.reserve(numberOfNodes);
56 
57  for (size_t i=0; i<numberOfNodes; i++)
58  {
59  binVector.push_back(0.0);
60  dataVector.push_back(0.0);
61  }
62 }
63 
65  G4double theEmax, size_t theNbin)
66  : G4PhysicsVector()
67 {
69 
70  dBin = std::log(theEmax/theEmin)/theNbin;
71  baseBin = std::log(theEmin)/dBin;
72  numberOfNodes = theNbin + 1;
73  dataVector.reserve(numberOfNodes);
74  binVector.reserve(numberOfNodes);
75 
76  binVector.push_back(theEmin);
77  dataVector.push_back(0.0);
78 
79  for (size_t i=1; i<numberOfNodes-1; i++)
80  {
81  binVector.push_back(std::exp((baseBin+i)*dBin));
82  dataVector.push_back(0.0);
83  }
84  binVector.push_back(theEmax);
85  dataVector.push_back(0.0);
86 
87  edgeMin = binVector[0];
88  edgeMax = binVector[numberOfNodes-1];
89 }
90 
92 
93 G4bool G4PhysicsLnVector::Retrieve(std::ifstream& fIn, G4bool ascii)
94 {
95  G4bool success = G4PhysicsVector::Retrieve(fIn, ascii);
96  if (success)
97  {
98  G4double theEmin = binVector[0];
99  dBin = std::log(binVector[1]/theEmin);
100  baseBin = std::log(theEmin)/dBin;
101  }
102  return success;
103 }
104 
106 {
107  G4PhysicsVector::ScaleVector(factorE, factorV);
108  G4double theEmin = binVector[0];
109  dBin = std::log(binVector[1]/theEmin);
110  baseBin = std::log(theEmin)/dBin;
111 }
112 
114 {
115 
116  // For G4PhysicsLnVector, FindBinLocation is implemented using
117  // a simple arithmetic calculation.
118  //
119  // Because this is a virtual function, it is accessed through a
120  // pointer to the G4PhyiscsVector object for most usages. In this
121  // case, 'inline' will not be invoked. However, there is a possibility
122  // that the user access to the G4PhysicsLnVector object directly and
123  // not through pointers or references. In this case, the 'inline' will
124  // be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
125 
126  return size_t( std::log(theEnergy)/dBin - baseBin );
127 }