StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PeakAnaPainter.h
1 /*
2 Author: David Kapukchyan
3 @[July 5, 2023]
4 > Modified paint functions to only paint certain things and added options to select what to paint
5 
6 @[October 20, 2022]
7 > Added doxygen style comments
8 
9 @[September 29, 2022]
10 > Got rid of the virtual painter
11 
12 @[June 12, 2022]
13 > Painter now sets the found peak line color
14 
15 @[May 10, 2022]
16 > Changed how options work. Graph options now supported. Use semicolon separated list for graph, peak and stat options respectively. Added style options for the various lines. Moved lines for the peak windows to the 'PeakWindow' class.
17 
18 @[March 23, 2022]
19 > Found a bug where calling "Draw" on ROOT objects is bad because it adds the TLine objects created by this class to the pad. This means the pad can delete those objects which causes seg fault errors. The proper method to call is "Paint". This is because "Draw" for most ROOT objects only adds objects to the TPad's list so that later the pad can call the "Paint" method of the added class. This means when "Draw" is called on a *PeakAna* object it gets added to the pad so that "Paint" can be called. The "Paint" method will now draw all the lines needed. However, if "Draw" is called the lines are also added to the TPad's list. This is not needed since it is sufficient that only the *PeakAna* class be in the list so that the lines are not deleted by TPad.
20 
21  If that paint method involves a "Draw" call then it only adds objects to the pad without calling their paint method
22 
23 @[March 14, 2022]
24 > Separated the peak stats box painting method and added options for it
25 
26 @[March 9, 2022]
27 > This class will be used to draw PeakAna. It is a first try after reading ROOT code and and seeing that by having a separate painter class is better due to how TCanvas objects work and drawing in ROOT in general works. Also after splitting up the various classes I realized that it really is easier to have a separate painter and analysis class. The painter class essentially assumes a canvas/pad exists and only draws on it the things it needs independent of what else is on the canvas/pad. This is the philosophy to keep in mind when writing painter classes.
28 */
29 
34 #ifndef PEAKANAPAINTER_H
35 #define PEAKANAPAINTER_H
36 
37 //C++ Headers
38 #include <vector>
39 #include <utility> //std::move (Needs C++ 11) and std::pair
40 
41 //ROOT Headers
42 #include "TObject.h"
43 #include "TKey.h"
44 #include "TH1.h"
45 #include "TPaveText.h"
46 
47 //Custom Headers
48 #include "PeakWindow.h"
49 
50 class PeakAna;
51 
52 class PeakAnaPainter : public TObject
53 {
54 public:
56  virtual ~PeakAnaPainter();
57 
58  virtual void Paint(Option_t *opt="");
59  virtual void PaintRawData();
60  virtual void PaintFoundPeak();
61  virtual void PaintBaselines();
62  virtual void PaintFoundPeakRange();
63  virtual void PaintPeakRanges();
64  virtual void PaintFoundMarker();
65  virtual void PaintPeakMarkers();
66  virtual void PaintStats();
67 
68  virtual void CleanPainter();
69 
70  virtual void SetPeakAna(PeakAna* ana);
71 
72  virtual Color_t GetBaseLineColor();
73  virtual Style_t GetBaseLineStyle();
74  virtual Width_t GetBaseLineWidth();
75 
76  virtual Color_t GetHitLineColor();
77  virtual Style_t GetHitLineStyle();
78  virtual Width_t GetHitLineWidth();
79 
80  virtual void SetBaseLineColor(Color_t color);
81  virtual void SetBaseLineColorAlpha(Color_t color,Float_t alpha);
82  virtual void SetBaseLineStyle(Style_t style);
83  virtual void SetBaseLineWidth(Width_t width);
84 
85  virtual void SetHitLineColor(Color_t color);
86  virtual void SetHitLineColorAlpha(Color_t color,Float_t alpha);
87  virtual void SetHitLineStyle(Style_t style);
88  virtual void SetHitLineWidth(Width_t width);
89 
90  bool ValidGraph();
91 
92 protected:
93  void Init();
94 
95  TLine* mTheBaseLine;
96  TLine* mTheHitLine;
97 
98  virtual TPaveText* MakePaveText(Double_t xmin=0.7,Double_t ymin=0.5, Double_t xmax=1.0, Double_t ymax=1.0);
99 
101  TPaveText* mPaveT_PA;
102  TString mGraphOption;
103  TString mPeakOption;
104  TString mStatsOption;
105 
106  //[March 23, 2022]>Need a variable to know if something needs to repainted or not this will prevent multiple calls to delete??
107 
108 private:
109  UInt_t mDEBUG;
110 
111  ClassDef(PeakAnaPainter,2);
112 };
113 
114 #endif
virtual void CleanPainter()
Clean up internal objects.
TString mPeakOption
option for drawing the peaks
bool ValidGraph()
Check if PeakAna object loaded and has a non-zero TGraph.
TLine * mTheHitLine
threshold for a peak PeakAna::mBaseline + PeakAna::mBaselineSigma*PeakAna::mBaselineSigmaScale ...
TString mGraphOption
option for drawing the TGraph
virtual void SetPeakAna(PeakAna *ana)
virtual void PaintFoundPeakRange()
Just draw the found peak on the current pad.
virtual void PaintPeakRanges()
Draw all found peaks on the current pad except the found peak.
TLine * mTheBaseLine
line for the PeakAna::mBaseline
virtual void PaintRawData()
Raw data with no modifications.
TString mStatsOption
option for what to put in stats box
virtual void PaintFoundMarker()
Draw the marker indicating the found peak.
PeakAna * mPA
pointer to PeakAna for drawing (PA=PeakAna)
virtual void PaintBaselines()
Just draw the baseline and hitlines.
virtual void PaintPeakMarkers()
Draw markers indicating all peaks except the found peak marker.
virtual void PaintStats()
Draw Stats box for peak finding.
TPaveText * mPaveT_PA
for custom stats box
virtual TPaveText * MakePaveText(Double_t xmin=0.7, Double_t ymin=0.5, Double_t xmax=1.0, Double_t ymax=1.0)
Makes the stats box to show peak infomation.
virtual void PaintFoundPeak()
Raw data inside zoomed in on found signal region.
void Init()
Initialize internal variables to null.