Subversion Repositories f9daq

Rev

Rev 172 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
146 f9daq 1
#ifndef __ROOT_APP_H__
2
#define __ROOT_APP_H__
3
 
4
//#define winWidth 1240
5
//#define winHeight 800
6
#define WINDOW_NAME "CAMAC/MPOD/4MM DAQ software"
7
#define measwin 3
8
#define analysiswin 4
9
#define BSIZE 10000
10
 
11
#include "root_include.h"
12
#include "substructure.h"
13
#include "daq.h"
14
#include "daqscope.h"
15
#include <iostream>
16
#include <fstream>
17
#include <cmath>
18
#include <time.h>
19
 
20
enum EMenuIds {
21
   M_FILE_SET_LAYOUT,
22
   M_FILE_SAVE_LAYOUT,
23
   M_FILE_SAVE_MSETTINGS,
24
   M_FILE_SAVE_ASETTINGS,
173 f9daq 25
   M_FILE_DEF_MSETTINGS,
26
   M_FILE_DEF_ASETTINGS,
27
   M_FILE_DEF_SETTINGS,
146 f9daq 28
   M_FILE_CHECK_WIDTH,
29
   M_FILE_EXIT,
30
 
31
   M_ANALYSIS_HISTTYPE_1DADC,
32
   M_ANALYSIS_HISTTYPE_1DTDC,
33
   M_ANALYSIS_HISTTYPE_2D,
34
   M_ANALYSIS_INTEG,
35
   M_ANALYSIS_INTEGX,
36
   M_ANALYSIS_INTEGY,
37
   M_ANALYSIS_PHOTMU,
38
   M_ANALYSIS_BREAKDOWN,
39
   M_ANALYSIS_SURFSCAN,
40
   M_ANALYSIS_TIMING,
41
 
42
   M_HELP_WEBHELP,
43
   M_HELP_ABOUT
44
};
45
 
46
// Separate functions -----------------------------------------
47
void GetTime(int intime, char *outtime);
48
void remove_ext(char *inname, char *outname);
49
void remove_from_last(char *inname, char search, char *outname);
50
void remove_before_last(char *inname, char search, char *outname);
51
void layoutMainWindow(int *w, int *h);
52
void SeqNumber(int innum, int maxnum, char *outstr);
53
void TimeEstimate(clock_t stopw0, time_t time0, float progress, char *retEstim, int offset);
172 f9daq 54
void TimeEstimateNew(int nr, clock_t stopw0, time_t time0, int rX, int rY, int rZ, int xWait, int yWait, int zWait, char *retEstim);
146 f9daq 55
void NormateSet(int file, int nrpoint, double *min, double *max, double *setCount, double *setAcc);
56
double PointEstimate(int nrp, double *points);
57
// Separate functions -----------------------------------------
58
 
59
 
60
// Window classes ----------------------------------------------------
61
//class TGWindow;
62
//class TGMainFrame;
63
 
64
// Subwindow layout class
65
/*class TGMdiSubwindow
66
{
67
RQ_OBJECT("TGMdiSubwindow")
68
 
69
protected:
70
   TGMdiFrame *fMdiFrame;
71
 
72
public:
73
   TGMdiSubwindow(TGMdiMainFrame *main, int w, int h);
74
   TGMdiFrame *GetMdiFrame() const { return fMdiFrame; }
75
   // layoutchange is 0 when we close a subwindow and 1 when we change the layout (close multiple subwindows)
76
   virtual Bool_t CloseWindow(int layoutchange);
77
 
78
   // unique id is set for each subwindow
79
   //  settingsPane->id = 0
80
   int id;
81
};*/
82
 
