ROOTANA
Loading...
Searching...
No Matches
TFancyHistogramCanvas.hxx
Go to the documentation of this file.
1#ifndef TFancyHistogramCanvas_h
2#define TFancyHistogramCanvas_h
3
4
5#include <iostream>
6#include <string>
7
8#include "TH1F.h"
10#include "TGNumberEntry.h"
11#include "TGLabel.h"
12#include "THistogramArrayBase.h"
13#include "TGButton.h"
14#include "TGButtonGroup.h"
15#include "TLegend.h"
16
17/// A canvas that plots THistogramArrayBase type histograms in
18/// a nice way.
19/// The basic idea is to allow the user to easily plot an array
20/// of histograms in three different ways:
21/// 1) They can scroll through the histograms one by one, using
22/// the "Histogram Number" button.
23/// 2) They can have a set of NNN different canvases, each
24/// with a different histogram, where NNN can be 2, 4, 8 or 16.
25/// 3) They can have multiple histograms overlaid on the same
26/// canvas; the user can choose how many histograms to overlay.
27///
29
30public:
31
32 /// Pass the THistogramArrayBase pointer during constructor;
33 /// does not pass ownership (TFancyHistogramCanvas will not delete histoArray);
34 /// parameters:
35 /// 'histoArray': this is the pointer to the class derived from THistogramArrayBase base;
36 /// - does not assume ownership of pointer memory.
37 /// 'name' is the name that the histogram will have.
38 /// 'numberChannelsInGroups': if this value is greater than 1, then the fancy canvas
39 /// will have an additional button allowing the user to specify particular groups;
40 /// the histograms will be organized into size/fNumberChannelsInGroups of groups,
41 /// with each group having fNumberChannelsInGroups entries.
42 /// will have an additional button allowing the user to specify particular groups.
43 /// 'disableAutoUpdate' will tell fancy histogram to not call histoArray->UpdateHistograms()
44 /// -> the assumption is that the user will take care of calling this function.
45 ///
47 std::string name, int numberChannelsInGroups = -1,
48 bool disableAutoUpdate=false);
49
51
52 /// Reset the histograms for this canvas
54
55 /// Update the histograms for this canvas.
56 void UpdateCanvasHistograms(TDataContainer& dataContainer);
57
58 /// Plot the histograms for this canvas
59 void PlotCanvas(TDataContainer& dataContainer, TRootEmbeddedCanvas *embedCanvas);
60
61 /// Take actions at begin run
62 void BeginRun(int transition,int run,int time);
63
64 /// Take actions at end run
65 void EndRun(int transition,int run,int time);
66
67
68 void SetUpCompositeFrame(TGCompositeFrame *compFrame, TRootanaDisplay *display);
69
70 /// These methods are callbacks to ensure that multi-canvas and overlay-histo modes
71 /// are used exclusively.
74
75 /// Allow the user to set explicitly the group name.
76 void SetGroupName(std::string groupName);
77 /// Allow the user to set explicitly the channel name.
78 void SetChannelName(std::string channelName);
79
80private:
81
82 /// Pointer to the THistogramArrayBase class; memory is not owned by TFancyHistogramCanvas.
84
85 /// 'disableAutoUpdate' will tell fancy histogram to not call histoArray->UpdateHistograms()
86 /// -> the assumption is that the user will take care of calling this function.
88
89 /// 'fNumberChannelsInGroups': if this value is greater than 1, then the fancy canvas
90 /// will have an additional button allowing the user to specify particular groups;
91 /// the histograms will be organized into size/fNumberChannelsInGroups of groups,
92 /// with each group having fNumberChannelsInGroups entries.
94
95 /// Overall frame in which we will add buttons and widgets.
96 TGHorizontalFrame *fLabelframe;
97
98 /// Button for the histogram number.
99 TGNumberEntry *fChannelCounterButton;
100
101 /// A label for the histogram number button.
103
104 /// Name for the channel button.
105 std::string fChannelName;
106
107 /// Button for the group number.
108 TGNumberEntry *fGroupCounterButton;
109
110 /// A label for the group button.
111 TGLabel *fLabelGroup;
112
113 /// Name for the group button.
114 std::string fGroupName;
115
116 /// This button controls whether to display mutliple sub-canvases.
117 TGCheckButton *fMultiCanvasButton;
118
119 /// Button group to select how many canvases to show.
120 TGHButtonGroup *fNCanvasButtonGroup;
121 TGRadioButton *fNCanvasButtons[4];
122
123 /// This button controls whether to display overlaid histograms.
124 TGCheckButton *fOverlayHistoButton;
125
126 /// Button group to select how many histograms to show.
127 TGNumberEntry *fNHistoButton;
128 TGLabel *labelNHisto;
130
131 /// Helper function to remove extra buttons if not needed anymore.
133
134 /// Cached pointer to rootana display; needed so that we can
135 /// create new buttons with correct callbacks.
137
138 // Don't define default constructor.
140
141 // Need to rootcint this class, in order for call-backs to work.
142 ClassDef(TFancyHistogramCanvas,1)
143};
144
145
146#endif
TGLabel * fLabelChannels
A label for the histogram number button.
TGHorizontalFrame * fLabelframe
Overall frame in which we will add buttons and widgets.
TGHButtonGroup * fNCanvasButtonGroup
Button group to select how many canvases to show.
void UpdateCanvasHistograms(TDataContainer &dataContainer)
Update the histograms for this canvas.
std::string fChannelName
Name for the channel button.
TGNumberEntry * fNHistoButton
Button group to select how many histograms to show.
TGCheckButton * fMultiCanvasButton
This button controls whether to display mutliple sub-canvases.
TGRadioButton * fNCanvasButtons[4]
void BeginRun(int transition, int run, int time)
Take actions at begin run.
void PlotCanvas(TDataContainer &dataContainer, TRootEmbeddedCanvas *embedCanvas)
Plot the histograms for this canvas.
std::string fGroupName
Name for the group button.
TGLabel * fLabelGroup
A label for the group button.
void ResetCanvasHistograms()
Reset the histograms for this canvas.
TGNumberEntry * fChannelCounterButton
Button for the histogram number.
void EndRun(int transition, int run, int time)
Take actions at end run
THistogramArrayBase * fHistoArray
Pointer to the THistogramArrayBase class; memory is not owned by TFancyHistogramCanvas.
void SetChannelName(std::string channelName)
Allow the user to set explicitly the channel name.
void SetGroupName(std::string groupName)
Allow the user to set explicitly the group name.
TFancyHistogramCanvas(THistogramArrayBase *histoArray, std::string name, int numberChannelsInGroups=-1, bool disableAutoUpdate=false)
TGCheckButton * fOverlayHistoButton
This button controls whether to display overlaid histograms.
void CheckExtraButtons()
Helper function to remove extra buttons if not needed anymore.
TGNumberEntry * fGroupCounterButton
Button for the group number.
void SetUpCompositeFrame(TGCompositeFrame *compFrame, TRootanaDisplay *display)
This is the complicated part, where we create a bunch of buttons and widgets.