-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_config.cpp
110 lines (101 loc) · 3.65 KB
/
read_config.cpp
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
#include <string.h>
void readConfigFile(const char * fileName,const char *configType)
{
if((config=fopen(fileName,"r"))==NULL)
{
printf("ERROR: Cannot open the parameter file %s!\n",fileName);
exit(-1);
}
while(!(feof(config)))//go until the end of file is reached
{
if(fgets(cfgstr,256,config)!=NULL)
{
if(sscanf(cfgstr,"%s %s",str1,str2)==2) //single parameter data
{
// file list and tree name
if(strcmp(str1,"INPUT_FILE_LIST")==0)
strcpy(inp_filename,str2);
if(strcmp(str1,"TREE_NAME")==0)
strcpy(tree_name,str2);
if(strcmp(str1,"PROJ_A")==0)
Ap=atof(str2);
if(strcmp(str1,"PROJ_Z")==0)
Zp=atof(str2);
if(strcmp(str1,"RECL_A")==0)
Ar=atof(str2);
if(strcmp(str1,"RECL_Z")==0)
Zr=atof(str2);
if(strcmp(str1,"EGAMMA")==0)
E0=atof(str2);
if(strcmp(str1,"PROJ_REAC_IN_PATH")==0)
strcpy(prIn_name,str2);
if(strcmp(str1,"PROJ_REAC_OUT_PATH")==0)
strcpy(prOut_name,str2);
if(strcmp(str1,"PROJ_DECAY_PATH")==0)
strcpy(prDec_name,str2);
if(strcmp(str1,"GAMMA_X")==0)
strcpy(gx_name,str2);
if(strcmp(str1,"GAMMA_Y")==0)
strcpy(gy_name,str2);
if(strcmp(str1,"GAMMA_Z")==0)
strcpy(gz_name,str2);
if(strcmp(str1,"OUTPUT_FILE")==0)
strcpy(out_filename,str2);
if(strcmp(str1,"SORT_PATH")==0)
strcpy(sort_path,str2);
if(strcmp(str1,"SORT_DATA_SCALING_FACTOR")==0)
sort_scaling=atof(str2);
// group map stuff
if( (strcmp(str1,"GROUP_MAP_PATH")==0))
strcpy(group_file,str2);
if(strcmp(str1,"POS_PATH")==0)
strcpy(pos_path,str2);
if(strcmp(str1,"COL_PATH")==0)
strcpy(col_path,str2);
if(strcmp(str1,"CSI_PATH")==0)
strcpy(csi_path,str2);
// FWHM response
if(strcmp(str1,"SORT_DATA_FWHM_RESPONSE")==0)
{
if(strcmp(str2,"yes")==0)
fwhmResponse=true;
else
fwhmResponse=false;
}
if(strcmp(str1,"FWHM_F")==0)
fwhmF=atof(str2);
if(strcmp(str1,"FWHM_G")==0)
fwhmG=atof(str2);
if(strcmp(str1,"FWHM_H")==0)
fwhmH=atof(str2);
}
if(sscanf(cfgstr,"%s %s",str1,str2)==1) //only one item on line
if(strcmp(str1,"<---END_OF_PARAMETERS--->")==0)
break;
}
}
fclose(config);
//Report parameters based on the config file type used
if(strcmp(configType,"coulex_ang_dist")==0)
{
printf("Input list file: %s\n",inp_filename);
printf("Sorting from tree name: %s\n",tree_name);
printf("Projectile Z,A: %d,%d\n",(int)Zp,(int)Ap);
printf("Recoil Z,A: %d,%d\n",(int)Zr,(int)Ar);
printf("Projectile Egamma: %f\n",E0);
printf("Projectile reaction in branch : %s\n",prIn_name);
printf("Projectile reaction out branch: %s\n",prOut_name);
printf("Projectile decay branch: %s\n",prDec_name);
printf("Gamma (x,y,z) branches: (%s,%s,%s)\n",gx_name,gy_name,gz_name);
printf("Sorting from leaf with path: %s in tree: %s\n",sort_path,tree_name);
printf("Using groups defined in %s\n",group_file);
if(fwhmResponse==true)
{
printf("Will apply FWHM response function to sorted data.\n");
printf("FWHM response function paremeters: F=%f, G=%f, H=%f.\n",fwhmF,fwhmG,fwhmH);
}
if(sort_scaling!=1.0)
printf("Will scale sorted data by a factor of %f\n",sort_scaling);
printf("Will save output data to file: %s\n",out_filename);
}
}