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