GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ConditionPainter.cxx
Go to the documentation of this file.
1 // $Id: TGo4ConditionPainter.cxx 2746 2020-04-16 09:10:17Z linev $
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 
14 #include "TGo4ConditionPainter.h"
15 
16 #include "TVirtualPad.h"
17 #include "TCutG.h"
18 #include "TH1.h"
19 
20 #include "TGo4WinCond.h"
21 #include "TGo4PolyCond.h"
22 
24 : TGo4LabelPainter(), fxCondition(0)
25 {
26 }
27 
28 TGo4ConditionPainter::TGo4ConditionPainter(const char* name, const char* title)
29 : TGo4LabelPainter(name, title ? title : "Go4 ConditionPainter"), fxCondition(0)
30 {
31 }
32 
34 {
36 }
37 
39 {
40 }
41 
43 {
44 }
45 
47 {
48 if(gPad==0) return;
50  {
51  //------ find out initial coordinates for labels near condition boundaries:
52  Double_t xpmin=0;
53  Double_t ypmin=0;
54  TGo4WinCond* wconny=dynamic_cast<TGo4WinCond*>(fxCondition);
55  TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
56  if(wconny)
57  {
58  Double_t xpmax=0; Double_t ypmax=0; Int_t dim=0; // dummies here
59  wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
60  if(ypmin==0) ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
61  }
62  else if(pconny)
63  {
64  TCutG* cutg=pconny->GetCut(kFALSE);
65  if(cutg) cutg->GetPoint(0,xpmin,ypmin);
66  }
67  else
68  {
69  xpmin=(gPad->GetUxmax()-gPad->GetUxmin())/2;
70  ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
71  }
72 
73  Bool_t haslabel=fxCondition->IsLabelDraw();
74  Bool_t drlimits=fxCondition->IsLimitsDraw();
75  Bool_t drint=fxCondition->IsIntDraw();
76  Bool_t drxmean=fxCondition->IsXMeanDraw();
77  Bool_t drxrms=fxCondition->IsXRMSDraw();
78  Bool_t drymean=fxCondition->IsYMeanDraw();
79  Bool_t dryrms=fxCondition->IsYRMSDraw();
80  Bool_t drxmax=fxCondition->IsXMaxDraw();
81  Bool_t drymax=fxCondition->IsYMaxDraw();
82  Bool_t drcmax=fxCondition->IsCMaxDraw();
83  Bool_t isarray=fxCondition->IsArrayType();
84  Bool_t ismulti=fxCondition->IsMultiEdit();
85  TString fmt=fxCondition->GetLabelNumFormat();
86  TH1* histogram=fxCondition->GetWorkHistogram();
87  if((isarray && !ismulti) || !haslabel)
88  {
89  // no label: remove previous label
90  UnPaintLabel();
91  }
92  else
93  {
94  // at least one to be displayed: optionally create new label
95  Double_t xoff=0.015*(gPad->GetUxmax()-gPad->GetUxmin());
96  Double_t yoff=0.015*(gPad->GetUymax()-gPad->GetUymin()); // these are in pad coordinates (for logscale)
97  SetX0( gPad->PadtoX( gPad->XtoPad(xpmin) + xoff));
98  SetY0( gPad->PadtoY( gPad->YtoPad(ypmin) + yoff)); // initial coords are in "real" axis scale
99  SetLineColor(fxCondition->GetLineColor());
100  TString cap=fxCondition->GetName();
101  TH1* his=fxCondition->GetWorkHistogram();
102  if(his)
103  {
104  cap+=":";
105  cap+=his->GetName();
106  }
107  SetCaption(cap.Data());
108  TGo4LabelPainter::PaintLabel();// this creates new label at initial coords
109  if(drlimits)
110  {
111  AddToLabel(Form(Form("X1 = %s",fmt.Data()),fxCondition->GetXLow()));
112  AddToLabel(Form(Form("X2 = %s",fmt.Data()),fxCondition->GetXUp()));
113  if(fxCondition->GetDimension()>1)
114  {
115  AddToLabel(Form(Form("Y1 = %s",fmt.Data()),fxCondition->GetYLow()));
116  AddToLabel(Form(Form("Y2 = %s",fmt.Data()),fxCondition->GetYUp()));
117  }
118  }
119  if(drint)
120  AddToLabel(Form(Form("Int = %s",fmt.Data()),fxCondition->GetIntegral(histogram)));
121  if(drxmean)
122  AddToLabel(Form(Form("Xmean = %s",fmt.Data()),fxCondition->GetMean(histogram,1)));
123  if(drxrms)
124  AddToLabel(Form(Form("Xrms = %s",fmt.Data()),fxCondition->GetRMS(histogram,1)));
125  if(drxmax)
126  AddToLabel(Form(Form("Xmax = %s",fmt.Data()),fxCondition->GetXMax(histogram)));
127  if(drymean)
128  AddToLabel(Form(Form("Ymean = %s",fmt.Data()),fxCondition->GetMean(histogram,2)));
129  if(dryrms)
130  AddToLabel(Form(Form("Yrms = %s",fmt.Data()),fxCondition->GetRMS(histogram,2)));
131  if(drymax)
132  AddToLabel(Form(Form("Ymax = %s",fmt.Data()),fxCondition->GetYMax(histogram)));
133  if(drcmax)
134  AddToLabel(Form(Form("Cmax = %s",fmt.Data()),fxCondition->GetCMax(histogram)));
135  RePaintLabel();
136  }//if((isarray && !ismulti) || !haslabel)
137  }//if(fxCondition && fxCondition->IsVisible())
138 else
139  {
140  UnPaintLabel();
141  }
142 }
143 
145 {
146  fxCondition=con;
147 }
148 
149 
virtual Bool_t IsXRMSDraw()
virtual Bool_t IsLimitsDraw()
virtual Double_t GetRMS(TH1 *, Int_t=1)
virtual Bool_t IsCMaxDraw()
virtual void PaintCondition(Option_t *opt="")
void SetX0(Double_t x=0)
virtual Bool_t IsIntDraw()
virtual Double_t GetYUp()
Int_t GetDimension()
virtual void UnPaintLabel(Option_t *opt="")
virtual void UnPaintCondition(Option_t *opt="")
virtual Bool_t IsVisible()
virtual Bool_t IsLabelDraw()
TGo4Condition * fxCondition
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
virtual Double_t GetIntegral(TH1 *, Option_t *="")
virtual Double_t GetXLow()
virtual void PaintLabel(Option_t *opt="")
virtual void PaintLabel(Option_t *opt="")
TCutG * GetCut(Bool_t changeowner)
virtual Bool_t IsYMaxDraw()
void SetCaption(const char *txt)
void SetY0(Double_t y=0)
virtual Bool_t IsArrayType()
virtual Bool_t IsMultiEdit()
virtual Bool_t IsXMeanDraw()
virtual Bool_t IsXMaxDraw()
TH1 * GetWorkHistogram()
virtual void SetCondition(TGo4Condition *con)
virtual Double_t GetYLow()
virtual Bool_t IsYMeanDraw()
virtual Bool_t IsYRMSDraw()
virtual const char * GetLabelNumFormat()
virtual Double_t GetMean(TH1 *, Int_t=1)
virtual Double_t GetYMax(TH1 *)
void AddToLabel(const char *txt)
virtual Double_t GetXUp()
virtual void RePaintLabel(Option_t *opt="")
virtual Double_t GetCMax(TH1 *)
virtual Double_t GetXMax(TH1 *)