Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
27 // --------------------------------------------------------------------
28 // by J.P Wellisch, Sun Sep 15 2002.
29 
30 #include "G4PiData.hh"
31 #include "G4SystemOfUnits.hh"
32 #include "G4HadronicException.hh"
33 
35 
36 G4PiData::G4PiData(const G4double * aT, const G4double * aIn,
37  const G4double * anE, G4int nP)
38 {
39  G4int i=0;
40 
41  for( i = 0; i < nP; i++ )
42  {
43  std::pair<G4double, G4double> x;
44  x.first=aT[i]*millibarn;
45  x.second=aIn[i]*millibarn;
46  std::pair<G4double, std::pair<G4double, G4double > > aP;
47  aP.first=anE[i]*GeV;
48  aP.second=x;
49  push_back(aP);
50  }
51 }
52 
54 
56 {
57  G4bool result = true;
58  if(kineticEnergy>back().first) result = false;
59  return result;
60 }
61 
63 
65 {
66  G4double result = 0;
67  G4PiData::iterator it=begin();
68  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
69  if(it==end())
70  {
71  throw G4HadronicException(__FILE__, __LINE__,
72  "G4PiData::ReactionXSection: used outside validity range");
73  }
74  if(it==begin()) it++;
75  G4double x1,x2,e1,e2;
76  e1=(*(it-1)).first;
77  x1=(*(it-1)).second.second;
78  e2=(*(it)).first;
79  x2=(*(it)).second.second;
80  result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
81  return result;
82 }
83 
85 
87 {
88  G4double result = 0;
89  G4PiData::iterator it=begin();
90  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
91  if(it==end())
92  {
93  throw G4HadronicException(__FILE__, __LINE__,
94  "G4PiData::ElasticXSection: used outside validity range");
95  }
96  if(it==begin()) it++;
97  G4double x1,x2,e1,e2;
98  e1=(*(it-1)).first;
99  x1=(*(it-1)).second.first - (*(it-1)).second.second;
100  e2=(*(it)).first;
101  x2=(*(it)).second.first - (*(it)).second.second;
102  result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
103  return result;
104 }
105 
107 
109 {
110  G4double result = 0;
111  G4PiData::iterator it=begin();
112  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
113  if(it==end())
114  {
115  throw G4HadronicException(__FILE__, __LINE__,
116  "G4PiData::TotalXSection: used outside validity range");
117  }
118  if(it==begin()) it++;
119  G4double x1,x2,e1,e2;
120  e1=(*(it-1)).first;
121  x1=(*(it-1)).second.first;
122  e2=(*(it)).first;
123  x2=(*(it)).second.first;
124  result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
125  return result;
126 }
G4double G4ParticleHPJENDLHEData::G4double result
G4double TotalXSection(G4double kineticEnergy)
Definition: G4PiData.cc:108
G4double ElasticXSection(G4double kineticEnergy)
Definition: G4PiData.cc:86
G4double ReactionXSection(G4double kineticEnergy)
Definition: G4PiData.cc:64
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4bool AppliesTo(G4double kineticEnergy)
Definition: G4PiData.cc:55
G4PiData(const G4double *aTotal, const G4double *aInelastic, const G4double *anEnergy, G4int nPoints)
Definition: G4PiData.cc:36
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static constexpr double GeV
Definition: G4SIunits.hh:217
double G4double
Definition: G4Types.hh:76
static constexpr double millibarn
Definition: G4SIunits.hh:106