NdbMTReactionXS.cxx

Go to the documentation of this file.
00001 #include <Riostream.h>
00002 
00003 #include "NdbDefs.h"
00004 #include "NdbEndfIO.h"
00005 #include "NdbMTReactionXS.h"
00006 
00007 ClassImp(NdbMTReactionXS);
00008 
00009 /* -------- LoadENDF -------- */
00010 Bool_t
00011 NdbMTReactionXS::LoadENDF( char *filename )
00012 {
00013         NdbEndfIO       endf(filename,TENDF_READ);
00014         Int_t           za;
00015         Float_t         awr;
00016         Bool_t          error;
00017 
00018         if (!endf.IsOpen()) return kTRUE;
00019 
00020         minxs = MAX_REAL;
00021         maxxs = -MAX_REAL;
00022 
00023         endf.FindMFMT(3,MT());                  // Find total cross section
00024         za  = (int)endf.ReadReal(&error);       // ??
00025         awr = endf.ReadReal(&error);
00026               endf.ReadLine();
00027         QM  = endf.ReadReal(&error);
00028         QI  = endf.ReadReal(&error);
00029              endf.ReadInt(&error);     // Skip number
00030 
00031         LR = endf.ReadInt(&error); if (error) return error;
00032         NR = endf.ReadInt(&error); if (error) return error;
00033         NP = endf.ReadInt(&error); if (error) return error;
00034              endf.ReadLine();          // Skip line
00035 
00036         IT = endf.ReadInt(&error,2);    // Interpolation type
00037         endf.ReadLine();          // Skip line
00038 
00039         ene.Set(NP);
00040         xs.Set(NP);
00041 
00042         for (int i=0; i<NP; i++) {
00043                 Float_t f;
00044                 ene.AddAt(endf.ReadReal(&error), i);
00045                 xs.AddAt( f = endf.ReadReal(&error), i);
00046                 minxs = MIN(minxs,f);
00047                 maxxs = MAX(maxxs,f);
00048         }
00049         return kFALSE;
00050 } // loadENDF
00051 
00052 /* -------- BinSearch -------- */
00053 Int_t
00054 NdbMTReactionXS::BinSearch( Float_t e )
00055 {
00056         Int_t   low = 0;
00057         Int_t   high = NP-1;
00058         Int_t   mid;
00059 
00060         if (e < ene[low])  return NOTFOUND;
00061         if (e > ene[high]) return NOTFOUND;
00062 
00063         while (1) {
00064                 mid = (low+high)/2;
00065                 if (mid==low) return mid;
00066                 if (e > ene[mid])
00067                         low = mid;
00068                 else
00069                 if (e < ene[mid]) 
00070                         high = mid;
00071                 else
00072                         return mid;
00073         }
00074 } // BinSearch
00075 
00076 /* -------- Interpolate -------- */
00077 Float_t
00078 NdbMTReactionXS::Interpolate( Float_t e )
00079 {
00080         Int_t   p = BinSearch(e);
00081 
00082         if (p==NOTFOUND)
00083                 return xs[ e<ene[0]? 0 : NP-1 ];
00084 
00085         if (p==NP-1)
00086                 return xs[p];
00087 
00088         Float_t el = ene[p];
00089         Float_t xl = xs[p];
00090         p++;
00091 
00092         switch (IT) {
00093                 case IT_LINLOG:
00094                         cout << "Linear-Log interpolation" << endl;
00095                         return 0.0;
00096 
00097                 case IT_LOGLIN:
00098                         cout << "Log-Linear interpolation" << endl;
00099                         return 0.0;
00100 
00101                 case IT_LOGLOG:
00102                         cout << "Log-Log interpolation" << endl;
00103                         return 0.0;
00104 
00105                 case IT_GAMOW:
00106                         cout << "GAMOW interpolation" << endl;
00107                         return 0.0;
00108 
00109                 case IT_LINLIN:
00110                         return xs[p] + (e-el) * (xs[p]-xl) / (ene[p]-el);
00111 
00112                 default:
00113                         break;
00114         }
00115         return 0.0;
00116 } // interpolate

Generated on Tue Jul 5 15:15:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1