Main Page   Compound List   File List   Compound Members   File Members  

MyBiSource.cpp

Go to the documentation of this file.
00001 
00007 #include <math.h>
00008 #include <iostream.h>
00009 #include <fstream.h>   // file I/O
00010 #include <iomanip.h>   // format manipulation
00011 #include <string>
00012 #include "ReactorDetector.hh"
00013 #include "ReactorConstants.hh"
00014 #include "ReactorFortran.hh"
00015 #include "MyBiSource.hh"
00016 
00017 MyBiSource::MyBiSource(int newIsotope){
00018 
00019   Isotope = newIsotope;
00020 
00021   //cout << "MyBiSource::MyBiSource(" << Isotope << ")" << endl;
00022 
00023   // input the source number and position
00024   fstream fin("data/tl_bi_decays.txt", ios::in);
00025   //cout << "Bi input file: data/tl_bi_decays.txt" << endl;
00026 
00027   char paramLine[256];
00028   string dummyString;
00029   int dummyInt;
00030   float dummyFloat;
00031   bool done = false;
00032   bool Set = false;
00033 
00034   int Z, A;
00035   int Nbranch;
00036   float branchProb[130];
00037   int Ngamma[130];
00038   float gammaE[130][6];
00039 
00040   // zero the permanent information
00041   numGamma = 0;
00042   for(int i=0;i<6; i++) gammaEnergy[i] = 0.;
00043 
00044   // Bi212
00045   if(Isotope == 212){
00046 
00047     while(!done){
00048 
00049       // '#' specifies a comment line -- ignore it
00050       if(fin.peek() == '#'){
00051 
00052         fin.getline(paramLine, 256);
00053         continue;
00054       }
00055 
00056       // 'E'ND or 'e'nd specifies end of file -- set done flag to true
00057       if(fin.peek() == 'e' || fin.peek() == 'E'){
00058 
00059         done = true;
00060         continue;
00061       }
00062 
00063       // 'N'UCLEUS = or 'n'ucleus = specifies Z and A of daughter nucleus 
00064       if(fin.peek() == 'n' || fin.peek() == 'N'){
00065 
00066         if(Set){
00067 
00068           fin.getline( paramLine, 256 );
00069           continue;
00070         }
00071         fin >> dummyString;
00072         while(fin.peek() == ' ' || fin.peek() == '=') 
00073           fin.ignore(1);
00074 
00075         fin >> Z >> A;
00076         //cout << Z << " " << A << endl;
00077 
00078         if(A == 212){
00079 
00080           // read in Bi212 decay table, 6 branches
00081           Nbranch = 6;
00082           for(int n=0; n<Nbranch; n++){
00083 
00084             fin >> branchProb[n] >> dummyInt >> dummyFloat >> Ngamma[n];
00085             for(int i=0; i<6; i++) fin >> gammaE[n][i];
00086             fin >> dummyFloat >> dummyFloat >> dummyFloat;
00087 
00088             /*
00089             cout << "  branchProb[" << n << "] " << branchProb[n] 
00090                  << " and Ngamma[" << n << "] " << Ngamma[n] << endl;
00091             for(int i=0; i<Ngamma[n]; i++){
00092               cout << "  gammaE[" << n << "][" << i << "] " << gammaE[n][i];
00093             }
00094             cout << endl;
00095             */
00096           }
00097 
00098           Set = true;
00099         }
00100 
00101         continue;
00102       }
00103 
00104       // ignore lines starting with numbers if they are not in our decay table
00105       if(fin.peek() == '0' || fin.peek() == '1'){
00106 
00107         fin.getline(paramLine, 256);
00108         continue;
00109       }
00110 
00111       // ignore extra whitespace
00112       if(fin.peek() == ' ' || fin.peek() == '\n'){
00113 
00114         fin.ignore(1);
00115         continue;
00116       }
00117     }
00118 
00119   } // done with Bi212
00120 
00121   // Bi214
00122   if(Isotope == 214){
00123 
00124     while(!done){
00125 
00126       // '#' specifies a comment line -- ignore it
00127       if(fin.peek() == '#'){
00128 
00129         fin.getline(paramLine, 256);
00130         continue;
00131       }
00132 
00133       // 'E'ND or 'e'nd specifies end of file -- set done flag to true
00134       if(fin.peek() == 'e' || fin.peek() == 'E'){
00135 
00136         done = true;
00137         continue;
00138       }
00139 
00140       // 'N'UCLEUS = or 'n'ucleus = specifies Z and A of daughter nucleus 
00141       if(fin.peek() == 'n' || fin.peek() == 'N'){
00142 
00143         if(Set){
00144 
00145           fin.getline( paramLine, 256 );
00146           continue;
00147         }
00148         fin >> dummyString;
00149         while(fin.peek() == ' ' || fin.peek() == '=') 
00150           fin.ignore(1);
00151 
00152         fin >> Z >> A;
00153         //cout << Z << " " << A << endl;
00154 
00155         if(A == 214){
00156 
00157           // read in Bi214 decay table, 127 branches
00158           Nbranch = 127;
00159           for(int n=0; n<Nbranch; n++){
00160 
00161             fin >> branchProb[n] >> dummyInt >> dummyFloat >> Ngamma[n];
00162             for(int i=0; i<6; i++) fin >> gammaE[n][i];
00163             fin >> dummyFloat >> dummyFloat >> dummyFloat;
00164 
00165             /*
00166             cout << "  branchProb[" << n << "] " << branchProb[n] 
00167                  << " and Ngamma[" << n << "] " << Ngamma[n] << endl;
00168             for(int i=0; i<Ngamma[n]; i++){
00169               cout << "  gammaE[" << n << "][" << i << "] " << gammaE[n][i];
00170             }
00171             cout << endl;
00172             */
00173           }
00174 
00175           Set = true;
00176         }
00177 
00178         continue;
00179       }
00180 
00181       // ignore lines starting with numbers if they are not in our decay table
00182       if(fin.peek() == '0' || fin.peek() == '1'){
00183 
00184         fin.getline(paramLine, 256);
00185         continue;
00186       }
00187 
00188       // ignore extra whitespace
00189       if(fin.peek() == ' ' || fin.peek() == '\n'){
00190 
00191         fin.ignore(1);
00192         continue;
00193       }
00194     }
00195 
00196   } // done with Bi214
00197 
00198   // pick a decay branch and get the gamma energies
00199   int len = 1;
00200   float r[len];
00201   ranlux_(r,len);
00202 
00203   bool passed = false;
00204   for(int n=0;n<Nbranch; n++){
00205 
00206     if(branchProb[n] > r[0] && !passed){
00207 
00208       // save the number and energies of the gammas
00209       numGamma = Ngamma[n];
00210       for(int i=0;i<numGamma; i++) gammaEnergy[i] = gammaE[n][i];
00211 
00212        if(numGamma)passed = true;
00213     }
00214   }
00215 
00216 
00217 }
00218 
00219 MyBiSource::~MyBiSource(){
00220   ;
00221 }
00222 
00223 MyBiSource::MyBiSource(const MyBiSource& BiSource){
00224 
00225   Isotope = BiSource.Isotope;
00226 
00227   numGamma = BiSource.numGamma;
00228 
00229   for(int n=0;n<6;n++){
00230     gammaEnergy[n] = BiSource.gammaEnergy[n];
00231   }
00232 }    
00233 
00234 MyBiSource& MyBiSource::operator=(const MyBiSource& rhs){
00235 
00236   if(this == &rhs)return *this;
00237 
00238   Isotope = rhs.Isotope;  
00239 
00240   numGamma = rhs.numGamma;
00241 
00242   for(int n=0;n<6;n++){
00243     gammaEnergy[n] = rhs.gammaEnergy[n];
00244   }
00245 
00246   return *this;
00247 
00248 }    

Generated on Fri Oct 22 13:56:25 2004 for ReactorFsim by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002