TGo4FitDataHistogram.cxx

Go to the documentation of this file.
00001 // $Id: TGo4FitDataHistogram.cxx 578 2010-02-17 09:35:37Z linev $
00002 //-----------------------------------------------------------------------
00003 //       The GSI Online Offline Object Oriented (Go4) Project
00004 //         Experiment Data Processing at EE department, GSI
00005 //-----------------------------------------------------------------------
00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
00007 //                     Planckstr. 1, 64291 Darmstadt, Germany
00008 // Contact:            http://go4.gsi.de
00009 //-----------------------------------------------------------------------
00010 // This software can be used under the license agreements as stated
00011 // in Go4License.txt file which is part of the distribution.
00012 //-----------------------------------------------------------------------
00013 
00014 #include "TGo4FitDataHistogram.h"
00015 
00016 #include "Riostream.h"
00017 
00018 #include "TH1.h"
00019 #include "TArrayD.h"
00020 #include "TArrayF.h"
00021 
00022 TGo4FitDataHistogram::TGo4FitDataHistogram() :
00023   TGo4FitData(), fxHistogram(this, TH1::Class()) {
00024 }
00025 
00026 TGo4FitDataHistogram::TGo4FitDataHistogram(const char* iName, TH1 *iHistogram, Bool_t iHistogramOwned, Bool_t AddAmpl) :
00027   TGo4FitData(iName,"TH1 and derived classes", dtHistogram, AddAmpl),
00028   fxHistogram("Histogram","Histogram object of TH1 class ",this, TH1::Class(), kTRUE, iHistogram, iHistogramOwned) {
00029 }
00030 
00031 TGo4FitDataHistogram::~TGo4FitDataHistogram() {
00032 }
00033 
00034 void TGo4FitDataHistogram::SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned)
00035 {
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    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 }

Generated on Thu Oct 28 15:54:12 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1