83
// Main window class
84
class TGAppMainFrame
85
{
86
RQ_OBJECT("TGAppMainFrame")
87
 
88
protected:
89
   TGMainFrame *fMain;
90
//   TGMdiMainFrame *fMainFrame;
91
//   TGMdiMenuBar *fMenuBar;
92
   TGMenuBar *fMenuBar;
93
   TGLayoutHints *fMenuBarItemLayout;
94
   TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuHelp, *fMenuHisttype;
95
   TGTab *fTab, *analTab;
96
   int winWidth;
97
   int winHeight;
98
//   TGMdiSubwindow *settingsPane;
99
 
100
   // Variables for frame layouts and titles
101
   TGCompositeFrame *fLayout[2];
102
   TGHorizontalFrame *fTitle;
103
 
104
   void InitMenu();
105
   void AppLayout();
106
   void OpenWindow(int winid);
107
   void CloseWindow();
108
   Bool_t About();
109
 
110
   int idtotal;
111
   bool cleanPlots;
112
   int logChange;
113
   int selChannel;
114
   bool acqStarted;
115
   unsigned int gBuf[BSIZE];
116
   clock_t clkt0;
117
   time_t timet0;
118
   bool liveUpdate;
119
   int npeaks;
120
 
121
public:
122
   TGAppMainFrame(const TGWindow *p, int w, int h);
123
   virtual ~TGAppMainFrame();
124
 
125
   void HandleMenu(Int_t id);
126
 
127
   // Splitter to a set number of frames
128
   bool TGSplitter(TGWindow *parent, const char *majorSplit, int *vertSplits, int *horSplits, const char *frameTitles[512], TGCompositeFrame **frames, int *frameWidth, int *frameHeight);
129
   void TGTitleLabel(TGWindow *parent, TGHorizontalFrame *fTitle, const char *title, Pixel_t foreColor, Pixel_t backColor, const char *font);
130
 
131
   // Layout setup
132
   void LayoutRead(int nrframes, int *w, int *h);
133
   void LayoutSave();
134
   void LayoutSet();
173 f9daq 135
   void SaveMeasSettings();
136
   void SaveAnalSettings();
137
   void GetMeasSettings();
138
   void GetAnalSettings();
146 f9daq 139
   void ToolTipSet();
172 f9daq 140
   void ToolTipSetSurfaceScan();
141
   void ToolTipSetRelativePDE();
142
   void ToolTipSetTempAnalysis();
146 f9daq 143
 
144
   // Subframes where we display everything
145
   TGCompositeFrame *measLayout[measwin];
146
   TGCompositeFrame *analysisLayout[analysiswin];
147
 
148
   // Substructures for Settings pane (measurement layout)
149
   TSubStructure *scansOn;
150
   TSubStructure *vHardlimit;
151
   TSubStructure *NCH;
152
   TSubStructure *posUnits;
153
   TSubStructure *rotUnits;
154
   TSubStructure *oscConnect;
155
   TSubStructure *laserInfo;
156
   TSubStructure *chtemp;
157
   TSubStructure *liveDisp;
158
 
159
   // Substructures for Measurement pane (measurement layout)
160
   TSubStructure *vOutCh;
161
   TSubStructure *vOut;
162
   TSubStructure *vOutOpt;
163
   TSubStructure *vOutButtons;
164
   TSubStructure *vOutStart;
165
   TSubStructure *vOutStop;
166
   TSubStructure *vOutStep;
167
   TSubStructure *xPos;
168
   TSubStructure *yPos;
169
   TSubStructure *zPos;
170
   TSubStructure *zPosMin;
171
   TSubStructure *zPosMax;
172
   TSubStructure *zPosStep;
173
   TSubStructure *posButtons;
174
   TSubStructure *xPosMin;
175
   TSubStructure *xPosMax;
176
   TSubStructure *xPosStep;
177
   TSubStructure *yPosMin;
178
   TSubStructure *yPosMax;
179
   TSubStructure *yPosStep;
180
   TSubStructure *rotPos;
181
   TSubStructure *rotButtons;
173 f9daq 182
   TSubStructure *rotButEmergency;
146 f9daq 183
   TSubStructure *rotPosMin;
184
   TSubStructure *rotPosMax;
185
   TSubStructure *rotPosStep;
186
   TSubStructure *evtNum;
187
   TSubStructure *timeStamp;
188
   TSubStructure *fileName;
189
   TSubStructure *measProgress;
190
 
191
   // Substructures for Display pane (measurement layout)
192
   TRootEmbeddedCanvas *measCanvas;
193
 
194
   // Action connections for Settings pane (measurement layout)
195
   void EnableScan(int type);
196
   void VoltageLimit();
197
   void ChangeUnits(int type);
198
   void ChangeUnitsRot(int type);
199
   void EnableLiveUpdate();
200
 
201
   // Action connections for Measurement pane (measurement layout)
202
   int GetChannel();
203
   void NegativePolarity();
204
   void VoltOut(int opt);
205
   void PositionSet(int opt);
206
   void RotationSet(int opt);
207
   void SaveFile();
208
   void StartAcq();
209
 
210
   // Substructures for Histogram selection pane (analysis layout)
211
   TSubStructure *selectDir;
212
   TGListBox *fileList;
213
   TSubStructure *multiSelect;
214
   TSubStructure *fileListCtrl;
215
   TSubStructure *dispTime;
216
   TSubStructure *dispBias;
217
   TSubStructure *dispPos;
218
   TSubStructure *dispTemp;
219
   TSubStructure *dispAngle;
220
   TSubStructure *dispLaser;
221
 
222
   // Substructures for Histogram pane (analysis layout)
223
   TRootEmbeddedCanvas *analysisCanvas;
224
 
225
   // Substructures for Histogram controls pane (analysis layout)
226
   TSubStructure *adcRange;
227
   TSubStructure *tdcRange;
228
   TSubStructure *yRange;
229
   TSubStructure *selectCh;
230
   TSubStructure *plotType;
231
   TSubStructure *histOpt;
232
   TSubStructure *exportHist;
233
   TSubStructure *editSelHist;
167 f9daq 234
   TSubStructure *posUnitsPlot;
146 f9daq 235
 
236
   // Substructures for analysis pane (analysis layout)
237
   TSubStructure *intSpect;
238
   TSubStructure *resol2d;
239
   TSubStructure *intSpectButtons;
240
 
241
   TSubStructure *relPde;
242
   TSubStructure *midPeak;
243
   TSubStructure *darkRun;
244
   TSubStructure *zeroAngle;
245
   TSubStructure *relPdeButtons;
246
 
247
   TSubStructure *minPeak;
248
   TSubStructure *peakSepCalc;
249
   TSubStructure *brDownButtons;
250
 
251
   TSubStructure *surfScanOpt;
252
   TSubStructure *resolSurf;
253
   TSubStructure *surfButtons;
254
 
255
   TSubStructure *fitSigma;
256
   TSubStructure *fitTresh;
257
   TSubStructure *fitInter;
258
   TSubStructure *adcOffset;
259
   TSubStructure *accError;
260
   TSubStructure *pedesLow;
261
   TSubStructure *fitChecks;
262
   TSubStructure *analysisProgress;
263
 
264
   // Action connections for Histogram file selection pane (analysis layout)
265
   void SelectDirectory();
266
   void ListMultiSelect(int opt);
267
   void FileListNavigation(int opt);
268
   void HeaderEdit();
269
   void ClearHistogramList();
270
 
271
   // Action connections for Histogram controls pane (analysis layout)
272
   void UpdateHistogram(int opt);
273
   void HistogramOptions(int opt);
274
   void ChangeHisttype(int type);
275
 
276
   // Action connections for analysis pane (analysis layout)
277
   void SelectDarkHist();
278
   void AnalysisDefaults();
279
   void AnalysisHandle(int type);
280
   void IntegSpectrum(TList *files, int direction, int edit);
281
   void PhotonMu(TList *files, int edit);
282
   void PlotEdgeDistribution(TList *files, int filenr, int points, double *min, double *max, double *xy, double *integAcc, int axis, bool edge2d, int edit);
283
   void BreakdownVolt(TList *files, int edit);
284
   void SurfaceScan(TList *files, int edit);
285
 
286
   // Substructures for Edit file header window (new tab)
287
   TGListBox *editList;
288
   TSubStructure *timeEditDisplay;
289
   TSubStructure *biasEdit;
290
   TSubStructure *xPosEdit;
291
   TSubStructure *yPosEdit;
292
   TSubStructure *zPosEdit;
293
   TSubStructure *tempEdit;
294
   TSubStructure *angleEdit;
295
   TSubStructure *laserEdit;
296
   TSubStructure *editHead;
297
   TSubStructure *editMulti;
298
   TGLabel *selectWarn;
299
 
300
   // Action connections for Edit file header window (new tab)
301
   void SetWarnings();
302
   void EditTickToggle(int type);
303
   void StartHeaderEdit();
304
   void ShowHeaderEdit(int id);
305
   void HeaderChange(char *histfile, bool *changetype);
306
   void CloseEditTab(int tabval);
307
 
308
   // Substructures for temporary analysis edit window (new tab)
309
   TRootEmbeddedCanvas *tempAnalysisCanvas;
310
   TSubStructure *runningAver;
311
   TSubStructure *runningOff;
312
   TSubStructure *secondAxis;
313
   TSubStructure *exportExitAnalysis;
172 f9daq 314
 
315
   TSubStructure *xCrop;
316
   TSubStructure *yCrop;
317
   TSubStructure *interpolSize;
318
   TSubStructure *updateCrop;
146 f9daq 319
 
320
   // Action connections for temporary analysis edit window (new tab)
321
   void ApplyRunningAver();
172 f9daq 322
   void UpdateIntegrateSurface(int val);
146 f9daq 323
   void CloseTempAnalysisTab(int tabval);
167 f9daq 324
   void ExportTempAnalysisPlot();
146 f9daq 325
 
326
   // Additional functions
327
   void DisplayHistogram(char *histfile, int histtype, int opt);
328
   void HeaderEditTab(TGTab *mainTab, bool create, int *tabid);
329
   void TempAnalysisTab(TGTab *mainTab, bool create, int *tabid, int analtype);
330
   void RunMeas(void *ptr, int runCase, int &scanon);
331
   int MyTimer();
332
 
172 f9daq 333
   // Open directory (separate for saving measurement and for opening histograms)
334
   char *currentMeasDir;
335
   char *currentAnalDir;
167 f9daq 336
 
146 f9daq 337
// ROOT file variable structure -------------------------------
338
   struct EventHeader {
339
     int nrch;
340
     int timestamp;
341
     double biasvolt;
342
     int xpos;
343
     int ypos;
344
     int zpos;
345
     double temperature;
346
     double angle;
347
     char laserinfo[256];
348
   } evtheader;
349
 
350
   struct EventData {
351
     int adcdata[8];
352
     int tdcdata[8];
353
   } evtdata;
354
 
355
   struct EventMeas {
356
     double measdata;
357
   } evtmeas;
358
 
359
   TFile *inroot;
360
   TFile *outroot;
361
// ROOT file variable structure -------------------------------
362
 
363
   daq *gDaq;
364
   daqscope *gScopeDaq;
365
};
366
 
367
// -------------------------------------------------------------------
368
 
369
#endif