| 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 | #ifndef G4CrossSectionBuffer_h
|
|---|
| 27 | #define G4CrossSectionBuffer_h
|
|---|
| 28 |
|
|---|
| 29 | #include "G4ParticleDefinition.hh"
|
|---|
| 30 | #include "globals.hh"
|
|---|
| 31 | #include <utility>
|
|---|
| 32 | #include <vector>
|
|---|
| 33 |
|
|---|
| 34 | class G4CrossSectionBuffer
|
|---|
| 35 | {
|
|---|
| 36 | public:
|
|---|
| 37 |
|
|---|
| 38 | G4CrossSectionBuffer(const G4ParticleDefinition * aA, const G4ParticleDefinition * aB)
|
|---|
| 39 | : theA(aA), theB(aB) {}
|
|---|
| 40 |
|
|---|
| 41 | G4bool InCharge(const G4ParticleDefinition * aA, const G4ParticleDefinition * aB) const
|
|---|
| 42 | {
|
|---|
| 43 | G4bool result = false;
|
|---|
| 44 | if(aA == theA)
|
|---|
| 45 | {
|
|---|
| 46 | if(aB == theB) result = true;
|
|---|
| 47 | }
|
|---|
| 48 | else if(aA == theB)
|
|---|
| 49 | {
|
|---|
| 50 | if(aB == theA) result = true;
|
|---|
| 51 | }
|
|---|
| 52 | return result;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | void push_back(G4double s, G4double x)
|
|---|
| 56 | {
|
|---|
| 57 | std::pair<G4double, G4double> aNew;
|
|---|
| 58 | aNew.first = s;
|
|---|
| 59 | aNew.second = x;
|
|---|
| 60 | theData.push_back(aNew);
|
|---|
| 61 | }
|
|---|
| 62 | G4double CrossSection(const G4KineticTrack& trk1, const G4KineticTrack& trk2) const
|
|---|
| 63 | {
|
|---|
| 64 | G4double sqrts = (trk1.Get4Momentum()+trk2.Get4Momentum()).mag();
|
|---|
| 65 | G4double x1(1), y1(0);
|
|---|
| 66 | G4double x2(2), y2(0);
|
|---|
| 67 |
|
|---|
| 68 | if(theData.size()==1) return theData[theData.size()-1].second;
|
|---|
| 69 |
|
|---|
| 70 | for(size_t i=0; i<theData.size(); i++)
|
|---|
| 71 | {
|
|---|
| 72 | if(theData[i].first>sqrts)
|
|---|
| 73 | {
|
|---|
| 74 | if(0==i)
|
|---|
| 75 | {
|
|---|
| 76 | x1 = theData[i].first;
|
|---|
| 77 | y1 = theData[i].second;
|
|---|
| 78 | x2 = theData[i+1].first;
|
|---|
| 79 | y2 = theData[i+1].second;
|
|---|
| 80 | }
|
|---|
| 81 | else if(theData.size()-1==i)
|
|---|
| 82 | {
|
|---|
| 83 | x1 = theData[theData.size()-2].first;
|
|---|
| 84 | y1 = theData[theData.size()-2].second;
|
|---|
| 85 | x2 = theData[theData.size()-1].first;
|
|---|
| 86 | y2 = theData[theData.size()-1].second;
|
|---|
| 87 | }
|
|---|
| 88 | else
|
|---|
| 89 | {
|
|---|
| 90 | x1 = theData[i-1].first;
|
|---|
| 91 | y1 = theData[i-1].second;
|
|---|
| 92 | x2 = theData[i].first;
|
|---|
| 93 | y2 = theData[i].second;
|
|---|
| 94 | }
|
|---|
| 95 | break;
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 | // LINLIN interpolation
|
|---|
| 99 | // G4cerr << "!!!!!! "<<sqrts<<" "<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<" "<<i<<G4endl;
|
|---|
| 100 | G4double result = y1 + (sqrts-x1) * (y2-y1)/(x2-x1);
|
|---|
| 101 | if(result<0) result = 0;
|
|---|
| 102 | if(y1<0.01*millibarn) result = 0;
|
|---|
| 103 | return result;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | void Print()
|
|---|
| 107 | {
|
|---|
| 108 | for(size_t i=0;i<theData.size(); i++)
|
|---|
| 109 | {
|
|---|
| 110 | G4cerr << "sqrts = "<<theData[i].first<<", X = "<<theData[i].second/millibarn<<G4endl;
|
|---|
| 111 | }
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | private:
|
|---|
| 115 | std::vector<std::pair<G4double, G4double> > theData;
|
|---|
| 116 |
|
|---|
| 117 | const G4ParticleDefinition * theA;
|
|---|
| 118 | const G4ParticleDefinition * theB;
|
|---|
| 119 | };
|
|---|
| 120 |
|
|---|
| 121 | #endif
|
|---|