Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4FitDataHistogram.h"
00015
00016 #include "Riostream.h"
00017 #include "TH1.h"
00018 #include "TArrayD.h"
00019 #include "TArrayF.h"
00020
00021 TGo4FitDataHistogram::TGo4FitDataHistogram() :
00022 TGo4FitData(), fxHistogram(this, TH1::Class()) {
00023 }
00024
00025 TGo4FitDataHistogram::TGo4FitDataHistogram(const char* iName, TH1 *iHistogram, Bool_t iHistogramOwned, Bool_t AddAmpl) :
00026 TGo4FitData(iName,"TH1 and derived classes", dtHistogram, AddAmpl),
00027 fxHistogram("Histogram","Histogram object of TH1 class ",this, TH1::Class(), kTRUE, iHistogram, iHistogramOwned) {
00028 }
00029
00030 TGo4FitDataHistogram::~TGo4FitDataHistogram() {
00031 }
00032
00033 void TGo4FitDataHistogram::SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned)
00034 {
00035 fxHistogram.ClearObject();
00036 fxHistogram.SetObject(iHistogram,iHistogramOwned);
00037 }
00038
00039 TGo4FitDataIter* TGo4FitDataHistogram::MakeIter() {
00040 return new TGo4FitDataHistogramIter(this);
00041 }
00042
00043 void TGo4FitDataHistogram::FillSlotList(TSeqCollection* list) {
00044 TGo4FitData::FillSlotList(list);
00045 list->Add(&fxHistogram);
00046 }
00047
00048 void TGo4FitDataHistogram::Print(Option_t* option) const {
00049 TGo4FitData::Print(option);
00050 std::cout << " ";
00051 fxHistogram.Print(option);
00052 }
00053
00054
00055
00056
00057 TGo4FitDataHistogramIter::TGo4FitDataHistogramIter() : TGo4FitDataIter(),
00058 fxData(0), fxLimits(), fxOwnScales(), fxOwnWidths() {
00059 }
00060
00061 TGo4FitDataHistogramIter::TGo4FitDataHistogramIter(TGo4FitDataHistogram* data) :
00062 TGo4FitDataIter(), fxData(data), fxLimits(), fxOwnScales(), fxOwnWidths() {
00063 }
00064
00065 TGo4FitDataHistogramIter::~TGo4FitDataHistogramIter() {
00066 }
00067
00068 Bool_t TGo4FitDataHistogramIter::StartReset()
00069 {
00070 if (fxData==0) return kFALSE;
00071 TH1* histo = fxData->GetHistogram();
00072 if (histo==0) return kFALSE;
00073
00074 Int_t NumDimen = histo->GetDimension();
00075 fxLimits.Set(NumDimen);
00076 fxLimits[0] = histo->GetNbinsX();
00077 if (NumDimen>1) fxLimits[1] = histo->GetNbinsY();
00078 if (NumDimen>2) fxLimits[2] = histo->GetNbinsZ();
00079
00080 fxOwnScales.Set(NumDimen); fxOwnScales.Reset(0.);
00081 fxOwnWidths.Set(NumDimen); fxOwnWidths.Reset(0.);
00082
00083 return ReserveArrays(NumDimen, NumDimen, kTRUE);
00084 }
00085
00086 Bool_t TGo4FitDataHistogramIter::ReadCurrentPoint()
00087 {
00088 if (fxData==0) return kFALSE;
00089 TH1* histo = fxData->GetHistogram();
00090 if (histo==0) return kFALSE;
00091
00092 switch (histo->GetDimension()) {
00093 case 1: fdValue = histo->GetBinContent(fxIndexes[0]+1); break;
00094 case 2: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1); break;
00095 case 3: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1, fxIndexes[2]+1); break;
00096 default: fdValue = 0;
00097 }
00098
00099 if (!GetDeviation()) fdStandardDeviation = fdValue;
00100
00101 for (Int_t n=0;n<fxOwnScales.GetSize();n++)
00102 switch (n) {
00103 case 0: fxOwnScales[0] = histo->GetXaxis()->GetBinCenter(fxIndexes[0]+1); break;
00104 case 1: fxOwnScales[1] = histo->GetYaxis()->GetBinCenter(fxIndexes[1]+1); break;
00105 case 2: fxOwnScales[2] = histo->GetZaxis()->GetBinCenter(fxIndexes[2]+1); break;
00106 }
00107
00108 for (Int_t n=0;n<fxOwnWidths.GetSize();n++)
00109 switch (n) {
00110 case 0: fxOwnWidths[0] = histo->GetXaxis()->GetBinWidth(fxIndexes[0]+1); break;
00111 case 1: fxOwnWidths[1] = histo->GetYaxis()->GetBinWidth(fxIndexes[1]+1); break;
00112 case 2: fxOwnWidths[2] = histo->GetZaxis()->GetBinWidth(fxIndexes[2]+1); break;
00113 }
00114
00115 return ProduceScales(fxIndexes.GetArray(), fxOwnScales.GetArray(), fxOwnWidths.GetArray());
00116 }
00117
00118 Bool_t TGo4FitDataHistogramIter::ShiftToNextPoint() {
00119 return NextIndex(fxIndexes,fxLimits);
00120 }