DDASToys for NSCLDAQ  6.2-000
QRootCanvas.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Aaron Chester
12  FRIB
13  Michigan State University
14  East Lansing, MI 48824-1321
15 */
16 
22 #ifndef QROOTCANVAS_H
23 #define QROOTCANVAS_H
24 
25 #include <QWidget>
26 
27 #include <vector>
28 #include <cstdint>
29 
30 class QMouseEvent;
31 class QPaintEvent;
32 class QResizeEvent;
33 
34 class TCanvas;
35 class TH1D;
36 class TLegend;
37 
38 namespace ddastoys {
39  class DDASFitHit;
40 }
41 
42 class FitManager;
43 
44 class QRootCanvas : public QWidget
45 {
46  Q_OBJECT
47 
60 public:
68  QRootCanvas(FitManager* pFitMgr, QWidget* parent = nullptr);
70  virtual ~QRootCanvas();
71 
76  TCanvas* getCanvas() {return m_pCanvas;};
81  void drawHit(const ddastoys::DDASFitHit& hit);
83  void clear();
84 
85 protected:
86 
87  // Qt actions to ROOT
88 
93  virtual void mouseMoveEvent(QMouseEvent* e);
98  virtual void mousePressEvent(QMouseEvent* e);
103  virtual void mouseReleaseEvent(QMouseEvent* e);
106  virtual void paintEvent(QPaintEvent*);
109  virtual void resizeEvent(QResizeEvent*);
110 
111 private:
116  void drawTrace(const ddastoys::DDASFitHit& hit);
122  void drawSingleFit(const ddastoys::DDASFitHit& hit);
128  void drawDoubleFit(const ddastoys::DDASFitHit& hit);
130  void drawFitLegend();
131 
132 private:
133  FitManager* m_pFitManager;
134  TCanvas* m_pCanvas;
135  TLegend* m_pFitLegend;
136  TH1D* m_pTraceHist;
137  TH1D* m_pFit1Hist;
138  TH1D* m_pFit2Hist;
139 };
140 
141 #endif
Provides an interface for calculating trace fits using HitExtension fit parameters.
Definition: FitManager.h:65
A ROOT canvas embedded in a Qt application.
Definition: QRootCanvas.h:45
virtual ~QRootCanvas()
Destructor.
Definition: QRootCanvas.cpp:84
void drawHit(const ddastoys::DDASFitHit &hit)
Draw hit data on the canvas.
Definition: QRootCanvas.cpp:99
void clear()
Clear and update the ROOT canvas.
Definition: QRootCanvas.cpp:120
virtual void paintEvent(QPaintEvent *)
Handle resize events in ROOT.
Definition: QRootCanvas.cpp:204
virtual void mouseMoveEvent(QMouseEvent *e)
Handle Qt mouse move events on the ROOT canvas.
Definition: QRootCanvas.cpp:135
virtual void mouseReleaseEvent(QMouseEvent *e)
Handle Qt mouse release events on the ROOT canvas.
Definition: QRootCanvas.cpp:173
QRootCanvas(FitManager *pFitMgr, QWidget *parent=nullptr)
Constructor.
Definition: QRootCanvas.cpp:50
virtual void resizeEvent(QResizeEvent *)
Handle paint events in ROOT.
Definition: QRootCanvas.cpp:194
virtual void mousePressEvent(QMouseEvent *e)
Handle Qt mouse press events on the ROOT canvas.
Definition: QRootCanvas.cpp:152
TCanvas * getCanvas()
Return a pointer to the ROOT canvas.
Definition: QRootCanvas.h:76
Encapsulates data for DDAS hits that may have fitted traces.
Definition: DDASFitHit.h:46