Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

PEGSData.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/gismo/src/egs/PEGSData.cxx,v 1.1 2000/09/01 20:20:15 burnett Exp $
00002 //
00003 // This file is part of Gismo 2
00004 
00005 
00006 #include "PEGSData.h"
00007 
00008 #include "facilities/error.h"
00009 #include <string.h>
00010 #include <stdlib.h>
00011 #include <iomanip>
00012 #include <strstream>
00013 
00014 void
00015 PEGSData::read(std::istream& fin, Material& mat)
00016 {
00017    char linebuf[101];
00018    iraylm = irayl;      // set local Rayleigh flag from current static
00019 
00020    // initialize data for bremsstrahlung production
00021    // the quantity zbrang is ( (1/111)*zeff**(1/3) )**2
00022    // where zeff is defined in equation (7) of pirs0203
00023 
00024     zbrang = 0.0;
00025     double pznorm=0.0;
00026 
00027     for( Material::Element_list::iterator pel= mat.elementList.begin();
00028             pel != mat.elementList.end(); ++pel) {
00029         const Material::AtomicElement* tel = *pel;
00030         zbrang += tel->pz*tel->z*(tel->z+1.0);
00031         pznorm += tel->pz;
00032     }
00033 
00034    zbrang = 8.116224E-05 * pow(zbrang/pznorm , 1./3.);
00035 
00036    // read media and thresh
00037 //   float rlc;
00038 //   fin >> rlc ;
00039 //   mat.setRadiationLength(rlc);
00040 
00041    fin>> ae >> ap >> ue >> up;
00042 #if 0
00043    cout << "Ae="<<ae<<", Ap="<<ap<<", ue="<<ue<<", up="<<up<<'\n';
00044 #endif
00045    te = ae-rm;
00046    thmoll = 2.*te+rm;
00047 
00048    // array sizes from PEGS
00049    int iray1=0, mseke, meke, mleke, mcmfp, mrange;
00050    int msge, mge;
00051    fin >> msge >> mge
00052        >> mseke>> meke >> mleke >> mcmfp >> mrange  >> iray1;
00053 
00054    if( iray1==0 && iraylm ) {
00055        iraylm = 0;
00056 #if 0  // this message is generated in the original
00057        std::ostrstream message;
00058        message << "PEGSData::read -- no Rayleigh data for material \'"
00059            << mat.name() << "\'" << '\0';
00060        WARNING(message.str());
00061 #endif
00062    }
00063 
00064    fin.getline(linebuf,100);   // skip rest of line
00065 
00066    bp.readPEGS(fin);         // read brempr data
00067 
00068    el.readPEGS(fin, meke);   //read electin data
00069 
00070    ph.readPEGS(fin, mge, iray1);  // read photin data
00071 
00072    // change to given distance units
00073 
00074    rldu   = mat.radiationLength()/dunit;
00075    el.rescale(rldu);        //converts rl to dunits
00076    ph.rescale(rldu);
00077 
00078    el.fixtmx(estepe);         // apply low E correction to tmxs
00079 }
00080 
00081 // --------------- member function PEGSData::meanFreePath ----------
00082 
00083 float PEGSData::meanFreePath(float e, int iq) const
00084 {
00085     switch (iq)    {
00086         case -1: return (e>ae)? 1.0 / esig(e-rm) : 0;
00087         case  1: return (e>ae)? 1.0 / psig(e-rm) : 0;
00088         default:  {
00089             if( e<=ap ) return 0;
00090             float mfp = gmfp(e);
00091             if( iraylm ) mfp *= cohe(e);
00092             return mfp;
00093         }
00094     }
00095 }
00096 
00097 // --------------- member function PEGSData::dedx -----------------------
00098 
00099 float PEGSData::dedx(float e, int iq) const
00100 {   switch (iq)
00101 
00102     { case -1: return ededx(e-rm);
00103       case  1: return pdedx(e-rm);
00104       default: return 0.;
00105     }
00106 }
00107 
00108 // --------------- member function PEGSData::chooseChannel -----------------------
00109 
00110 PEGSData::channel
00111 PEGSData::chooseChannel(float rnno, float e, int iq) const
00112 {
00113 
00114     switch (iq)
00115     {
00116       case -1:    //electron
00117         if (e<=ae)                 return STOP;             //stop
00118         if     (rnno <=ebr1(e-rm)) return BREMS;
00119         else                       return MOLLER;  //e- -> e- + e-
00120 
00121       case 1:    // positron
00122         if     (e<=ae || ae==0)    return ANNIH;   //e+ => gamma+gamma at rest
00123         else if(rnno <=pbr1(e-rm)) return BREMS;   //e+ -> e+ + gamma
00124         else if(rnno < pbr2(e-rm)) return BHABHA;  //e+ -> e+ + e-
00125         else                       return ANNIH;   //e+ -> gamma+gamma
00126 
00127       default:    // photon
00128 
00129 
00130         if( iraylm ) {
00131             // rayleigh-scattering option: cohe(e) is the probability to not scatter
00132             float cohfac = cohe(e);
00133             if( rnno <= (1.0-cohfac) )  return RAYLEIGH;  // gamma -> gamma
00134             // didn't scatter: rescale rnno to the range (0,1]
00135             rnno = (rnno - (1-cohfac))/cohfac;
00136         }
00137         if     (rnno <= gbr1(e))   return PAIR;   //gamma-> e+ + e-
00138         else if(rnno <  gbr2(e))   return COMPT;  //gamma-> gamma + e-
00139         else                       return PHOTO;  //gamma-> e- (+gamma)
00140     }
00141 }
00142 //--------------------------- printing stuff ------------------------------
00143 void
00144 PEGSData::printHead1(std::ostream& out)
00145 {
00146     out << std::setw(58)
00147         << "---------------------------PEGS4 data ----------------------";
00148 }
00149 
00150 void
00151 PEGSData::printHead2(std::ostream& out)
00152 {
00153     out
00154         << std::setw(10) << "rl(cm)"
00155         << std::setw(10) << "ecut(MeV)"
00156         << std::setw(10) << "pcut(Mev)"
00157         << std::setw(10) << "emax(Mev)"
00158         << std::setw(10) << "pmax(Mev)"
00159         << std::setw(8)  << "iraylm"
00160         ;
00161 }
00162 void
00163 PEGSData::printOn(std::ostream& out)
00164 {
00165     out
00166         << std::setw(10) << rl()
00167         << std::setw(10) << ecut()
00168         << std::setw(10) << pcut()
00169         << std::setw(10) << emax()
00170         << std::setw(10) << pmax()
00171         << std::setw(8)  << iraylm
00172         ;
00173 }
00174 
00175 PEGSData::~PEGSData()
00176 {
00177 }
00178 
00179 //  -------------------- allocate static constants ----------------------
00180 
00181 const float PEGSData::dunit = 1.0;  // distance unit in cm
00182 const float PEGSData::rm = 0.511;   // electron Mass in MeV
00183 float PEGSData::estepe=0.50;  // fractional eloss allowed
00184 int PEGSData::irayl=1;        // Rayleigh flag
00185 
00186 
00187 

Generated at Mon Nov 26 18:18:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000