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