#include #include #include #include #include #include #include #include #include #include #include #include #include #include "RootHeader.h" #include "TTree.h" #include "TProfile.h" #include "TH1F.h" #include "TFile.h" void my_test(char *file, float ped[21][16]){ int ch; char str_tmp[300]; char str[80]; char str1[80]; int crate; int sl; int args_assigned = -1; int args = -1; cout << " ===== MY_TEST ====== " << endl; FILE *pFile; pFile = fopen(file,"r"); while ((ch = getc(pFile)) != EOF) { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ args_assigned = sscanf(str_tmp,"%s",str); if(strncmp(str, "CRATE", 5) == 0){ args_assigned = sscanf(str_tmp,"%*s %d %*s %d",&crate, &sl); cout << " Crate = " << crate << " Slot = " << sl << endl; } // cout << str_tmp << endl; if(strncmp(str, "PED", 3) == 0){ // cout << " I am here " << sl << endl; args = sscanf(str_tmp, "%*s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f ", &ped[sl][0], &ped[sl][1], &ped[sl][2], &ped[sl][3], &ped[sl][4], &ped[sl][5], &ped[sl][6], &ped[sl][7], &ped[sl][8], &ped[sl][9], &ped[sl][10], &ped[sl][11], &ped[sl][12], &ped[sl][13], &ped[sl][14], &ped[sl][15]); cout << " Number of arguments " << args << " Slot = " << sl << " " << ped[3][1] << endl; } } } } void set_ped(){ float ped_3200[21][16]; float ped_3300[21][16]; memset(ped_3200,0,sizeof(ped_3200)); memset(ped_3300,0,sizeof(ped_3300)); char *file = "ps2_3250.txt"; // char *file = "ps1_3200.txt"; // char *file = "ps2_3200.txt"; // char *file = "tpol_3200.txt"; // char *file = "tagm_3200.txt"; my_test(file, ped_3200); file = "ps2_3350.txt"; // file = "ps1_3300.txt"; // file = "ps2_3300.txt"; // file = "tpol_3300.txt"; // file = "tagm_3300.txt"; my_test(file, ped_3300); #if 0 for(int ii = 0; ii < 16; ii++){ cout << ped_3300[3][ii] << " "; } cout << endl; for(int ii = 0; ii < 16; ii++){ cout << ped_3200[3][ii] << " "; } cout << endl; #endif for(int sl = 3; sl < 21; sl++){ if(sl == 11 || sl == 12 || sl == 21) continue; cout << endl; cout << "############################ " << endl; cout << "FADC250_SLOTS " << sl << endl; cout << "############################ " << endl; cout << endl; // cout << " SLOT = " << sl << endl; cout << "FADC250_ALLCH_DAC "; for(int ch = 0; ch < 16; ch++){ float dac = 0; if(ped_3300[sl][ch] > 0 && ped_3200[sl][ch] > 0){ float a = (ped_3300[sl][ch] - ped_3200[sl][ch])/100.; float b = ped_3300[sl][ch] - a*3350; dac = (100 - b)/a; cout << roundf(dac) << " "; } else cout << dac << " "; } cout << endl; } // std::cout.precision(10); // cout << " DAC = " << dac << " " << roundf(dac) << " " << nearbyint(dac) << " " << floor(dac + 0.5) << endl; }