source: trunk/source/global/management/include/G4LPhysicsFreeVector.icc @ 835

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

import all except CVS

File size: 5.0 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: G4LPhysicsFreeVector.icc,v 1.7 2006/06/29 19:02:10 gunter Exp $
28// GEANT4 tag $Name: geant4-09-01-patch-02 $
29//
30//
31// ------------------------------------------------------------------
32//
33// Class G4LPhysicsFreeVector -- source file
34//
35// Derived from base class G4PhysicsVector
36// This is a free vector for Low Energy Physics cross section data.
37// The class name includes an "L" to distinguish it from other groups
38// who may wish to implement a free vector in a different way.
39// A subdivision method is used to find the energy|momentum bin.
40//
41// F.W. Jones, TRIUMF, 04-JUN-96
42// --------------------------------------------------------------------------
43
44// G4PhysicsVector has PutValue() but it is inconvenient.
45// Want to simultaneously fill the bin and data vectors.
46
47inline
48void G4LPhysicsFreeVector::PutValues(size_t binNumber,
49                                     G4double binValue, G4double dataValue)
50{
51   binVector[binNumber] = binValue;
52   dataVector[binNumber] = dataValue;
53}
54
55// Note that theEnergy could be energy, momentum, or whatever.
56// Note: GetValue() is no longer virtual in the parent class
57// G4PhysicsVector, so at present the following function cannot
58// be called through a base class pointer.
59
60inline
61G4double G4LPhysicsFreeVector::GetValue(G4double theEnergy, G4bool& isOutRange)
62{
63   G4double returnValue = 0.;
64
65   //   verboseLevel = 2;
66
67   if (theEnergy < edgeMin)
68   {
69      isOutRange = true;
70
71#ifdef G4VERBOSE
72      if (verboseLevel > 1)
73      {
74         G4cout << "G4LPhysicsFreeVector::GetValue " << theEnergy
75                << " " << dataVector[0] << " " << isOutRange << G4endl;
76      }
77#endif
78      returnValue = dataVector[0];
79   }
80   else if (theEnergy > edgeMax)
81   {
82      isOutRange = true;
83
84#ifdef G4VERBOSE
85      if (verboseLevel > 1)
86      {
87         G4cout << "G4LPhysicsFreeVector::GetValue " << theEnergy
88                << " " << dataVector[numberOfBin - 1]
89                << " " << isOutRange << G4endl;
90      }
91#endif
92      returnValue = dataVector[numberOfBin - 1];
93   }
94   else
95   {
96     isOutRange = false;
97
98     G4int n = FindBinLocation(theEnergy);
99
100     G4double dsde = (dataVector[n + 1] - dataVector[n])/
101                     (binVector[n + 1] - binVector[n]);
102#ifdef G4VERBOSE
103     if (verboseLevel > 1)
104     {
105        G4cout << "G4LPhysicsFreeVector::GetValue " << theEnergy
106               << " " << dataVector[n] + (theEnergy - binVector[n])*dsde
107               << " " << isOutRange << G4endl;
108     }
109#endif
110     returnValue = dataVector[n] + (theEnergy - binVector[n])*dsde;
111   }
112   return returnValue;
113}                                                                 
114
115inline
116void G4LPhysicsFreeVector::SetVerboseLevel(G4int value)
117{
118   verboseLevel = value;
119}
120
121inline
122G4int G4LPhysicsFreeVector::GetVerboseLevel(G4int)
123{
124   return verboseLevel;
125}
126
127inline
128G4double G4LPhysicsFreeVector::GetLastEnergy()
129{
130   return lastEnergy;
131}
132
133inline
134size_t G4LPhysicsFreeVector::GetLastBin()
135{
136   return lastBin;
137}
138
139inline
140size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
141{
142   G4int n1 = 0;
143   G4int n2 = numberOfBin/2;
144   G4int n3 = numberOfBin - 1;
145   while (n1 != n3 - 1)
146   {
147      if (theEnergy > binVector[n2])
148         { n1 = n2; }
149      else
150         { n3 = n2; }
151      n2 = n1 + (n3 - n1 + 1)/2;
152   }
153#ifdef G4VERBOSE
154   if (verboseLevel > 1)
155   {
156     G4cout << "G4LPhysicsFreeVector::FindBinLocation:  returning "
157            << n1 << G4endl;
158   }
159#endif
160   return (size_t)n1;
161}
Note: See TracBrowser for help on using the repository browser.