- Timestamp:
- 08/03/11 14:21:39 (13 years ago)
- Location:
- trunk/FACT++/gui/RawEventsViewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
r11740 r11753 514 514 float yRange = bboxMax[1] - bboxMin[1]; 515 515 glColor3f(1.0,1.0,1.0); 516 float divideMe = (float)(VALUES_SPAN-1); 517 float plusMe = VALUES_SPAN/2; 518 if (drawCalibrationLoaded && calibrationLoaded) 519 { 520 divideMe /=2; 521 plusMe /=2; 522 } 516 523 for (int i=0;i<nRoi-1;i++) 517 524 { 518 525 #ifdef LOAD_RAW 519 526 glVertex2f(bboxMin[0] + xRange*i/(float)nRoi, 520 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+ (VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));527 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+plusMe) /divideMe); 521 528 glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi, 522 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+ (VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));529 bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+plusMe) /divideMe); 523 530 #else 531 524 532 glVertex2f(bboxMin[0] + xRange*i/(float)nRoi, 525 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+ (VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));533 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i]+plusMe) /divideMe); 526 534 glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi, 527 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+ (VALUES_SPAN/2)) /(float)(VALUES_SPAN-1));535 bboxMin[1] + yRange*(eventData[nRoi*selectedPixel + i+1]+plusMe) /divideMe); 528 536 #endif 529 537 } … … 659 667 for (int i=0;i<1440;i++) 660 668 updateNeighbors(i); 669 670 calibrationLoaded = false; 671 drawCalibrationLoaded = false; 672 661 673 } 662 674 /************************************************************ … … 936 948 if (!inputFile->SetPtrAddress("Data", eventData)){ 937 949 cout << "Missing column " << "Data" << " Aborting load..." << endl; 938 nRoi = nRows = 0; }950 nRoi = nRows = 0;return;} 939 951 if (!inputFile->SetPtrAddress("EventNum", &eventNum)){ 940 952 cout << "Missing column " << "EventNum" << " Aborting load..." << endl; 941 nRoi = nRows = 0; }953 nRoi = nRows = 0;return;} 942 954 if (!inputFile->SetPtrAddress("TriggerType", &triggerType)){ 943 955 cout << "Missing column " << "TriggerType" << " Aborting load..." << endl; 944 nRoi = nRows = 0; }956 nRoi = nRows = 0;return;} 945 957 if (!inputFile->SetPtrAddress("SoftTrig", &softTrig)){ 946 958 cout << "Missing column " << "SoftTrig" << " Aborting load..." << endl; 947 nRoi = nRows = 0; }959 nRoi = nRows = 0;return;} 948 960 if (!inputFile->SetPtrAddress("PCTime", &pcTime)){ 949 961 cout << "Missing column " << "PCTime" << " Aborting load..." << endl; 950 nRoi = nRows = 0; }962 nRoi = nRows = 0;return;} 951 963 if (!inputFile->SetPtrAddress("BoardTime", boardTime)){ 952 964 cout << "Missing column " << "BoardTime" << " Aborting load..." << endl; 953 nRoi = nRows = 0; }965 nRoi = nRows = 0;return;} 954 966 if (!inputFile->SetPtrAddress("StartCellData", startPix)){ 955 967 cout << "Missing column " << "StartCellData" << " Aborting load..." << endl; 956 nRoi = nRows = 0; }968 nRoi = nRows = 0;return;} 957 969 if (!inputFile->SetPtrAddress("StartCellTimeMarker", startTM)){ 958 970 cout << "Missing column " << "StartCellTimeMarker" << " Aborting load..." << endl; 959 nRoi = nRows = 0; }971 nRoi = nRows = 0;return;} 960 972 int backupStep = eventStep; 961 973 rowNum = -1; … … 966 978 emit signalCurrentPixel(selectedPixel); 967 979 } 968 980 void RawDataViewer::openCalibFile(string& file) 981 { 982 calibrationLoaded = false; 983 calibInputFile = new fits(file); 984 if (!*calibInputFile) 985 { 986 delete calibInputFile; 987 calibInputFile = NULL; 988 return; 989 } 990 991 if (!calibInputFile->SetPtrAddress("BaselineMean", baseLineMean)){ 992 cout << "Missing column " << "BaseLineMean" << " Aborting load..." << endl; 993 return;} 994 if (!calibInputFile->SetPtrAddress("GainMean", gainMean)){ 995 cout << "Missing column " << "GainMean" << " Aborting load..." << endl; 996 return;} 997 if (!calibInputFile->SetPtrAddress("TriggerOffsetMean", triggerOffsetMean)){ 998 cout << "Missing column " << "TriggerOffsetMean" << " Aborting load..." << endl; 999 return;} 1000 1001 calibInputFile->GetNextRow(); 1002 1003 delete calibInputFile; 1004 1005 calibrationLoaded = true; 1006 emit newFileLoaded(); 1007 if (drawCalibrationLoaded) 1008 updateGL(); 1009 } 969 1010 /************************************************************ 970 1011 * PLUS EVENT … … 1009 1050 #endif 1010 1051 1052 if (drawCalibrationLoaded) 1053 { 1054 for (int i=0;i<1440;i++) 1055 for (int j=0;j<nRoi;j++) 1056 { 1057 eventData[i*1024+j] /= 2; 1058 eventData[i*1024+j] -= (baseLineMean[i*1024+j]+triggerOffsetMean[i*1024+j]); 1059 eventData[i*1024+j] /= gainMean[i*1024+j]; 1060 } 1061 } 1011 1062 updateGL(); 1012 1063 emit signalCurrentEvent(eventNum); 1013 1064 emit signalCurrentPixel(selectedPixel); 1014 1015 1065 } 1016 1066 /************************************************************ … … 1065 1115 patchID = 1; 1066 1116 rescaleWholeCamera = true; 1117 currentFile = "none"; 1118 currentCalibFile = "none"; 1067 1119 } 1068 1120 void UIConnector::slicesPlusPlus() … … 1073 1125 { 1074 1126 viewer->previousSlice(); 1127 } 1128 void UIConnector::drawCalibratedDataChanged(int state) 1129 { 1130 if (state) 1131 { 1132 if (viewer->calibrationLoaded) 1133 { 1134 viewer->drawCalibrationLoaded = true; 1135 for (int i=0;i<1440;i++) 1136 for (int j=0;j<viewer->nRoi;j++) 1137 { 1138 viewer->eventData[i*1024+j] /= 2; 1139 viewer->eventData[i*1024+j] -= (viewer->baseLineMean[i*1024+j]+viewer->triggerOffsetMean[i*1024+j]); 1140 viewer->eventData[i*1024+j] /= viewer->gainMean[i*1024+j]; 1141 } 1142 viewer->updateGL(); 1143 } 1144 else 1145 { 1146 drawCalibrationCheckBox->setChecked(false); 1147 } 1148 } 1149 else 1150 { 1151 viewer->drawCalibrationLoaded = false; 1152 if (viewer->calibrationLoaded) 1153 { 1154 for (int i=0;i<1440;i++) 1155 for (int j=0;j<viewer->nRoi;j++) 1156 { 1157 viewer->eventData[i*1024+j] *= viewer->gainMean[i*1024+j]; 1158 viewer->eventData[i*1024+j] += (viewer->baseLineMean[i*1024+j]+viewer->triggerOffsetMean[i*1024+j]); 1159 viewer->eventData[i*1024+j] *= 2; 1160 } 1161 viewer->updateGL(); 1162 } 1163 1164 } 1165 1075 1166 } 1076 1167 /************************************************************ … … 1306 1397 dialog.exec(); 1307 1398 } 1399 void UIConnector::loadNewCalibFileClicked() 1400 { 1401 QFileDialog dialog; 1402 dialog.setFileMode(QFileDialog::ExistingFile); 1403 dialog.open(this, SLOT(calibFileSelected(QString))); 1404 dialog.setVisible(true); 1405 dialog.exec(); 1406 } 1308 1407 /************************************************************ 1309 1408 * FILE SELECTED. return of the file open dialog handler … … 1315 1414 viewer->openFile(currentFile); 1316 1415 } 1416 void UIConnector::calibFileSelected(QString file) 1417 { 1418 currentCalibFile = file.toStdString(); 1419 if (currentCalibFile != "") 1420 viewer->openCalibFile(currentCalibFile); 1421 } 1317 1422 /************************************************************ 1318 1423 * NEW FILE LOADED. update of the UI after a new file has been loaded … … 1322 1427 ostringstream str; 1323 1428 str << "File loaded: " << currentFile << "\n"; 1429 str << "Calibration file loaded: " << currentCalibFile << "\n"; 1324 1430 // fileLoadedLabel->setText(QString(str.str().c_str())); 1325 1431 // str.str(""); … … 2123 2229 connector.range3 = myUi.colorRange3; 2124 2230 connector.range4 = myUi.colorRange4; 2231 connector.drawCalibrationCheckBox = myUi.calibratedCheckBox; 2125 2232 2126 2233 connector.initHistograms(); … … 2162 2269 &connector, SLOT(newFileLoaded())); 2163 2270 2271 QObject::connect(myUi.calibratedCheckBox, SIGNAL(stateChanged(int)), 2272 &connector, SLOT(drawCalibratedDataChanged(int))); 2164 2273 QObject::connect(myUi.loadNewFileButton, SIGNAL(clicked()), 2165 2274 &connector, SLOT(loadNewFileClicked())); 2275 QObject::connect(myUi.loadDRSCalibButton, SIGNAL(clicked()), 2276 &connector, SLOT(loadNewCalibFileClicked())); 2166 2277 2167 2278 QObject::connect(myUi.colorRange0, SIGNAL(valueChanged(double)), -
trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
r11740 r11753 27 27 #include <QtGui/QDoubleSpinBox> 28 28 #include <QtGui/QRadioButton> 29 #include <QtGui/QCheckBox> 29 30 #include <iostream> 30 31 #include <GL/gl.h> … … 79 80 RawDataViewer(QWidget *parent = 0); 80 81 ~RawDataViewer(); 81 void openFile(string& filename); 82 void openFile(string& file); 83 void openCalibFile(string& file); 82 84 83 85 public Q_SLOTS: … … 169 171 vector<edge> patchesIndices[160]; 170 172 fits* inputFile; 173 fits* calibInputFile; 174 float baseLineMean[1440*1024]; 175 float gainMean[1440*1024]; 176 float triggerOffsetMean[1440*1024]; 177 bool calibrationLoaded; 178 bool drawCalibrationLoaded; 171 179 172 180 QPoint lastPos; … … 191 199 public Q_SLOTS: 192 200 void loadNewFileClicked(); 201 void loadNewCalibFileClicked(); 193 202 void fileSelected(QString file); 203 void calibFileSelected(QString file); 194 204 void drawPatchesCheckChange(int state); 195 205 void drawImpulseCheckChange(int state); … … 233 243 void slicesPlusPlus(); 234 244 void slicesMinusMinus(); 245 void drawCalibratedDataChanged(int state); 235 246 236 247 Q_SIGNALS: … … 247 258 QTimer timer; 248 259 string currentFile; 260 string currentCalibFile; 249 261 int crateID; 250 262 int boardID; … … 301 313 QDoubleSpinBox* range4; 302 314 315 QCheckBox* drawCalibrationCheckBox; 316 303 317 void initHistograms(); 304 318 -
trunk/FACT++/gui/RawEventsViewer/viewer.ui
r11740 r11753 221 221 <property name="text"> 222 222 <string>File loaded: none 223 Calibration file loaded: none 223 224 Run number: 224 225 Number of Events: … … 243 244 </string> 244 245 </property> 246 <property name="wordWrap"> 247 <bool>true</bool> 248 </property> 245 249 </widget> 246 250 </item> … … 476 480 </widget> 477 481 </item> 478 <item row="0" column="8">479 <widget class="QPushButton" name="loadNewFileButton">480 <property name="toolTip">481 <string>Load a new fits file</string>482 </property>483 <property name="text">484 <string>Load New File</string>485 </property>486 </widget>487 </item>488 482 <item row="1" column="5"> 489 483 <widget class="QDoubleSpinBox" name="redValue2"> … … 847 841 </item> 848 842 </layout> 843 </item> 844 <item row="0" column="8"> 845 <layout class="QHBoxLayout" name="horizontalLayout_8"> 846 <item> 847 <widget class="QPushButton" name="loadNewFileButton"> 848 <property name="toolTip"> 849 <string>Load a new fits file</string> 850 </property> 851 <property name="text"> 852 <string>Load Data</string> 853 </property> 854 </widget> 855 </item> 856 <item> 857 <widget class="QPushButton" name="loadDRSCalibButton"> 858 <property name="text"> 859 <string>Load DRS calib.</string> 860 </property> 861 </widget> 862 </item> 863 </layout> 864 </item> 865 <item row="0" column="1"> 866 <widget class="QCheckBox" name="calibratedCheckBox"> 867 <property name="layoutDirection"> 868 <enum>Qt::RightToLeft</enum> 869 </property> 870 <property name="text"> 871 <string>Calibrated data</string> 872 </property> 873 </widget> 849 874 </item> 850 875 </layout>
Note:
See TracChangeset
for help on using the changeset viewer.