G4InuclSpecialFunctions.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 // $Id$
00027 //
00028 // 20100114  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
00029 // 20100914  M. Kelsey -- Migrate to integer A and Z.  Discard pointless
00030 //              verbosity.
00031 // 20120608  M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
00032 
00033 #include <cmath>
00034 
00035 #include "G4InuclSpecialFunctions.hh"
00036 #include "G4PhysicalConstants.hh"
00037 #include "G4LorentzVector.hh"
00038 #include "G4ThreeVector.hh"
00039 #include "Randomize.hh"
00040 
00041 
00042 G4double G4InuclSpecialFunctions::getAL(G4int A) {
00043   return 0.76 + 2.2 / G4cbrt(A);
00044 }
00045 
00046 G4double G4InuclSpecialFunctions::csNN(G4double e) {
00047   G4double snn;
00048 
00049   if (e < 40.0) {
00050     snn = -1174.8 / (e * e) + 3088.5 / e + 5.3107;
00051   } else {
00052     snn = 93074.0 / (e * e) - 11.148 / e + 22.429;
00053   }
00054 
00055   return snn; 
00056 }
00057 
00058 G4double G4InuclSpecialFunctions::csPN(G4double e) {
00059   G4double spn;
00060 
00061   if (e < 40.0) {
00062     spn = -5057.4 / (e * e) + 9069.2 / e + 6.9466;
00063   } else {
00064     spn = 239380.0 / (e * e) + 1802.0 / e + 27.147;
00065   }
00066 
00067   return spn; 
00068 }
00069 
00070 // calculates the nuclei Fermi energy for 0 - neutron and 1 - proton
00071 
00072 G4double G4InuclSpecialFunctions::FermiEnergy(G4int A, G4int Z, G4int ntype) {
00073   const G4double C = 55.4;
00074   G4double arg = (ntype==0) ? G4double(A-Z)/A : G4double(Z)/A;
00075 
00076   return C * G4cbrt(arg*arg);   // 2/3 power
00077 }
00078 
00079 G4double G4InuclSpecialFunctions::G4cbrt(G4double x) {
00080   return x==0 ? 0. : (x<0?-1.:1.)*std::exp(std::log(std::fabs(x))/3.);
00081 }
00082 
00083 G4double G4InuclSpecialFunctions::inuclRndm() { 
00084   return G4UniformRand(); 
00085 } 
00086 
00087 G4double G4InuclSpecialFunctions::randomGauss(G4double sigma) {
00088   const G4double eps = 1.0e-6;
00089   G4double r1 = inuclRndm();
00090   r1 = r1 > eps ? r1 : eps;
00091   G4double r2 = inuclRndm();
00092   r2 = r2 > eps ? r2 : eps;
00093   r2 = r2 < 1.0 - eps ? r2 : 1.0 - eps; 
00094 
00095   return sigma * std::sin(twopi * r1) * std::sqrt(-2.0 * std::log(r2)); 
00096 } 
00097 
00098 G4double G4InuclSpecialFunctions::randomPHI() { 
00099   return twopi * inuclRndm();
00100 } 
00101 
00102 std::pair<G4double, G4double> G4InuclSpecialFunctions::randomCOS_SIN() {
00103   G4double CT = 1.0 - 2.0 * inuclRndm();
00104 
00105   return std::pair<G4double, G4double>(CT, std::sqrt(1.0 - CT*CT));
00106 }
00107 
00108 G4LorentzVector 
00109 G4InuclSpecialFunctions::generateWithFixedTheta(G4double ct, G4double p, 
00110                                                 G4double mass) {
00111   G4double phi = randomPHI();
00112   G4double pt = p * std::sqrt(std::fabs(1.0 - ct * ct));
00113 
00114   static G4ThreeVector pvec;    // Buffers to avoid memory thrashing
00115   static G4LorentzVector momr;
00116 
00117   pvec.set(pt*std::cos(phi), pt*std::sin(phi), p*ct);
00118   momr.setVectM(pvec, mass);
00119 
00120   return momr;
00121 }
00122 
00123 G4LorentzVector 
00124 G4InuclSpecialFunctions::generateWithRandomAngles(G4double p, G4double mass) {
00125   std::pair<G4double, G4double> COS_SIN = randomCOS_SIN();
00126   G4double phi = randomPHI();
00127   G4double pt = p * COS_SIN.second;
00128   
00129   static G4ThreeVector pvec;    // Buffers to avoid memory thrashing
00130   static G4LorentzVector momr;
00131 
00132   pvec.set(pt*std::cos(phi), pt*std::sin(phi), p*COS_SIN.first);
00133   momr.setVectM(pvec, mass);
00134 
00135   return momr;
00136 }

Generated on Mon May 27 17:48:39 2013 for Geant4 by  doxygen 1.4.7