Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PiData.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// GEANT4 tag $Name: not supported by cvs2svn $
27//
28// --------------------------------------------------------------------
29// by J.P Wellisch, Sun Sep 15 2002.
30
31#include "G4PiData.hh"
32#include "G4SystemOfUnits.hh"
34
35///////////////////////////////////////////////////////////////////////
36
37G4PiData::G4PiData(const G4double * aT, const G4double * aIn,
38 const G4double * anE, G4int nP)
39{
40 G4int i=0;
41
42 for( i = 0; i < nP; i++ )
43 {
44 std::pair<G4double, G4double> x;
45 x.first=aT[i]*millibarn;
46 x.second=aIn[i]*millibarn;
47 std::pair<G4double, std::pair<G4double, G4double > > aP;
48 aP.first=anE[i]*GeV;
49 aP.second=x;
50 push_back(aP);
51 }
52}
53
54////////////////////////////////////////////////////////////////////////
55
57{
58 G4bool result = true;
59 if(kineticEnergy>back().first) result = false;
60 return result;
61}
62
63//////////////////////////////////////////////////////////////////////////
64
66{
67 G4double result = 0;
68 G4PiData::iterator it=begin();
69 while(it!=end()&&kineticEnergy>(*it).first) {it++;}
70 if(it==end())
71 {
72 throw G4HadronicException(__FILE__, __LINE__,
73 "G4PiData::ReactionXSection: used outside validity range");
74 }
75 if(it==begin()) it++;
76 G4double x1,x2,e1,e2;
77 e1=(*(it-1)).first;
78 x1=(*(it-1)).second.second;
79 e2=(*(it)).first;
80 x2=(*(it)).second.second;
81 result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
82 return result;
83}
84
85////////////////////////////////////////////////////////////////////////////
86
88{
89 G4double result = 0;
90 G4PiData::iterator it=begin();
91 while(it!=end()&&kineticEnergy>(*it).first) {it++;}
92 if(it==end())
93 {
94 throw G4HadronicException(__FILE__, __LINE__,
95 "G4PiData::ElasticXSection: used outside validity range");
96 }
97 if(it==begin()) it++;
98 G4double x1,x2,e1,e2;
99 e1=(*(it-1)).first;
100 x1=(*(it-1)).second.first - (*(it-1)).second.second;
101 e2=(*(it)).first;
102 x2=(*(it)).second.first - (*(it)).second.second;
103 result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
104 return result;
105}
106
107////////////////////////////////////////////////////////////////////////////
108
110{
111 G4double result = 0;
112 G4PiData::iterator it=begin();
113 while(it!=end()&&kineticEnergy>(*it).first) {it++;}
114 if(it==end())
115 {
116 throw G4HadronicException(__FILE__, __LINE__,
117 "G4PiData::TotalXSection: used outside validity range");
118 }
119 if(it==begin()) it++;
120 G4double x1,x2,e1,e2;
121 e1=(*(it-1)).first;
122 x1=(*(it-1)).second.first;
123 e2=(*(it)).first;
124 x2=(*(it)).second.first;
125 result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
126 return result;
127}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4double ReactionXSection(G4double kineticEnergy)
Definition: G4PiData.cc:65
G4PiData(const G4double *aTotal, const G4double *aInelastic, const G4double *anEnergy, G4int nPoints)
Definition: G4PiData.cc:37
G4bool AppliesTo(G4double kineticEnergy)
Definition: G4PiData.cc:56
G4double TotalXSection(G4double kineticEnergy)
Definition: G4PiData.cc:109
G4double ElasticXSection(G4double kineticEnergy)
Definition: G4PiData.cc:87