StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readParams.C
1 #include <stdio.h>
2 
3 void readParams(char *fileName, float *params, float *errors, int nCent, int nParams ) {
4  FILE *fIn = fopen(fileName,"r");
5  if (!fIn) {
6  printf("Could not open file %s\n",fileName);
7  return;
8  }
9  char line[1024];
10  fgets(line,1024,fIn);
11  fgets(line,1024,fIn);
12  for (int ic=0;ic<nCent;ic++) {
13  float chisq, p, pe;
14  int icent;
15  fscanf(fIn,"%i",&icent);
16  fscanf(fIn,"%f",&chisq);
17  for (int ip=0;ip<nParams;ip++) {
18  fscanf(fIn,"%f(%f)",&p,&pe);
19  params[ic*nParams+ip] = p;
20  errors[ic*nParams+ip] = pe/1000;
21  }
22  }
23  fclose(fIn);
24 }