00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "TPaveStatsEditor.h"
00031 #include "TGButton.h"
00032 #include "TPaveStats.h"
00033
00034 ClassImp(TPaveStatsEditor)
00035
00036 enum EPaveStatsWid {
00037 kSTAT_NAME,
00038 kSTAT_ENTRIES,
00039 kSTAT_MEAN,
00040 kSTAT_RMS,
00041 kSTAT_UNDER,
00042 kSTAT_OVER,
00043 kSTAT_INTEGRAL,
00044 kSTAT_SKEWNESS,
00045 kSTAT_KURTOSIS,
00046 kSTAT_ERR,
00047 kFIT_NAME,
00048 kFIT_ERR,
00049 kFIT_CHI,
00050 kFIT_PROB
00051 };
00052
00053
00054
00055 TPaveStatsEditor::TPaveStatsEditor(const TGWindow *p, Int_t width, Int_t height,
00056 UInt_t options, Pixel_t back) :
00057 TGedFrame(p, width, height, options | kVerticalFrame, back)
00058 {
00059
00060
00061 fPaveStats = 0;
00062
00063 MakeTitle("Stat Options");
00064
00065 TGCompositeFrame *f1 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00066 TGCompositeFrame *f2 = new TGCompositeFrame(f1, 40, 20, kVerticalFrame);
00067 f1->AddFrame(f2, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
00068
00069 fHistoName = new TGCheckButton(f2, "Name", kSTAT_NAME);
00070 fHistoName->SetToolTipText("Print the histogram name");
00071 f2->AddFrame(fHistoName, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00072 fOverflow = new TGCheckButton(f2, "Overflow", kSTAT_OVER);
00073 fOverflow->SetToolTipText("Print the number of overflows");
00074 f2->AddFrame(fOverflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00075 fUnderflow = new TGCheckButton(f2, "Underflow", kSTAT_UNDER);
00076 fUnderflow->SetToolTipText("Print the number of underflows");
00077 f2->AddFrame(fUnderflow, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00078 fSkewness = new TGCheckButton(f2, "Skewness", kSTAT_SKEWNESS);
00079 fSkewness->SetToolTipText("Print the skewness");
00080 f2->AddFrame(fSkewness, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00081 fKurtosis = new TGCheckButton(f2, "Kurtosis", kSTAT_KURTOSIS);
00082 fKurtosis->SetToolTipText("Print the kurtosis");
00083 f2->AddFrame(fKurtosis, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00084
00085 TGCompositeFrame *f3 = new TGCompositeFrame(f1, 40, 20, kVerticalFrame);
00086 fEntries = new TGCheckButton(f3, "Entries", kSTAT_ENTRIES);
00087 fEntries->SetToolTipText("Print the number of entries");
00088 f3->AddFrame(fEntries, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00089 fMean = new TGCheckButton(f3, "Mean", kSTAT_MEAN);
00090 fMean->SetToolTipText("Print the mean value");
00091 f3->AddFrame(fMean, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00092 fRMS = new TGCheckButton(f3, "RMS", kSTAT_RMS);
00093 fRMS->SetToolTipText("Print root-mean-square (RMS)");
00094 f3->AddFrame(fRMS, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00095 fIntegral = new TGCheckButton(f3, "Integral", kSTAT_INTEGRAL);
00096 fIntegral->SetToolTipText("Print the integral of bins");
00097 f3->AddFrame(fIntegral, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00098 fStatsErrors = new TGCheckButton(f3, "Errors", kSTAT_ERR);
00099 fStatsErrors->SetToolTipText("Print the errors");
00100 f3->AddFrame(fStatsErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 5));
00101 f1->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
00102
00103 AddFrame(f1, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00104
00105 MakeTitle("Fit Options");
00106
00107 TGCompositeFrame *f4 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00108 TGCompositeFrame *f5 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
00109 f4->AddFrame(f5, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
00110
00111 fNameValues = new TGCheckButton(f5, "Values", kFIT_NAME);
00112 fNameValues->SetToolTipText("Print the parameter name and value");
00113 f5->AddFrame(fNameValues, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00114 fProbability = new TGCheckButton(f5, "Probability", kFIT_PROB);
00115 fProbability->SetToolTipText("Print probability");
00116 f5->AddFrame(fProbability, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00117
00118 TGCompositeFrame *f6 = new TGCompositeFrame(f4, 40, 20, kVerticalFrame);
00119 fErrors = new TGCheckButton(f6, "Errors", kFIT_ERR);
00120 fErrors->SetToolTipText("Print the errors");
00121 f6->AddFrame(fErrors, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00122 fChisquare = new TGCheckButton(f6, "Chi", kFIT_CHI);
00123 fChisquare->SetToolTipText("Print Chisquare");
00124 f6->AddFrame(fChisquare, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00125 f4->AddFrame(f6, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
00126
00127 AddFrame(f4, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00128 }
00129
00130
00131 TPaveStatsEditor::~TPaveStatsEditor()
00132 {
00133
00134 }
00135
00136
00137 void TPaveStatsEditor::ConnectSignals2Slots()
00138 {
00139
00140
00141
00142 fHistoName->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00143 fEntries->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00144 fOverflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00145 fMean->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00146 fUnderflow->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00147 fRMS->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00148 fIntegral->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00149 fSkewness->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00150 fKurtosis->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00151 fStatsErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoStatOptions()");
00152
00153
00154 fNameValues->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
00155 fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
00156 fErrors->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"SetValuesON(Bool_t");
00157 fProbability->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
00158 fChisquare->Connect("Toggled(Bool_t)","TPaveStatsEditor",this,"DoFitOptions()");
00159
00160 fInit = kFALSE;
00161 }
00162
00163
00164 void TPaveStatsEditor::SetModel(TObject* obj)
00165 {
00166
00167
00168 fPaveStats = (TPaveStats *)obj;
00169 fAvoidSignal = kTRUE;
00170
00171 Int_t stat = fPaveStats->GetOptStat();
00172
00173 if (stat % 10) fHistoName->SetState(kButtonDown);
00174 else fHistoName->SetState(kButtonUp);
00175
00176 if (stat/10 % 10) fEntries->SetState(kButtonDown);
00177 else fEntries->SetState(kButtonUp);
00178
00179 if (stat/100 % 10) fMean->SetState(kButtonDown);
00180 else fMean->SetState(kButtonUp);
00181
00182 if (stat/1000 % 10) fRMS->SetState(kButtonDown);
00183 else fRMS->SetState(kButtonUp);
00184
00185 if (stat/10000 % 10) fUnderflow->SetState(kButtonDown);
00186 else fUnderflow->SetState(kButtonUp);
00187
00188 if (stat/100000 % 10) fOverflow->SetState(kButtonDown);
00189 else fOverflow->SetState(kButtonUp);
00190
00191 if (stat/1000000 % 10) fIntegral->SetState(kButtonDown);
00192 else fIntegral->SetState(kButtonUp);
00193
00194 if (stat/10000000 % 10) fSkewness->SetState(kButtonDown);
00195 else fSkewness->SetState(kButtonUp);
00196
00197 if (stat/100000000 % 10) fKurtosis->SetState(kButtonDown);
00198 else fKurtosis->SetState(kButtonUp);
00199
00200 Int_t fit = fPaveStats->GetOptFit();
00201 if (fit % 10) fNameValues->SetState(kButtonDown);
00202 else fNameValues->SetState(kButtonUp);
00203
00204 if (fit/10 % 10) {
00205 fErrors->SetState(kButtonDown);
00206 fNameValues->SetState(kButtonDown);
00207 } else {
00208 fErrors->SetState(kButtonUp);
00209 }
00210
00211 if (fit/100 % 10) fChisquare->SetState(kButtonDown);
00212 else fChisquare->SetState(kButtonUp);
00213
00214 if (fit/1000 % 10) fProbability->SetState(kButtonDown);
00215 else fProbability->SetState(kButtonUp);
00216
00217 if (fInit) ConnectSignals2Slots();
00218
00219 fAvoidSignal = kFALSE;
00220 }
00221
00222
00223 void TPaveStatsEditor::DoStatOptions()
00224 {
00225
00226
00227 if (fAvoidSignal) return;
00228 Int_t stat = 0;
00229 if (fHistoName->GetState() == kButtonDown) stat +=1;
00230 if (fEntries->GetState() == kButtonDown) stat +=10;
00231 if (fMean->GetState() == kButtonDown) stat +=100;
00232 if (fRMS->GetState() == kButtonDown) stat +=1000;
00233 if (fUnderflow->GetState() == kButtonDown) stat +=10000;
00234 if (fOverflow->GetState() == kButtonDown) stat +=100000;
00235 if (fIntegral->GetState() == kButtonDown) stat +=1000000;
00236 if (fSkewness->GetState() == kButtonDown) stat +=10000000;
00237 if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
00238 if (fStatsErrors->GetState() == kButtonDown) {
00239 if (fMean->GetState() == kButtonDown) stat +=100;
00240 if (fRMS->GetState() == kButtonDown) stat +=1000;
00241 if (fSkewness->GetState() == kButtonDown) stat +=10000000;
00242 if (fKurtosis->GetState() == kButtonDown) stat +=100000000;
00243 }
00244
00245 if (!stat) {
00246 stat = 1;
00247 fHistoName->SetState(kButtonDown);
00248 }
00249 if (stat == 1) stat = 1000000001;
00250 fPaveStats->SetOptStat(stat);
00251 Update();
00252 }
00253
00254
00255 void TPaveStatsEditor::DoFitOptions()
00256 {
00257
00258
00259 if (fAvoidSignal) return;
00260 Int_t fit = 0;
00261 if (fNameValues->GetState() == kButtonDown) fit +=1;
00262 if (fErrors->GetState() == kButtonDown) fit +=10;
00263 if (fChisquare->GetState() == kButtonDown) fit +=100;
00264 if (fProbability->GetState() == kButtonDown) fit +=1000;
00265
00266 if (fit == 1) fit = 10001;
00267 fPaveStats->SetOptFit(fit);
00268 Update();
00269 }
00270
00271
00272 void TPaveStatsEditor::SetValuesON(Bool_t on)
00273 {
00274
00275
00276
00277 if (fAvoidSignal) return;
00278 if (on == kTRUE) fNameValues->SetState(kButtonDown);
00279 }