GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ConditionPainter.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
15
16#include "TVirtualPad.h"
17#include "TCutG.h"
18#include "TH1.h"
19
20#include "TGo4WinCond.h"
21#include "TGo4PolyCond.h"
22
27
28TGo4ConditionPainter::TGo4ConditionPainter(const char *name, const char *title)
29: TGo4LabelPainter(name, title ? title : "Go4 ConditionPainter"), fxCondition(nullptr)
30{
31}
32
37
39{
40}
41
45
47{
48 if (!gPad)
49 return;
50 if (fxCondition && fxCondition->IsVisible()) {
51 //------ find out initial coordinates for labels near condition boundaries:
52 Double_t xpmin = 0, ypmin = 0;
53 TGo4WinCond *wconny = dynamic_cast<TGo4WinCond *>(fxCondition);
54 TGo4PolyCond *pconny = dynamic_cast<TGo4PolyCond *>(fxCondition);
55 if (wconny) {
56 Double_t xpmax = 0, ypmax = 0;
57 Int_t dim = 0; // dummies here
58 wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
59 if (ypmin == 0)
60 ypmin = (gPad->GetUymax() - gPad->GetUymin()) / 2;
61 } else if (pconny) {
62 TCutG *cutg = pconny->GetCut(kFALSE);
63 if (cutg)
64 cutg->GetPoint(0, xpmin, ypmin);
65 } else {
66 xpmin = (gPad->GetUxmax() - gPad->GetUxmin()) / 2;
67 ypmin = (gPad->GetUymax() - gPad->GetUymin()) / 2;
68 }
69
70 Bool_t haslabel = fxCondition->IsLabelDraw();
71 Bool_t drlimits = fxCondition->IsLimitsDraw();
72 Bool_t drint = fxCondition->IsIntDraw();
73 Bool_t drxmean = fxCondition->IsXMeanDraw();
74 Bool_t drxrms = fxCondition->IsXRMSDraw();
75 Bool_t drymean = fxCondition->IsYMeanDraw();
76 Bool_t dryrms = fxCondition->IsYRMSDraw();
77 Bool_t drxmax = fxCondition->IsXMaxDraw();
78 Bool_t drymax = fxCondition->IsYMaxDraw();
79 Bool_t drcmax = fxCondition->IsCMaxDraw();
80 Bool_t isarray = fxCondition->IsArrayType();
81 Bool_t ismulti = fxCondition->IsMultiEdit();
82 TString fmt = fxCondition->GetLabelNumFormat();
83
84 auto add_label = [this, &fmt](const char *name, Double_t value) {
85 TString conv = name;
86 while (conv.Length() < 5)
87 conv.Append(" ");
88 conv.Append(" = ");
89 conv.Append(TString::Format(fmt.Data(), value));
90 AddToLabel(conv.Data());
91 };
92
93 TH1 *histogram = fxCondition->GetWorkHistogram();
94 if ((isarray && !ismulti) || !haslabel) {
95 // no label: remove previous label
97 } else {
98 // at least one to be displayed: optionally create new label
99 Double_t xoff = 0.015 * (gPad->GetUxmax() - gPad->GetUxmin());
100 Double_t yoff = 0.015 * (gPad->GetUymax() - gPad->GetUymin()); // these are in pad coordinates (for logscale)
101 SetX0(gPad->PadtoX(gPad->XtoPad(xpmin) + xoff));
102 SetY0(gPad->PadtoY(gPad->YtoPad(ypmin) + yoff)); // initial coords are in "real" axis scale
103 SetLineColor(fxCondition->GetLineColor());
104 TString cap = fxCondition->GetName();
105 TH1 *his = fxCondition->GetWorkHistogram();
106 if (his) {
107 cap += ":";
108 cap += his->GetName();
109 }
110 SetCaption(cap.Data());
111 TGo4LabelPainter::PaintLabel(); // this creates new label at initial coords
112 if (drlimits) {
113 add_label("X1", fxCondition->GetXLow());
114 add_label("X2", fxCondition->GetXUp());
115 if (fxCondition->GetDimension() > 1) {
116 add_label("Y1", fxCondition->GetYLow());
117 add_label("Y2", fxCondition->GetYUp());
118 }
119 }
120 if (drint)
121 add_label("Int", fxCondition->GetIntegral(histogram));
122 if (drxmean)
123 add_label("Xmean", fxCondition->GetMean(histogram, 1));
124 if (drxrms)
125 add_label("Xrms", fxCondition->GetRMS(histogram, 1));
126 if (drxmax)
127 add_label("Xmax", fxCondition->GetXMax(histogram));
128 if (drymean)
129 add_label("Ymean", fxCondition->GetMean(histogram, 2));
130 if (dryrms)
131 add_label("Yrms", fxCondition->GetRMS(histogram, 2));
132 if (drymax)
133 add_label("Ymax", fxCondition->GetYMax(histogram));
134 if (drcmax)
135 add_label("Cmax", fxCondition->GetCMax(histogram));
136 RePaintLabel();
137 } // if((isarray && !ismulti) || !haslabel)
138 } // if(fxCondition && fxCondition->IsVisible())
139 else {
140 UnPaintLabel();
141 }
142}
143
TGo4Condition * fxCondition
Condition to be painted.
virtual void UnPaintCondition(Option_t *opt="")
Display condition with plain root canvas and in go4 viewpanel.
void PaintLabel(Option_t *opt="") override
Display statistics label for this condition with respect to working histogram.
virtual void PaintCondition(Option_t *opt="")
Display condition with plain root canvas and in go4 viewpanel.
virtual void SetCondition(TGo4Condition *con)
Not inline, because we overwrite this for polygon condition.
Go4 condition class.
void SetY0(Double_t y=0.)
virtual void UnPaintLabel(Option_t *opt="")
Erase the label.
void SetCaption(const char *txt)
virtual void PaintLabel(Option_t *opt="")
Draw the label.
virtual void RePaintLabel(Option_t *opt="")
refresh painting of label with current attributes
void AddToLabel(const char *txt)
void SetX0(Double_t x=0.)
Polygon condition.
TCutG * GetCut(Bool_t changeowner) override
Used to return the cut pointer of a TGo4PolyCond.
Window condition.
Definition TGo4WinCond.h:26
void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) override
Returns limits.