source: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h@ 19371

Last change on this file since 19371 was 19368, checked in by tbretz, 8 years ago
Allow to switch to fake calibration...
File size: 8.8 KB
Line 
1/*
2 * QtGl.h
3 *
4 * Created on: Jul 20, 2011
5 * Author: lyard
6 */
7
8#ifndef QTGL_H_
9#define QTGL_H_
10
11#define NBOARDS 40 // max. number of boards
12#define NPIX 1440 // max. number of pixels
13#define NTMARK 160 // max. number of timeMarker signals
14
15#include <string>
16#include <valarray>
17
18#include <QObject>
19
20#include "BasicGlCamera.h"
21
22#include <qwt_plot_curve.h>
23
24class QwtPlotZoomer;
25class QwtPlotGrid;
26
27#ifndef Q_MOC_RUN
28#include "src/DataCalib.h"
29#include "externals/ofits.h"
30#endif
31
32/*************************************************
33 * Class Raw Data Viewer. FACT raw data diplayer
34 *************************************************/
35class RawDataViewer : public BasicGlCamera//QGLWidget
36{
37 Q_OBJECT
38
39 friend class UIConnector;
40
41 enum CalibDataTypes {
42 CALIB_BASELINE,
43 CALIB_GAIN,
44 CALIB_TRIG_OFFSET
45 };
46
47public:
48 DrsCalibration fDrsCalib;
49
50 bool fIsDrsCalibration;
51
52 RawDataViewer(QWidget *parent = 0);
53 ~RawDataViewer();
54 void openFile(std::string file, bool reopen);
55 void openCalibFile(std::string& file);
56
57 template <typename T>
58 void getCalibrationDataForDisplay(const CalibDataTypes calibTypes,
59 const vector<T>& inputData,
60 const int roi,
61 const int roiTM);
62 int getCurrentPixel(){return selectedPixel;}
63 void assignPixelMapFile(const string& map="");
64public Q_SLOTS:
65 void plusEvent();
66 void minusEvent();
67 void readEvent();
68 void setEventStep(int step);
69 void nextSlice();
70 void previousSlice();
71 void setCurrentPixel(int);
72
73
74Q_SIGNALS:
75 void signalCurrentEvent(int event);
76 void signalCurrentSlice(int slice);
77 void newFileLoaded();
78 void signalCurrentPixel(int pixel);
79 void signalAutoScaleNeeded();
80
81protected:
82// void initializeGL();
83// void resizeGL(int width, int height);
84 void paintGL();
85 void mousePressEvent(QMouseEvent *event);
86 void mouseMoveEvent(QMouseEvent *event);
87 void mouseDoubleClickEvent(QMouseEvent *event);
88 void drawCamera(bool alsoWire);
89// void drawPatches();
90// int PixelAtPosition(const QPoint &pos);
91// void drawHexagon(int index, bool solid);
92 int selectedPixel;
93 float *eventData;
94 float *rmsData;
95 int16_t* rawEventData;
96 int16_t* waveLetArray;
97 valarray<double> RMSvalues;//(1440);
98 valarray<double> Meanvalues;
99 valarray<double> Maxvalues;
100 valarray<double> PosOfMaxvalues;
101
102 ///Used to load zero data in case of missing fits columns
103 void allocateZeroArray();
104 char* fZeroArray;
105 //bool telling whether the data is natively ordered in software or hardware id
106 //used to correctly display monte-carlo data.
107 bool _softwareOrdering;
108
109private:
110 void drawPixelCurve();
111// void updateNeighbors(int currentPixel);
112// void skipPixels(int start, int howMany);
113// void calculatePixelsCoords();
114 bool setCorrectSlice(QMouseEvent* event);
115 void eventStepping(bool plus);
116// void buildVerticesList();
117// void buildPatchesIndices();
118 void calcBlurColor(int pixel, int vertex);
119 void calcMidBlurColor(int pixel, int vertex);
120 void drawBlurryHexagon(int index);
121 int whichSlice;
122 // float shownSizex;
123 // float shownSizey;
124 bool drawPatch;
125 bool drawImpulse;
126 bool drawBlur;
127 bool loopCurrentEvent;
128 //allocate the maximum size for one event
129 uint32_t boardTime[NBOARDS];
130 int16_t startPix[NPIX];
131 int16_t startTM[NTMARK];
132 int32_t pcTime[2];
133 uint32_t softTrig;
134 uint16_t triggerType;
135 int nRows;
136 int rowNum;
137 int eventNum;
138 int nRoi;
139 int nRoiTM;
140 int offSetRoi;
141 int runNumber;
142 int nTM;
143 std::string runType;
144 int firstDataTime;
145 int lastDataTime;
146 int revision;
147 int builderVersion;
148 int nBoards;
149 int nPixels;
150 std::string timeSystem;
151 std::string creationDate;
152 int nightInt;
153 std::string camera;
154 std::string daq;
155 float adcCount;
156 int nbOk;
157 int nbRej;
158 int nbBad;
159
160 int eventStep;
161
162
163
164
165
166// int hardwareMapping[1440];
167// int softwareMapping[1440];
168//// int patches[160][9];
169 GLfloat patchesColor[160][3];
170// vector<edge> patchesIndices[160];
171 fits* inputFile;
172// std::fits* calibInputFile;
173// float baseLineMean[1440*1024];
174// float gainMean[1440*1024];
175// float triggerOffsetMean[1440*1024];
176// bool calibrationLoaded;
177 bool drawCalibrationLoaded;
178
179 QPoint lastPos;
180public:
181 void computePulsesStatistics();
182 double aMeas[1024];
183 double n1mean[1024];
184 double n2mean[1024];
185 double vCorr[1024];
186 int64_t VALUES_SPAN;
187
188 void ApplyCalibration();
189
190// GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
191// PixelsNeighbors neighbors[MAX_NUM_PIXELS];
192 // GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
193// GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
194// int verticesIndices[ACTUAL_NUM_PIXELS][6];
195// int numVertices;
196};
197
198/*************************************************
199 * Class UIConnector. used to connect the interface to the raw data displayer
200 *************************************************/
201#include "ui_viewer.h"
202
203class Configuration;
204
205class UIConnector : public QMainWindow, protected Ui::MainWindow
206{
207 Q_OBJECT
208private:
209 QTimer timer;
210 std::string currentFile;
211 std::string currentCalibFile;
212
213 QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
214
215 bool updateSpinnerDisplay;
216 bool updating;
217
218 void initHistograms();
219
220public:
221 UIConnector(QWidget *parent = 0);
222 ~UIConnector();
223
224public Q_SLOTS:
225 void fileSelected(QString file);
226 void calibFileSelected(QString file);
227
228 void newFileLoaded();
229 void slicesPerSecondChanged(double value);
230 void nextSlicePlease();
231 void currentSliceHasChanged(int slice);
232 void currentEventHasChanged(int event);
233
234 void on_playPauseButton_clicked();
235 void on_loadNewFileButton_clicked();
236 void on_loadDRSCalibButton_clicked();
237
238 void on_drawPatchCheckBox_stateChanged(int);
239 void on_drawImpulseCheckBox_stateChanged(int);
240 void on_drawBlurCheckBox_stateChanged(int);
241 void on_loopOverCurrentEventBox_stateChanged(int);
242
243 void on_colorRange0_valueChanged(double);
244 void on_colorRange1_valueChanged(double);
245 void on_colorRange2_valueChanged(double);
246 void on_colorRange3_valueChanged(double);
247 void on_colorRange4_valueChanged(double);
248 void on_redValue0_valueChanged(double);
249 void on_redValue1_valueChanged(double);
250 void on_redValue2_valueChanged(double);
251 void on_redValue3_valueChanged(double);
252 void on_redValue4_valueChanged(double);
253 void on_greenValue0_valueChanged(double);
254 void on_greenValue1_valueChanged(double);
255 void on_greenValue2_valueChanged(double);
256 void on_greenValue3_valueChanged(double);
257 void on_greenValue4_valueChanged(double);
258 void on_blueValue0_valueChanged(double);
259 void on_blueValue1_valueChanged(double);
260 void on_blueValue2_valueChanged(double);
261 void on_blueValue3_valueChanged(double);
262 void on_blueValue4_valueChanged(double);
263
264 void on_slicesPerSecValue_valueChanged(double);
265
266 void pixelChanged(int);
267
268 void cbpxChanged();
269
270 void on_HwIDBox_valueChanged(int = 0);
271 void on_SwIDBox_valueChanged(int);
272 void on_crateIDBox_valueChanged(int) { cbpxChanged(); }
273 void on_boardIDBox_valueChanged(int) { cbpxChanged(); }
274 void on_patchIDBox_valueChanged(int) { cbpxChanged(); }
275 void on_pixelIDBox_valueChanged(int) { cbpxChanged(); }
276
277 void on_autoScaleColor_clicked();
278 void on_entireCameraScale_toggled(bool) { on_autoScaleColor_clicked(); }
279 void on_currentPixelScale_toggled(bool) { on_autoScaleColor_clicked(); }
280
281 void slicesPlusPlus();
282 void slicesMinusMinus();
283
284 void on_calibratedCheckBox_stateChanged(int state);
285 void on_displayingSliceBox_valueChanged(int);
286 void on_displayingEventBox_valueChanged(int);
287
288 void displaySliceValue();
289
290 int SetupConfiguration(Configuration &conf);
291
292private:
293 QwtPlotCurve boardsTimeHistoItem;
294 QwtPlotCurve startCellHistoItem;
295 QwtPlotCurve startTimeMarkHistoItem;
296 QwtPlotCurve pixelValueCurveItem;
297 QwtPlotCurve pixelAverageCurveItem;
298 QwtPlotCurve aMeanCurveItem;
299 QwtPlotCurve vCorrCurveItem;
300 QwtPlotCurve meanCurveItem;
301 QwtPlotCurve triggerDelayHistoItem;
302
303 QwtPlotZoomer* curveZoom;
304 QwtPlotZoomer* averageCurveZoom;
305 QwtPlotZoomer* boardsTimeHistoZoom;
306 QwtPlotZoomer* startCellHistoZoom;
307 QwtPlotZoomer* startTimeMarkHistoZoom;
308 QwtPlotZoomer* triggerDelayHistoZoom;
309
310 //declare the grids here, because I must have access to them to detach them properly at destruction time (bug and crash with "bad" versions of qwt)
311 QwtPlotGrid* grid1;
312 QwtPlotGrid* grid2;
313 QwtPlotGrid* grid3;
314 QwtPlotGrid* grid4;
315 QwtPlotGrid* grid5;
316 QwtPlotGrid* grid6;
317};
318
319#endif /* QTGL_H_ */
Note: See TracBrowser for help on using the repository browser.