GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitDataHistogram.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitDataHistogram.cxx 992 2013-07-08 09:09:31Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4FitDataHistogram.h"
15 
16 #include "Riostream.h"
17 #include "TH1.h"
18 #include "TArrayD.h"
19 #include "TArrayF.h"
20 
22  TGo4FitData(), fxHistogram(this, TH1::Class()) {
23 }
24 
25 TGo4FitDataHistogram::TGo4FitDataHistogram(const char* iName, TH1 *iHistogram, Bool_t iHistogramOwned, Bool_t AddAmpl) :
26  TGo4FitData(iName,"TH1 and derived classes", dtHistogram, AddAmpl),
27  fxHistogram("Histogram","Histogram object of TH1 class ",this, TH1::Class(), kTRUE, iHistogram, iHistogramOwned) {
28 }
29 
31 }
32 
33 void TGo4FitDataHistogram::SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned)
34 {
36  fxHistogram.SetObject(iHistogram,iHistogramOwned);
37 }
38 
40  return new TGo4FitDataHistogramIter(this);
41 }
42 
43 void TGo4FitDataHistogram::FillSlotList(TSeqCollection* list) {
45  list->Add(&fxHistogram);
46 }
47 
48 void TGo4FitDataHistogram::Print(Option_t* option) const {
49  TGo4FitData::Print(option);
50  std::cout << " ";
51  fxHistogram.Print(option);
52 }
53 
54 // *********************************************************************************
55 
56 
58  fxData(0), fxLimits(), fxOwnScales(), fxOwnWidths() {
59 }
60 
62  TGo4FitDataIter(), fxData(data), fxLimits(), fxOwnScales(), fxOwnWidths() {
63 }
64 
66 }
67 
69 {
70  if (fxData==0) return kFALSE;
71  TH1* histo = fxData->GetHistogram();
72  if (histo==0) return kFALSE;
73 
74  Int_t NumDimen = histo->GetDimension();
75  fxLimits.Set(NumDimen);
76  fxLimits[0] = histo->GetNbinsX();
77  if (NumDimen>1) fxLimits[1] = histo->GetNbinsY();
78  if (NumDimen>2) fxLimits[2] = histo->GetNbinsZ();
79 
80  fxOwnScales.Set(NumDimen); fxOwnScales.Reset(0.);
81  fxOwnWidths.Set(NumDimen); fxOwnWidths.Reset(0.);
82 
83  return ReserveArrays(NumDimen, NumDimen, kTRUE);
84 }
85 
87 {
88  if (fxData==0) return kFALSE;
89  TH1* histo = fxData->GetHistogram();
90  if (histo==0) return kFALSE;
91 
92  switch (histo->GetDimension()) {
93  case 1: fdValue = histo->GetBinContent(fxIndexes[0]+1); break;
94  case 2: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1); break;
95  case 3: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1, fxIndexes[2]+1); break;
96  default: fdValue = 0;
97  }
98 
100 
101  for (Int_t n=0;n<fxOwnScales.GetSize();n++)
102  switch (n) {
103  case 0: fxOwnScales[0] = histo->GetXaxis()->GetBinCenter(fxIndexes[0]+1); break;
104  case 1: fxOwnScales[1] = histo->GetYaxis()->GetBinCenter(fxIndexes[1]+1); break;
105  case 2: fxOwnScales[2] = histo->GetZaxis()->GetBinCenter(fxIndexes[2]+1); break;
106  }
107 
108  for (Int_t n=0;n<fxOwnWidths.GetSize();n++)
109  switch (n) {
110  case 0: fxOwnWidths[0] = histo->GetXaxis()->GetBinWidth(fxIndexes[0]+1); break;
111  case 1: fxOwnWidths[1] = histo->GetYaxis()->GetBinWidth(fxIndexes[1]+1); break;
112  case 2: fxOwnWidths[2] = histo->GetZaxis()->GetBinWidth(fxIndexes[2]+1); break;
113  }
114 
115  return ProduceScales(fxIndexes.GetArray(), fxOwnScales.GetArray(), fxOwnWidths.GetArray());
116 }
117 
119  return NextIndex(fxIndexes,fxLimits);
120 }
Bool_t ProduceScales(const Int_t *index, const Double_t *ownscales, const Double_t *ownwidths)
TArrayI fxIndexes
Definition: TGo4FitData.h:617
Double_t fdStandardDeviation
Definition: TGo4FitData.h:622
void SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned=kFALSE)
virtual void Print(Option_t *option) const
Double_t fdValue
Definition: TGo4FitData.h:621
TGo4FitDataIter * MakeIter()
Bool_t NextIndex(TArrayI &Index, TArrayI &Limits)
virtual void FillSlotList(TSeqCollection *list)
Bool_t SetObject(TObject *iObject, Bool_t iOwned=kFALSE, Bool_t CheckClass=kTRUE)
TGo4FitDataHistogram * fxData
Bool_t ReserveArrays(Int_t NumDimen, Int_t NumOwnAxis, Bool_t HasWidth)
virtual void FillSlotList(TSeqCollection *list)
Bool_t GetDeviation()
virtual void Print(Option_t *option) const
void ClearObject()
virtual void Print(Option_t *option) const