source: trunk/source/global/management/src/G4PhysicsFreeVector.cc @ 833

Last change on this file since 833 was 833, checked in by garnier, 16 years ago

import all except CVS

File size: 5.1 KB
Line 
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,v 1.10 2006/06/29 19:04:10 gunter Exp $
28// GEANT4 tag $Name:  $
29//
30//
31//--------------------------------------------------------------------
32//      GEANT 4 class implementation file
33//
34//  G4PhysicsFreeVector.cc
35//
36//  History:
37//    02 Dec. 1995, G.Cosmo : Structure created based on object model
38//    06 June 1996, K.Amako : The 1st version of implemented
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//
44//--------------------------------------------------------------------
45
46#include "G4PhysicsFreeVector.hh"
47
48
49G4PhysicsFreeVector::G4PhysicsFreeVector()
50{
51  edgeMin = 0.0;
52  edgeMax = 0.0;
53  numberOfBin = 0;
54  type = T_G4PhysicsFreeVector;
55}
56
57
58G4PhysicsFreeVector::G4PhysicsFreeVector(size_t theNbin)
59{
60  type = T_G4PhysicsFreeVector;
61  numberOfBin = theNbin;
62
63  // Add extra one bin (hidden to user) to handle correctly when
64  // Energy=theEmax in getValue.
65  dataVector.reserve(numberOfBin+1);
66  binVector.reserve(numberOfBin+1);
67
68  for (size_t i=0; i<=numberOfBin; i++)
69  {
70     binVector.push_back(0.0);
71     dataVector.push_back(0.0);
72  }
73
74  edgeMin = 0.;
75  edgeMax = 0.;
76
77  lastBin = INT_MAX;
78  lastEnergy = -DBL_MAX;
79  lastValue = DBL_MAX;
80} 
81
82
83G4PhysicsFreeVector::G4PhysicsFreeVector(const G4DataVector& theBinVector, 
84                                         const G4DataVector& theDataVector)
85{
86  type = T_G4PhysicsFreeVector;
87  numberOfBin = theBinVector.size();
88
89  // Add extra one bin (hidden to user) to handle correctly when
90  // Energy=theEmax in getValue.
91  dataVector.reserve(numberOfBin+1);
92  binVector.reserve(numberOfBin+1);
93
94  for (size_t i=0; i<numberOfBin; i++)
95  {
96     binVector.push_back(theBinVector[i]);
97     dataVector.push_back(theDataVector[i]);
98  }
99
100  // Put values to extra hidden bin. For 'binVector', the 'edgeMin' of the
101  // extra hidden bin is assumed to have the following value. For binary
102  // search, this value is completely arbitrary if it is greater than
103  // the 'edgeMin' at 'numberOfBin-1'.
104  binVector.push_back ( theBinVector[numberOfBin-1] + 1.0 );
105
106
107  // Put values to extra hidden bin. For 'dataVector', the 'value' of the
108  // extra hidden bin is assumed to have the same as the one at 'numberBin-1'.
109  dataVector.push_back( theDataVector[numberOfBin-1] );
110
111  edgeMin = binVector[0];
112  edgeMax = binVector[numberOfBin-1];
113
114  lastBin = INT_MAX;
115  lastEnergy = -DBL_MAX;
116  lastValue = DBL_MAX;
117} 
118
119
120G4PhysicsFreeVector::~G4PhysicsFreeVector(){}
121
122
123void G4PhysicsFreeVector::PutValue( size_t theBinNumber, G4double theBinValue, 
124                                    G4double theDataValue )
125{
126  binVector[theBinNumber]  = theBinValue;
127  dataVector[theBinNumber] = theDataValue;
128
129  if( theBinNumber == numberOfBin-1 )
130  {
131     edgeMax = binVector[numberOfBin-1];
132
133     // Put values to extra hidden bin. For 'binVector', the 'edgeMin'
134     // of the extra hidden bin is assumed to have the following value.
135     // For binary search, this value is completely arbitrary if it is
136     // greater than the 'edgeMin' at 'numberOfBin-1'.
137     binVector[numberOfBin] = theBinValue + 1.0;
138
139     // Put values to extra hidden bin. For 'dataVector', the 'value'
140     // of the extra hidden bin is assumed to have the same as the one
141     // at 'numberBin-1'.
142     dataVector[numberOfBin] = theDataValue;
143  }
144
145  if( theBinNumber == 0 )
146  {
147     edgeMin = binVector[0];
148  }
149}
Note: See TracBrowser for help on using the repository browser.