Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LPhysicsFreeVector.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 // Class G4LPhysicsFreeVector
32 // Derived from base class G4PhysicsVector
33 // This is a free vector for Low Energy Physics cross section data
34 //
35 // F.W. Jones, TRIUMF, 04-JUN-96
36 //
37 // Modified:
38 // 19 Jun. 2009, V.Ivanchenko : removed hidden bin
39 //
40 // --------------------------------------------------------------------
41 
42 #include "G4LPhysicsFreeVector.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "G4ios.hh"
45 
46 // --------------------------------------------------------------------
47 
49  : G4PhysicsVector()
50 {
52 }
53 
54 // --------------------------------------------------------------------
55 
57  G4double binmin,
58  G4double binmax)
59  : G4PhysicsVector()
60 {
62 
63  edgeMin = binmin;
64  edgeMax = binmax;
65  numberOfNodes = nbin;
66  binVector.reserve(numberOfNodes);
67  dataVector.reserve(numberOfNodes);
68  for (size_t i=0; i<numberOfNodes; i++)
69  {
70  binVector.push_back(0.0);
71  dataVector.push_back(0.0);
72  }
73 }
74 
75 // --------------------------------------------------------------------
76 
78 {
79 }
80 
81 // --------------------------------------------------------------------
82 
84 {
85  for (size_t i = 0; i < numberOfNodes; i++)
86  {
87  G4cout << binVector[i] << " " << dataVector[i]/millibarn << G4endl;
88  }
89 }
90 
91 // --------------------------------------------------------------------
92 
93 size_t G4LPhysicsFreeVector::FindBinLocation(G4double theEnergy) const
94 {
95  G4int n1 = 0;
96  G4int n2 = numberOfNodes/2;
97  G4int n3 = numberOfNodes - 1;
98  while (n1 != n3 - 1)
99  {
100  if (theEnergy > binVector[n2])
101  { n1 = n2; }
102  else
103  { n3 = n2; }
104  n2 = n1 + (n3 - n1 + 1)/2;
105  }
106 #ifdef G4VERBOSE
107  if (verboseLevel > 1)
108  {
109  G4cout << "G4LPhysicsFreeVector::FindBinLocation: returning "
110  << n1 << G4endl;
111  }
112 #endif
113  return (size_t)n1;
114 }