Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ConditionPainter.h"
00015
00016 #include "TVirtualPad.h"
00017 #include "TCutG.h"
00018 #include "TH1.h"
00019 #include "snprintf.h"
00020
00021 #include "TGo4Condition.h"
00022 #include "TGo4WinCond.h"
00023 #include "TGo4PolyCond.h"
00024
00025 TGo4ConditionPainter::TGo4ConditionPainter()
00026 : TGo4LabelPainter(), fxCondition(0)
00027 {
00028 }
00029
00030 TGo4ConditionPainter::TGo4ConditionPainter(const char* name, const char* title)
00031 : TGo4LabelPainter(name, title ? title : "Go4 ConditionPainter"), fxCondition(0)
00032 {
00033 }
00034
00035 TGo4ConditionPainter::~TGo4ConditionPainter()
00036 {
00037 UnPaintCondition();
00038 }
00039
00040
00041
00042 void TGo4ConditionPainter::PaintCondition(Option_t*)
00043 {
00044
00045
00046 }
00047
00048 void TGo4ConditionPainter::UnPaintCondition(Option_t*)
00049 {
00050
00051
00052 }
00053
00054 void TGo4ConditionPainter::PaintLabel(Option_t* opt)
00055 {
00056 if(gPad==0) return;
00057 if(fxCondition && fxCondition->IsVisible())
00058 {
00059
00060 Double_t xpmin=0;
00061 Double_t ypmin=0;
00062 TGo4WinCond* wconny=dynamic_cast<TGo4WinCond*>(fxCondition);
00063 TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
00064 if(wconny)
00065 {
00066 Double_t xpmax=0; Double_t ypmax=0; Int_t dim=0;
00067 wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
00068 if(ypmin==0) ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
00069 }
00070 else if(pconny)
00071 {
00072 TCutG* cutg=pconny->GetCut(kFALSE);
00073 if(cutg) cutg->GetPoint(0,xpmin,ypmin);
00074 }
00075 else
00076 {
00077 xpmin=(gPad->GetUxmax()-gPad->GetUxmin())/2;
00078 ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
00079 }
00080
00081 Bool_t haslabel=fxCondition->IsLabelDraw();
00082 Bool_t drlimits=fxCondition->IsLimitsDraw();
00083 Bool_t drint=fxCondition->IsIntDraw();
00084 Bool_t drxmean=fxCondition->IsXMeanDraw();
00085 Bool_t drxrms=fxCondition->IsXRMSDraw();
00086 Bool_t drymean=fxCondition->IsYMeanDraw();
00087 Bool_t dryrms=fxCondition->IsYRMSDraw();
00088 Bool_t drxmax=fxCondition->IsXMaxDraw();
00089 Bool_t drymax=fxCondition->IsYMaxDraw();
00090 Bool_t drcmax=fxCondition->IsCMaxDraw();
00091 Bool_t isarray=fxCondition->IsArrayType();
00092 Bool_t ismulti=fxCondition->IsMultiEdit();
00093 TString fmt=fxCondition->GetLabelNumFormat();
00094 TH1* histogram=fxCondition->GetWorkHistogram();
00095
00096 if((isarray && !ismulti) || !haslabel)
00097 {
00098
00099 UnPaintLabel();
00100 }
00101 else
00102 {
00103
00104 Double_t xoff=0.015*(gPad->GetUxmax()-gPad->GetUxmin());
00105 Double_t yoff=0.015*(gPad->GetUymax()-gPad->GetUymin());
00106 SetX0( gPad->PadtoX( gPad->XtoPad(xpmin) + xoff));
00107 SetY0( gPad->PadtoY( gPad->YtoPad(ypmin) + yoff));
00108 SetLineColor(fxCondition->GetLineColor());
00109 TString cap=fxCondition->GetName();
00110 TH1* his=fxCondition->GetWorkHistogram();
00111 if(his)
00112 {
00113 cap+=":";
00114 cap+=his->GetName();
00115 }
00116 SetCaption(cap.Data());
00117 TGo4LabelPainter::PaintLabel();
00118 if(drlimits)
00119 {
00120 AddToLabel(Form(Form("X1 = %s",fmt.Data()),fxCondition->GetXLow()));
00121 AddToLabel(Form(Form("X2 = %s",fmt.Data()),fxCondition->GetXUp()));
00122 if(fxCondition->GetDimension()>1)
00123 {
00124 AddToLabel(Form(Form("Y1 = %s",fmt.Data()),fxCondition->GetYLow()));
00125 AddToLabel(Form(Form("Y2 = %s",fmt.Data()),fxCondition->GetYUp()));
00126 }
00127 }
00128 if(drint)
00129 AddToLabel(Form(Form("Int = %s",fmt.Data()),fxCondition->GetIntegral(histogram)));
00130 if(drxmean)
00131 AddToLabel(Form(Form("Xmean = %s",fmt.Data()),fxCondition->GetMean(histogram,1)));
00132 if(drxrms)
00133 AddToLabel(Form(Form("Xrms = %s",fmt.Data()),fxCondition->GetRMS(histogram,1)));
00134 if(drxmax)
00135 AddToLabel(Form(Form("Xmax = %s",fmt.Data()),fxCondition->GetXMax(histogram)));
00136 if(drymean)
00137 AddToLabel(Form(Form("Ymean = %s",fmt.Data()),fxCondition->GetMean(histogram,2)));
00138 if(dryrms)
00139 AddToLabel(Form(Form("Yrms = %s",fmt.Data()),fxCondition->GetRMS(histogram,2)));
00140 if(drymax)
00141 AddToLabel(Form(Form("Ymax = %s",fmt.Data()),fxCondition->GetYMax(histogram)));
00142 if(drcmax)
00143 AddToLabel(Form(Form("Cmax = %s",fmt.Data()),fxCondition->GetCMax(histogram)));
00144 RePaintLabel();
00145 }
00146 }
00147 else
00148 {
00149 UnPaintLabel();
00150 }
00151 }
00152
00153 void TGo4ConditionPainter::SetCondition(TGo4Condition* con)
00154 {
00155 fxCondition=con;
00156 }
00157
00158