Subversion Repositories f9daq

Rev

Rev 146 | Rev 172 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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