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

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

geant4.8.2 beta

File size: 3.6 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.11 2008/09/06 19:52:16 vnivanch Exp $
28// GEANT4 tag $Name: HEAD $
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// 05 Sep. 2008, V.Ivanchenko : added protections for zero-length vector
43// --------------------------------------------------------------------------
44
45inline
46void G4LPhysicsFreeVector::PutValues(size_t binNumber,
47                                     G4double binValue, G4double dataValue)
48  // G4PhysicsVector has PutValue() but it is inconvenient.
49  // Want to simultaneously fill the bin and data vectors.
50{
51  if(binNumber <= numberOfBin) {
52    binVector[binNumber] = binValue;
53    dataVector[binNumber]= dataValue;
54    if(0 == binNumber) edgeMin = binValue;
55    else if( numberOfBin - 1 == binNumber) edgeMax = binValue;
56  }
57}
58
59inline
60void G4LPhysicsFreeVector::SetVerboseLevel(G4int value)
61{
62   verboseLevel = value;
63}
64
65inline
66G4int G4LPhysicsFreeVector::GetVerboseLevel(G4int)
67{
68   return verboseLevel;
69}
70
71inline
72G4double G4LPhysicsFreeVector::GetLastEnergy()
73{
74   return lastEnergy;
75}
76
77inline
78size_t G4LPhysicsFreeVector::GetLastBin()
79{
80   return lastBin;
81}
82
83inline
84size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
85{
86   G4int n1 = 0;
87   G4int n2 = numberOfBin/2;
88   G4int n3 = numberOfBin - 1;
89   while (n1 != n3 - 1)
90   {
91      if (theEnergy > binVector[n2])
92         { n1 = n2; }
93      else
94         { n3 = n2; }
95      n2 = n1 + (n3 - n1 + 1)/2;
96   }
97#ifdef G4VERBOSE
98   if (verboseLevel > 1)
99   {
100     G4cout << "G4LPhysicsFreeVector::FindBinLocation:  returning "
101            << n1 << G4endl;
102   }
103#endif
104   return (size_t)n1;
105}
Note: See TracBrowser for help on using the repository browser.