9 std::string name,
int numberChannelsInGroups,
10 bool disableAutoUpdate):
12 fHistoArray(histoArray){
16 }
else if(numberChannelsInGroups > 1)
17 fNumberChannelsInGroups = numberChannelsInGroups;
19 fNumberChannelsInGroups = -1;
22 fChannelCounterButton = 0;
24 fChannelName =
"Histogram";
28 fGroupCounterButton = 0;
34 fMultiCanvasButton = 0;
35 fNCanvasButtonGroup =0;
40 fOverlayHistoButton = 0;
45 fNHistoLegend =
new TLegend(0.6,0.6,0.89,0.8);
46 fNHistoLegend->SetFillColor(10);
48 fDisableAutoUpdate = disableAutoUpdate;
67 fLabelframe =
new TGHorizontalFrame(compFrame,200,40);
68 compFrame->AddFrame(
fLabelframe,
new TGLayoutHints(kLHintsCenterX,2,2,2,2));
74 TGVerticalFrame *hframe1 =
new TGVerticalFrame(
fLabelframe, 120, 40, kFixedWidth);
75 fLabelframe->AddFrame(hframe1,
new TGLayoutHints(kLHintsLeft,2,2,2,2));
79 TGNumberFormat::kNEANonNegative,
80 TGNumberFormat::kNELLimitMinMax,
85 fGroupCounterButton->Connect(
"ValueSet(Long_t)",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
86 fGroupCounterButton->GetNumberEntry()->Connect(
"ReturnPressed()",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
90 hframe1->AddFrame(
fLabelGroup,
new TGLayoutHints(kLHintsLeft , 1, 1, 1, 1));
99 TGVerticalFrame *hframe2 =
new TGVerticalFrame(
fLabelframe, 120, 40, kFixedWidth);
100 fLabelframe->AddFrame(hframe2,
new TGLayoutHints(kLHintsLeft,2,2,2,2));
106 TGNumberFormat::kNEANonNegative,
107 TGNumberFormat::kNELLimitMinMax,
108 0, numberChannels-1);
112 fChannelCounterButton->Connect(
"ValueSet(Long_t)",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
113 fChannelCounterButton->GetNumberEntry()->Connect(
"ReturnPressed()",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
117 hframe2->AddFrame(
fLabelChannels,
new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
126 fMultiCanvasButton->Connect(
"Toggled(Bool_t)",
"TFancyHistogramCanvas",
this,
"ActivateMultiCanvasButton()");
127 fMultiCanvasButton->Connect(
"Toggled(Bool_t)",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
136 for(
int i = 0; i < 4; i++)
151 fOverlayHistoButton->Connect(
"Toggled(Bool_t)",
"TFancyHistogramCanvas",
this,
"ActivateOverlayButton()");
152 fOverlayHistoButton->Connect(
"Toggled(Bool_t)",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
157 TGVerticalFrame *hframe3 =
new TGVerticalFrame(
fLabelframe, 120, 40, kFixedWidth);
158 fLabelframe->AddFrame(hframe3,
new TGLayoutHints(kLHintsLeft,2,2,2,2));
160 fNHistoButton =
new TGNumberEntry(hframe3, 2, 9,999, TGNumberFormat::kNESInteger,
161 TGNumberFormat::kNEANonNegative,
162 TGNumberFormat::kNELLimitMinMax,
164 hframe3->AddFrame(
fNHistoButton,
new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
166 fNHistoButton->Connect(
"ValueSet(Long_t)",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
167 fNHistoButton->GetNumberEntry()->Connect(
"ReturnPressed()",
"TRootanaDisplay", display,
"UpdatePlotsAction()");
170 labelNHisto =
new TGLabel(hframe3,
"# Histo in Canvas");
171 hframe3->AddFrame(
labelNHisto,
new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
179 for(
unsigned int i = 0; i <
fHistoArray->size(); i++)
197 if(
dynamic_cast<TH2*
>(histo)){
198 std::string fulloption = std::string(
"COLZ") + option;
199 histo->Draw(fulloption.c_str());
201 histo->Draw(option.c_str());
210 TCanvas* c1 = embedCanvas->GetCanvas();
241 for(
int i = 0; i < ncanvas; i++){
243 int index = i + channel;
246 (*fHistoArray)[index]->SetLineColor(1);
252 int nhisto =
fNHistoButton->GetNumberEntry()->GetIntNumber();
256 int first_channel = channel;
257 int last_channel = channel + nhisto;
263 for(
int ichan = first_channel; ichan < last_channel; ichan++){
265 max_histo = (*fHistoArray)[ichan];
266 else if((*
fHistoArray)[ichan]->GetMaximum() > max_histo->GetMaximum())
267 max_histo = (*fHistoArray)[ichan];
276 for(
int ichan = first_channel; ichan < last_channel; ichan++){
278 (*fHistoArray)[ichan]->SetLineColor(ichan-channel+1);
279 sprintf(name,
"Histogram # %i",ichan);
296 (*fHistoArray)[channel]->SetLineColor(1);
349 sprintf(tlabel,
"%s# (0-%i)",groupName.c_str(),(
int)numberGroups-1);
365 sprintf(tlabel,
"%s# (0-%i)",channelName.c_str(),(
int)numberChannels-1);
ClassImp(TFancyHistogramCanvas) TFancyHistogramCanvas
void DrawHistogram(TH1 *histo, std::string option=std::string(""))
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.
void ActivateMultiCanvasButton()
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.
TRootanaDisplay * fDisplay
TGNumberEntry * fChannelCounterButton
Button for the histogram number.
int fNumberChannelsInGroups
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.
TGCheckButton * fOverlayHistoButton
This button controls whether to display overlaid histograms.
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.
void ActivateOverlayButton()
virtual void BeginRun(int transition, int run, int time)
Take actions at begin run.
const std::string GetChannelName()
const int GetNumberChannelsInGroup()
const std::string GetGroupName()
virtual void UpdateHistograms(TDataContainer &dataContainer)=0
Update the histograms for this canvas.
virtual void EndRun(int transition, int run, int time)
Take actions at end run
const bool GetDisableAutoUpdate()
const bool HasAutoUpdate()