/************************************************************************* \ Name: HVCalib.cc Created by: Luisa Sabrina Stark Schneebeli, April 2009 sabrina.stark@phys.ethz.ch Contents: Class reading the calibration tabel for DAC to HV values \*************************************************************************/ #include "HVCalib.h" #include #include #include #include using namespace std; HVCalib::HVCalib(HVConfig* hvConfig) { char calibfile[80]; int idac, idacOld; int istep, ihv1000, ihvOld; char dLine[6000]; bool first = true; float hv1000,dac; double intpart; iDACMin = hvConfig->DACMin; fHVCalibSlope = hvConfig->fHVCalibSlope; NDACValues = hvConfig->DACMax - hvConfig->DACMin; NHVValues = 10*NDACValues; HVArray = new float***[hvConfig->NumHVBoards]; for(int i=0; iNumHVBoards; i++) { HVArray[i] = new float**[NCHAIN]; for(int j=0; jNumHVBoards]; for(int i=0; iNumHVBoards; i++) { DACArray[i] = new int**[NCHAIN]; for(int j=0; jNumHVBoards; i++){ // for(int i=0; i<1; i++){ for(int j=0;jfUSBDevice[i],65+j,1); // printf("Calibration tabel 0: %s\n", calibfile); ifstream fin(calibfile); while(fin){ fin >> dac; idacOld = 0; if ((int)dac >= hvConfig->DACMin) { if (first){ iDACMin = (int)dac; first = false; } idac = (int)dac - iDACMin; istep = idac - idacOld; for(int k=0;k>HVArray[i][j][k][idac]; for (int l=1; l 11240-iDACMin) // return; } } idacOld = idac; } else{ fin.getline(dLine,6000,'\n'); // Skip low voltage region } } } } for(int i=0; iNumHVBoards; i++){ // for(int i=0; i<1; i++){ for(int j=0;j= 0.5){ ihv1000 = (int)((hv1000>=0)?ceil(hv1000):floor(hv1000)); } else { ihv1000 = (int)((hv1000<0)?ceil(hv1000):floor(hv1000)); } if (ihv1000 <= ihvOld){ continue; } else if (ihv1000 > ihvOld){ for (int m=0; m<(ihv1000-ihvOld);m++){ DACArray[i][j][k][ihvOld+m] = l+iDACMin; //printf("HV = %d, HVArr = %f, DACArray = %d, m = %d. \n",ihvOld+m,HVArray[i][j][k][l],DACArray[i][j][k][ihvOld+m],m); // printf("DACArray[i][j][k][0] = %d\n", DACArray[i][j][k][0]); } ihvOld = ihv1000; } } } } } } ///////////////////////////////////////////////////////////////////////// HVCalib::~HVCalib() { for (int i=0; i= 0.5){ ihv = (int)((hv1000>=0)?ceil(hv1000):floor(hv1000)); } else { ihv = (int)((hv1000<0)?ceil(hv1000):floor(hv1000)); } return DACArray[board][chain][channel][ihv]; } }