Subversion Repositories f9daq

Rev

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.  
  223.    // Substructures for analysis pane (analysis layout)
  224.    TSubStructure *intSpect;
  225.    TSubStructure *resol2d;
  226.    TSubStructure *intSpectButtons;
  227.  
  228.    TSubStructure *relPde;
  229.    TSubStructure *midPeak;
  230.    TSubStructure *darkRun;
  231.    TSubStructure *zeroAngle;
  232.    TSubStructure *relPdeButtons;
  233.  
  234.    TSubStructure *minPeak;
  235.    TSubStructure *peakSepCalc;
  236.    TSubStructure *brDownButtons;
  237.  
  238.    TSubStructure *surfScanOpt;
  239.    TSubStructure *resolSurf;
  240.    TSubStructure *surfButtons;
  241.  
  242.    TSubStructure *fitSigma;
  243.    TSubStructure *fitTresh;
  244.    TSubStructure *fitInter;
  245.    TSubStructure *adcOffset;
  246.    TSubStructure *accError;
  247.    TSubStructure *pedesLow;
  248.    TSubStructure *fitChecks;
  249.    TSubStructure *analysisProgress;
  250.  
  251.    // Action connections for Histogram file selection pane (analysis layout)
  252.    void SelectDirectory();
  253.    void ListMultiSelect(int opt);
  254.    void FileListNavigation(int opt);
  255.    void HeaderEdit();
  256.    void ClearHistogramList();
  257.    
  258.    // Action connections for Histogram controls pane (analysis layout)
  259.    void UpdateHistogram(int opt);
  260.    void HistogramOptions(int opt);
  261.    void ChangeHisttype(int type);
  262.  
  263.    // Action connections for analysis pane (analysis layout)
  264.    void SelectDarkHist();
  265.    void AnalysisDefaults();
  266.    void AnalysisHandle(int type);
  267.    void IntegSpectrum(TList *files, int direction, int edit);
  268.    void PhotonMu(TList *files, int edit);
  269.    void PlotEdgeDistribution(TList *files, int filenr, int points, double *min, double *max, double *xy, double *integAcc, int axis, bool edge2d, int edit);
  270.    void BreakdownVolt(TList *files, int edit);
  271.    void SurfaceScan(TList *files, int edit);
  272.  
  273.    // Substructures for Edit file header window (new tab)
  274.    TGListBox *editList;
  275.    TSubStructure *timeEditDisplay;
  276.    TSubStructure *biasEdit;
  277.    TSubStructure *xPosEdit;
  278.    TSubStructure *yPosEdit;
  279.    TSubStructure *zPosEdit;
  280.    TSubStructure *tempEdit;
  281.    TSubStructure *angleEdit;
  282.    TSubStructure *laserEdit;
  283.    TSubStructure *editHead;
  284.    TSubStructure *editMulti;
  285.    TGLabel *selectWarn;
  286.  
  287.    // Action connections for Edit file header window (new tab)
  288.    void SetWarnings();
  289.    void EditTickToggle(int type);
  290.    void StartHeaderEdit();
  291.    void ShowHeaderEdit(int id);
  292.    void HeaderChange(char *histfile, bool *changetype);
  293.    void CloseEditTab(int tabval);
  294.  
  295.    // Substructures for temporary analysis edit window (new tab)
  296.    TRootEmbeddedCanvas *tempAnalysisCanvas;
  297.    TSubStructure *runningAver;
  298.    TSubStructure *runningOff;
  299.    TSubStructure *secondAxis;
  300.    TSubStructure *exportExitAnalysis;
  301.    
  302.    // Action connections for temporary analysis edit window (new tab)
  303.    void ApplyRunningAver();
  304.    void CloseTempAnalysisTab(int tabval);
  305.  
  306.    // Additional functions
  307.    void DisplayHistogram(char *histfile, int histtype, int opt);
  308.    void HeaderEditTab(TGTab *mainTab, bool create, int *tabid);
  309.    void TempAnalysisTab(TGTab *mainTab, bool create, int *tabid, int analtype);
  310.    void RunMeas(void *ptr, int runCase, int &scanon);
  311.    int MyTimer();
  312.  
  313. // ROOT file variable structure -------------------------------
  314.    struct EventHeader {
  315.      int nrch;
  316.      int timestamp;
  317.      double biasvolt;
  318.      int xpos;
  319.      int ypos;
  320.      int zpos;
  321.      double temperature;
  322.      double angle;
  323.      char laserinfo[256];
  324.    } evtheader;
  325.  
  326.    struct EventData {
  327.      int adcdata[8];
  328.      int tdcdata[8];
  329.    } evtdata;
  330.  
  331.    struct EventMeas {
  332.      double measdata;
  333.    } evtmeas;
  334.  
  335.    TFile *inroot;
  336.    TFile *outroot;
  337. // ROOT file variable structure -------------------------------
  338.  
  339.    daq *gDaq;
  340.    daqscope *gScopeDaq;
  341. };
  342.  
  343. // -------------------------------------------------------------------
  344.  
  345. #endif
  346.