1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218

#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
using namespace std;
//======================================================================
// Functions
//======================================================================
void mathmodel (double ji, double jm, double l1, double f22, double f42,
double* data[][3], double* values[][6], double* model[])
{
//this function does the w(theta) calculation for the model
int i,x ;
double f2, f4;
for ( i = 0 ; i<10 ; i++) {
if (ji==*values[i][1] and jm==*values[i][0] and l1==*values[i][2]){
f2 = *values [i][4];
f4 = *values [i][5];
}
}
for (x=0; x<10 ; x++){
*model[x] = 1 + f2*f22*1/2*(3* pow(cos(*data[x][0]),2) *1 )
+ f4*f42* 1/8*(35*pow(cos(*data[x][0]),4)
 30 *pow(cos(*data[x][0]),4) + 3);
}
}
//======================================================================
double multer (double sig)
{
// this subroutine calcs the constant in front of the exponent summation
// that is constant during the test
double con ;
double pi = 3.14159265359;
con = 1/(sig * sqrt(2*pi));
return (con);
}
//======================================================================
double baysum (double h , double d, double sig)
{
// this sub does the summation portion of the Bayesian analysis
double sum ;
sum =(1*pow((hd),2))/(2*pow(sig,2));
return (sum);
}
//======================================================================
double weight (double elevel, double atmass , double energy)
{
// this sub does the p(HI) calcs for the weights before normalization
// all odd #'s are M's and evens are E's Order goes( E1,M1,E2,M2,ect..)
float ph;
if (elevel == 1) ph = 1.0e14*pow(atmass,2/3)*pow(energy,3);
if (elevel == 2) ph = 7.3e7*pow(atmass,4/3)*pow(energy,5);
if (elevel == 3) ph = 34*pow(atmass,2)*pow(energy,7);
if (elevel == 4) ph = 1.e5*pow(atmass,8/3)*pow(energy,7);
if (elevel == 5) ph = 15.6e13*pow(energy,3);
if (elevel == 6) ph = 3.5e7*pow(atmass,2/3)*pow(energy,5);
if (elevel == 7) ph = 16*pow(atmass,4/3)*pow(energy,7);
if (elevel == 8) ph = 4.5e6*pow(atmass,2)*pow(energy,9);
return (ph);
}
//======================================================================
//======================================================================
// MAIN PROG
//======================================================================
int main ()
{
//FILLING DATA ARRAYS
// ask user for dat file
ifstream dat;
do {
cout << "Input filename where the raw data exist>";
char filename [50];
cin.getline(filename,50);
dat.open(a);
if (!dat.is_open())
cout << "File Does Not Exist!" << endl ;
} while (!dat.is_open());
// read from file and fill arrays
// array reads angle, w(angle) errw(angle)
double* data = new double [15][3];
int x = 0;
double a,b,c,d,e,f;
while ( dat >> a >> b >> c){
data[x][0] = a;
data[x][1] = b;
data[x][2] = c;
// cout << data[x][2] << endl;
x++;
}
// SECOND ARRAY FILLING
// fill arrays for testing models
ifstream table;
do {
cout << "Input filename where the data table exist>";
char file [50];
cin.getline(file,50);
table.open(file);
if (!table.is_open())
cout << "File Does Not Exist!" << endl ;
} while (!table.is_open());
double values [10][6]; //array from 1967 table values are:
// jf , ji,l1,l2,f2,f4
x = 0 ;
while (table >> a >> b >> c >> d >> e >> f){
values [x][0] = a;
values [x][1] = b;
values [x][2] = c;
values [x][3] = d;
values [x][4] = e;
values [x][5] = f;
x++;
}
table.close();
// Ask user for the atomic mass & energy level
float atmass;
cout << "Please enter the atomic mass number>" ;
cin >> atmass;
float energy;
cout << "Please enter the energy (Mev)>" ;
cin >> energy;
double elevel;
double mlevel;
double jm , ji , l1,l2 ,jf;
jm = 9;
jf = 7;
l2 = 2 ;
ji = 11;
l1 = 2 ;
// Done Filling Arrays From File And Grabbing User Input
//======================================================================
// find the proper f2 and f4values from the table for the
// values that we already know ie jm jf and l2
double conf2, conf4;
for ( x = 0 ; x<10 ; x++) {
if (jm==values[x][1] and jf==values[x][0] and l2==values[x][3]){
conf2 = values [x][4];
conf4 = values [x][5];
}
}
double* pmodelw;
pmodelw = new double[15];
mathmodel( ji, jm, l1, conf2, conf4,&data, &values,&pmodelw);
return 0 ;
}
