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