ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PiData.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4PiData.cc
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 
34 
35 G4PiData::G4PiData(const G4double * aT, const G4double * aIn,
36  const G4double * anE, G4int nP)
37 {
38  G4int i=0;
39 
40  for( i = 0; i < nP; i++ )
41  {
42  std::pair<G4double, G4double> x;
43  x.first=aT[i]*millibarn;
44  x.second=aIn[i]*millibarn;
45  std::pair<G4double, std::pair<G4double, G4double > > aP;
46  aP.first=anE[i]*GeV;
47  aP.second=x;
48  push_back(aP);
49  }
50 }
51 
53 
55 {
56  return (kineticEnergy<=back().first);
57 }
58 
60 
62 {
63  G4double result = 0;
64  G4PiData::iterator it=begin();
65  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
66  if(it==end())
67  {
69  ed << "This cross section is applied for E(MeV)= " << kineticEnergy
70  << " outside allowed energy interval" << G4endl;
71  G4Exception("G4PiData::ReactionXSection", "had001", FatalException, ed);
72  }
73  if(it==begin()) it++;
74  G4double x1,x2,e1,e2;
75  e1=(*(it-1)).first;
76  x1=(*(it-1)).second.second;
77  e2=(*(it)).first;
78  x2=(*(it)).second.second;
79  result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
80  return result;
81 }
82 
84 
86 {
87  G4double result = 0;
88  G4PiData::iterator it=begin();
89  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
90  if(it==end())
91  {
93  ed << "This cross section is applied for E(MeV)= " << kineticEnergy
94  << " outside allowed energy interval" << G4endl;
95  G4Exception("G4PiData::ElasticXSection", "had001", FatalException, ed);
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 
108 
110 {
111  G4double result = 0;
112  G4PiData::iterator it=begin();
113  while(it!=end()&&kineticEnergy>(*it).first) {it++;} /* Loop checking, 08.01.2016, W. Pokorski */
114  if(it==end())
115  {
117  ed << "This cross section is applied for E(MeV)= " << kineticEnergy
118  << " outside allowed energy interval" << G4endl;
119  G4Exception("G4PiData::TotalXSection", "had001", FatalException, ed);
120  }
121  if(it==begin()) it++;
122  G4double x1,x2,e1,e2;
123  e1=(*(it-1)).first;
124  x1=(*(it-1)).second.first;
125  e2=(*(it)).first;
126  x2=(*(it)).second.first;
127  result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
128  return result;
129 }