Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PhysicsFreeVector.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: G4PhysicsFreeVector.cc 74256 2013-10-02 14:24:02Z gcosmo $
28 //
29 //
30 //--------------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // G4PhysicsFreeVector.cc
34 //
35 // History:
36 // 02 Dec. 1995, G.Cosmo : Structure created based on object model
37 // 06 June 1996, K.Amako : The 1st version of implemented
38 // 01 Jul. 1996, K.Amako : Cache mechanism and hidden bin from the
39 // 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
42 // 19 Jun. 2009, V.Ivanchenko : removed hidden bin
43 //
44 //--------------------------------------------------------------------
45 
46 #include "G4PhysicsFreeVector.hh"
47 
48 
50  : G4PhysicsVector()
51 {
53 }
54 
56  : G4PhysicsVector()
57 {
59  numberOfNodes = theNbin;
60 
61  dataVector.reserve(numberOfNodes);
62  binVector.reserve(numberOfNodes);
63 
64  for (size_t i=0; i<numberOfNodes; i++)
65  {
66  binVector.push_back(0.0);
67  dataVector.push_back(0.0);
68  }
69 }
70 
72  const G4DataVector& theDataVector)
73 {
75  numberOfNodes = theBinVector.size();
76 
77  dataVector.reserve(numberOfNodes);
78  binVector.reserve(numberOfNodes);
79 
80  for (size_t i=0; i<numberOfNodes; i++)
81  {
82  binVector.push_back(theBinVector[i]);
83  dataVector.push_back(theDataVector[i]);
84  }
85 
86  edgeMin = binVector[0];
87  edgeMax = binVector[numberOfNodes-1];
88 }
89 
91 {
92 }
93 
94 void G4PhysicsFreeVector::PutValue( size_t theBinNumber,
95  G4double theBinValue,
96  G4double theDataValue )
97 {
98  binVector[theBinNumber] = theBinValue;
99  dataVector[theBinNumber] = theDataValue;
100 
101  if( theBinNumber == numberOfNodes-1 )
102  {
104  }
105 
106  if( theBinNumber == 0 )
107  {
108  edgeMin = binVector[0];
109  }
110 }
111 /*
112 size_t G4PhysicsFreeVector::FindBinLocation(G4double theEnergy) const
113 {
114  // For G4PhysicsFreeVector, FindBinLocation is implemented using
115  // the binary search algorithm.
116  //
117  // Because this is a virtual function, it is accessed through a
118  // pointer to the G4PhysicsVector object for most usages. In this
119  // case, 'inline' will not be invoked. However, there is a possibility
120  // that the user access to the G4PhysicsFreeVector object directly and
121  // not through pointers or references. In this case, the 'inline' will
122  // be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
123 
124  size_t lowerBound = 0;
125  size_t upperBound = numberOfNodes-2;
126 
127  while (lowerBound <= upperBound)
128  {
129  size_t midBin = (lowerBound + upperBound)/2;
130  if( theEnergy < binVector[midBin] )
131  { upperBound = midBin-1; }
132  else
133  { lowerBound = midBin+1; }
134  }
135 
136  return upperBound;
137 }
138 */
G4PVDataVector dataVector
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
G4PVDataVector binVector
G4PhysicsVectorType type
double G4double
Definition: G4Types.hh:76