| 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: geant4-09-03-cand-01 $
|
|---|
| 27 | //
|
|---|
| 28 | // --------------------------------------------------------------------
|
|---|
| 29 | // by J.P Wellisch, Sun Sep 15 2002.
|
|---|
| 30 |
|
|---|
| 31 | #include "G4PiData.hh"
|
|---|
| 32 |
|
|---|
| 33 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 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 |
|
|---|
| 52 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 53 |
|
|---|
| 54 | G4bool G4PiData::AppliesTo(G4double kineticEnergy)
|
|---|
| 55 | {
|
|---|
| 56 | G4bool result = true;
|
|---|
| 57 | if(kineticEnergy>back().first) result = false;
|
|---|
| 58 | return result;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | //////////////////////////////////////////////////////////////////////////
|
|---|
| 62 |
|
|---|
| 63 | G4double G4PiData::ReactionXSection(G4double kineticEnergy)
|
|---|
| 64 | {
|
|---|
| 65 | G4double result = 0;
|
|---|
| 66 | G4PiData::iterator it=begin();
|
|---|
| 67 | while(it!=end()&&kineticEnergy>(*it).first) {it++;}
|
|---|
| 68 | if(it==end())
|
|---|
| 69 | {
|
|---|
| 70 | G4Exception("G4PiData", "007", FatalException,
|
|---|
| 71 | "ReactionXSection used outside validity range");
|
|---|
| 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 |
|
|---|
| 83 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 84 |
|
|---|
| 85 | G4double G4PiData::ElasticXSection(G4double kineticEnergy)
|
|---|
| 86 | {
|
|---|
| 87 | G4double result = 0;
|
|---|
| 88 | G4PiData::iterator it=begin();
|
|---|
| 89 | while(it!=end()&&kineticEnergy>(*it).first) {it++;}
|
|---|
| 90 | if(it==end())
|
|---|
| 91 | {
|
|---|
| 92 | G4Exception("G4PiData", "007", FatalException,
|
|---|
| 93 | "ElasticXSection used outside validity range");
|
|---|
| 94 | }
|
|---|
| 95 | if(it==begin()) it++;
|
|---|
| 96 | G4double x1,x2,e1,e2;
|
|---|
| 97 | e1=(*(it-1)).first;
|
|---|
| 98 | x1=(*(it-1)).second.first - (*(it-1)).second.second;
|
|---|
| 99 | e2=(*(it)).first;
|
|---|
| 100 | x2=(*(it)).second.first - (*(it)).second.second;
|
|---|
| 101 | result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
|
|---|
| 102 | return result;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 106 |
|
|---|
| 107 | G4double G4PiData::TotalXSection(G4double kineticEnergy)
|
|---|
| 108 | {
|
|---|
| 109 | G4double result = 0;
|
|---|
| 110 | G4PiData::iterator it=begin();
|
|---|
| 111 | while(it!=end()&&kineticEnergy>(*it).first) {it++;}
|
|---|
| 112 | if(it==end())
|
|---|
| 113 | {
|
|---|
| 114 | G4Exception("G4PiData", "007", FatalException,
|
|---|
| 115 | "ElasticXSection used outside validity range");
|
|---|
| 116 | }
|
|---|
| 117 | if(it==begin()) it++;
|
|---|
| 118 | G4double x1,x2,e1,e2;
|
|---|
| 119 | e1=(*(it-1)).first;
|
|---|
| 120 | x1=(*(it-1)).second.first;
|
|---|
| 121 | e2=(*(it)).first;
|
|---|
| 122 | x2=(*(it)).second.first;
|
|---|
| 123 | result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
|
|---|
| 124 | return result;
|
|---|
| 125 | }
|
|---|