Main Page   Compound List   File List   Compound Members   File Members  

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

Generated on Thu Jul 29 14:27:03 2004 for ReactorFsim by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002