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

Photin.h

Go to the documentation of this file.
00001 // -*- C++ -*-  $Id: Photin.h,v 1.1 2000/09/01 20:20:17 burnett Exp $
00002 //
00003 // This file is part of Gismo 2
00004 
00005 #ifndef __PHOTIN_H
00006 #define __PHOTIN_H
00007 
00008 #include "facilities/error.h"
00009 
00010 #include <iostream>
00011 #include <strstream>
00012 
00013 #include <cmath>
00014 class Photin  // photon cross sections in this material
00015 {
00016    friend class PEGSData;
00017 public:
00018 
00019     ~Photin();
00020     // dtor
00021         
00022    float rsct(float xxx)const;
00023    // Rayleigh scattering angle function.
00024 
00025 private:
00026    float ebinda;   // K edge energy (used in routine photo)
00027 
00028     float volatile eold;   // last energy (in MeV)
00029     float volatile loge;   // log of E
00030     int   volatile index;  // index
00031 
00032     float ge0, ge1;  // interpolating constants
00033 
00034     int   mge;  // length of following arrays
00035     float *gmfp0, *gmfp1,
00036          *gbr10, *gbr11,
00037          *gbr20, *gbr21,
00038          *cohe0, *cohe1;
00039 
00040     Photin():mge(0){eold = -1.;} // constructor
00041 
00042     // calculate new index if energy changes
00043     void updateIndex(float enew) const
00044     {  if (enew == eold) return;
00045 #if 1
00046         Photin * self = const_cast<Photin*>(this);
00047         self->loge = log(enew);  // convert to MeV
00048         self->index= (int)(ge1*loge + ge0 -1); // note -1 for C arrays
00049         if (index>=mge) {
00050             std::ostrstream msg;
00051             msg << "Photin: photon energy, " << enew
00052                 << "MeV, index "<< index << ", exceeds ap, mge= " << mge << '\0';
00053             FATAL(msg.str());
00054         }
00055         self->eold = enew;
00056 #else // use volatile
00057       loge = log(enew);  // convert to MeV
00058       index= (int)(ge1*loge + ge0 -1); // note -1 for C arrays
00059       if (index>=mge)
00060       {
00061           FATAL("Photin: photon energy exceeds parameter ap");
00062       }
00063       eold = enew;
00064 #endif
00065    }
00066    // the interpolating functions (should have designed a macro)
00067 
00068    float  gmfp()const{return  gmfp1[index]*loge + gmfp0[index];}
00069    float  gbr1()const{return  gbr11[index]*loge + gbr10[index];}
00070    float  gbr2()const{return  gbr21[index]*loge + gbr20[index];}
00071    float  cohe()const{return  cohe1[index]*loge + cohe0[index];}
00072 
00073    float rco0, rco1;
00074 
00075    int   ngr;   // length of following table
00076    float *rsct0, *rsct1;
00077 
00078 
00079    void readPEGS(std::istream&, int, int);
00080    void rescale(float);
00081 
00082 };
00083 
00084 #endif
00085 

Generated at Wed Nov 21 12:20:26 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000