#include #include void read_hv_mapping(int CrateL[112], int SlotL[112], int ChanL[112], int CrateR[112], int SlotR[112], int ChanR[112], int Layer[112], int Bar[112]){ char line1[200],side[200],strL[200],strR[200],s1[200],s2[200],file[200]; int ind1; // Layer int ind2; // Bar int ind3; // HV Crate int ind4; // HV Slot int ind5; // HV Channel sprintf(file,"/home/igorko/E07-006/scripts/HAND/gain/HV-mapping.dat"); FILE *dbFile3 = fopen(file,"r"); int t=0, indx; int bars_p[6]={0,30,54,76,88,100}; //Numbering of the bars is from 0 up to 112 bars. The count start at layer 1 bar 1. while(fgets(line1, sizeof(line1), dbFile3) !=NULL) { sscanf(line1,"%s %s",&s1, &s2); sprintf(side,"%s",s2); sprintf(strL,"left"); sprintf(strR,"right"); if(!strcmp(side,strL)) t=1; if(!strcmp(side,strR)) t=2; if(s1[0]=='#' && t==1) indx=1; // left side scintillators if(s1[0]=='#' && t==2) indx=2; // right side scintillators //=================== Left Side ========================= if(indx==1 && s1[0]!='#') { sscanf(line1," %d %d %d %d %d", &ind1, &ind2, &ind3, &ind4, &ind5); CrateL[bars_p[ind1-1]+ind2]=ind3; SlotL[bars_p[ind1-1]+ind2] =ind4; ChanL[bars_p[ind1-1]+ind2] =ind5; Layer[bars_p[ind1-1]+ind2]=ind1; // General for left and right. Convert the bar index to layer number Bar[bars_p[ind1-1]+ind2]=ind2; // General for left and right. Convert the bar index to bar number in each layer. } //=================== Right Side ========================= if(indx==2 && s1[0]!='#') { sscanf(line1," %d %d %d %d %d", &ind1, &ind2, &ind3, &ind4, &ind5); CrateR[bars_p[ind1-1]+ind2]=ind3; SlotR[bars_p[ind1-1]+ind2] =ind4; ChanR[bars_p[ind1-1]+ind2] =ind5; } //========================================================= } }