G4PiData.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // GEANT4 tag $Name: not supported by cvs2svn $
00027 //
00028 // --------------------------------------------------------------------
00029 // by J.P Wellisch, Sun Sep 15 2002.
00030 
00031 #include "G4PiData.hh"
00032 #include "G4SystemOfUnits.hh"
00033 #include "G4HadronicException.hh"
00034 
00036 
00037 G4PiData::G4PiData(const G4double * aT, const G4double * aIn, 
00038                    const G4double * anE, G4int nP)
00039 {
00040   G4int i=0;
00041 
00042   for( i = 0; i < nP; i++ )
00043   {
00044     std::pair<G4double, G4double> x;
00045     x.first=aT[i]*millibarn;
00046     x.second=aIn[i]*millibarn;
00047     std::pair<G4double, std::pair<G4double, G4double > > aP;
00048     aP.first=anE[i]*GeV;
00049     aP.second=x;
00050     push_back(aP);
00051   }
00052 }
00053 
00055 
00056 G4bool G4PiData::AppliesTo(G4double kineticEnergy)
00057 {
00058   G4bool result = true;
00059   if(kineticEnergy>back().first) result = false;
00060   return result;
00061 }
00062 
00064 
00065 G4double G4PiData::ReactionXSection(G4double kineticEnergy)
00066 {
00067   G4double result = 0;
00068   G4PiData::iterator it=begin();
00069   while(it!=end()&&kineticEnergy>(*it).first) {it++;}
00070   if(it==end()) 
00071   {
00072     throw G4HadronicException(__FILE__, __LINE__,
00073         "G4PiData::ReactionXSection: used outside validity range");
00074   }
00075   if(it==begin()) it++;
00076   G4double x1,x2,e1,e2;
00077   e1=(*(it-1)).first;
00078   x1=(*(it-1)).second.second;
00079   e2=(*(it)).first;
00080   x2=(*(it)).second.second;
00081   result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
00082   return result;
00083 }
00084 
00086 
00087 G4double G4PiData::ElasticXSection(G4double kineticEnergy)
00088 {
00089   G4double result = 0;
00090   G4PiData::iterator it=begin();
00091   while(it!=end()&&kineticEnergy>(*it).first) {it++;}
00092   if(it==end()) 
00093   {
00094     throw G4HadronicException(__FILE__, __LINE__,
00095         "G4PiData::ElasticXSection: used outside validity range");
00096   }
00097   if(it==begin()) it++;
00098   G4double x1,x2,e1,e2;
00099   e1=(*(it-1)).first;
00100   x1=(*(it-1)).second.first - (*(it-1)).second.second;
00101   e2=(*(it)).first;
00102   x2=(*(it)).second.first - (*(it)).second.second;
00103   result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
00104   return result;
00105 }
00106 
00108 
00109 G4double G4PiData::TotalXSection(G4double kineticEnergy)
00110 {
00111   G4double result = 0;
00112   G4PiData::iterator it=begin();
00113   while(it!=end()&&kineticEnergy>(*it).first) {it++;}
00114   if(it==end()) 
00115   {
00116     throw G4HadronicException(__FILE__, __LINE__,
00117         "G4PiData::TotalXSection: used outside validity range");
00118   }
00119   if(it==begin()) it++;
00120   G4double x1,x2,e1,e2;
00121   e1=(*(it-1)).first;
00122   x1=(*(it-1)).second.first;
00123   e2=(*(it)).first;
00124   x2=(*(it)).second.first;
00125   result = std::max(0., x1 + (kineticEnergy-e1)*(x2-x1)/(e2-e1));
00126   return result;
00127 }

Generated on Mon May 27 17:49:20 2013 for Geant4 by  doxygen 1.4.7