/* This script READ the DB of the gain curves (only for BB scintillators). */ #include #include void read_gains(double *c_EL, double *c_ER, double *c_dEL, double *c_dER, double *cnst_EL, double *cnst_ER, double *cnst_dEL, double *cnst_dER, int *p_EL, int *p_ER, int *p_dEL, int *p_dER) { char line1[200],line2[200],s[200],s0[200],s1[200],s2[200],s3[200],*dd,*side,*strL,*strR,*detector; dd=(char*)malloc(1000); side=(char*)malloc(1000); strL=(char*)malloc(1000); strR=(char*)malloc(1000); detector=(char*)malloc(1000); int ind1,ind4,indx,d=0,t; float ind2; float ind3; FILE *dbFile4 = fopen("../gain_BB_demo.dat","r"); //open the DB file while(fgets(line2, sizeof(line2), dbFile4) !=NULL) { sscanf(line2,"%s %s %s",&s1, &s2, &s3); sprintf(detector,"%s",s2); // needed in order to choose E or dE plane sprintf(side,"%s",s3); // needed in order to choose between left and right sprintf(strL,"left"); sprintf(strR,"right"); if(!strcmp(side,strL)) t=1; if(!strcmp(side,strR)) t=2; if(!strcmp(detector,"dE")) d=1; if(s1[0]=='#' && (s2[0]=='E') && t==1) indx=1; // left E plane scintillators if(s1[0]=='#' && (s2[0]=='E') && t==2) indx=2; // right E plane scintillators if(s1[0]=='#' && d==1 && t==1) indx=3; // left dE plane scintillators if(s1[0]=='#' && d==1 && t==2) indx=4; // right dE plane scintillators if(indx==1 && s1[0]!='#') { sscanf(line2,"%d %e %f %d", &ind1, &ind2, &ind3, &ind4); *(c_EL+ind1)=ind2; *(cnst_EL+ind1)=ind3; *(p_EL+ind1)=ind4; } if(indx==2 && s1[0]!='#') { sscanf(line2,"%d %e %f %d", &ind1, &ind2, &ind3, &ind4); *(c_ER+ind1)=ind2; *(cnst_ER+ind1)=ind3; *(p_ER+ind1)=ind4; } if(indx==3 && s1[0]!='#') { sscanf(line2,"%d %e %f %d", &ind1, &ind2, &ind3, &ind4); *(c_dEL+ind1)=ind2; *(cnst_dEL+ind1)=ind3; *(p_dEL+ind1)=ind4; } if(indx==4 && s1[0]!='#') { sscanf(line2,"%d %e %f %d", &ind1, &ind2, &ind3, &ind4); *(c_dER+ind1)=ind2; *(cnst_dER+ind1)=ind3; *(p_dER+ind1)=ind4; } } }