GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitDataHistogram.cxx
Go to the documentation of this file.
1 // $Id$
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 fuer 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 <iostream>
17 
18 #include "TH1.h"
19 
20 TGo4FitDataHistogram::TGo4FitDataHistogram() : TGo4FitData(), fxHistogram(this, TH1::Class()) {}
21 
22 TGo4FitDataHistogram::TGo4FitDataHistogram(const char *iName, TH1 *iHistogram, Bool_t iHistogramOwned, Bool_t AddAmpl)
23  : TGo4FitData(iName, "TH1 and derived classes", dtHistogram, AddAmpl),
24  fxHistogram("Histogram", "Histogram object of TH1 class ", this, TH1::Class(), kTRUE, iHistogram, iHistogramOwned)
25 {
26 }
27 
29 
30 void TGo4FitDataHistogram::SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned)
31 {
33  fxHistogram.SetObject(iHistogram, iHistogramOwned);
34 }
35 
36 std::unique_ptr<TGo4FitDataIter> TGo4FitDataHistogram::MakeIter()
37 {
38  return std::make_unique<TGo4FitDataHistogramIter>(this);
39 }
40 
41 void TGo4FitDataHistogram::FillSlotList(TSeqCollection *list)
42 {
44  list->Add(&fxHistogram);
45 }
46 
47 void TGo4FitDataHistogram::Print(Option_t *option) const
48 {
49  TGo4FitData::Print(option);
50  std::cout << " ";
51  fxHistogram.Print(option);
52 }
53 
54 // *********************************************************************************
55 
57  : TGo4FitDataIter(), fxData(nullptr), fxLimits(), fxOwnScales(), fxOwnWidths()
58 {
59 }
60 
63 {
64 }
65 
67 
69 {
70  if (!fxData)
71  return kFALSE;
72  TH1 *histo = fxData->GetHistogram();
73  if (!histo)
74  return kFALSE;
75 
76  Int_t NumDimen = histo->GetDimension();
77  fxLimits.Set(NumDimen);
78  fxLimits[0] = histo->GetNbinsX();
79  if (NumDimen > 1)
80  fxLimits[1] = histo->GetNbinsY();
81  if (NumDimen > 2)
82  fxLimits[2] = histo->GetNbinsZ();
83 
84  fxOwnScales.Set(NumDimen);
85  fxOwnScales.Reset(0.);
86  fxOwnWidths.Set(NumDimen);
87  fxOwnWidths.Reset(0.);
88 
89  return ReserveArrays(NumDimen, NumDimen, kTRUE);
90 }
91 
93 {
94  if (!fxData)
95  return kFALSE;
96  TH1 *histo = fxData->GetHistogram();
97  if (!histo)
98  return kFALSE;
99 
100  switch (histo->GetDimension()) {
101  case 1: fdValue = histo->GetBinContent(fxIndexes[0] + 1); break;
102  case 2: fdValue = histo->GetBinContent(fxIndexes[0] + 1, fxIndexes[1] + 1); break;
103  case 3: fdValue = histo->GetBinContent(fxIndexes[0] + 1, fxIndexes[1] + 1, fxIndexes[2] + 1); break;
104  default: fdValue = 0;
105  }
106 
107  if (!GetDeviation())
109 
110  for (Int_t n = 0; n < fxOwnScales.GetSize(); n++)
111  switch (n) {
112  case 0: fxOwnScales[0] = histo->GetXaxis()->GetBinCenter(fxIndexes[0] + 1); break;
113  case 1: fxOwnScales[1] = histo->GetYaxis()->GetBinCenter(fxIndexes[1] + 1); break;
114  case 2: fxOwnScales[2] = histo->GetZaxis()->GetBinCenter(fxIndexes[2] + 1); break;
115  }
116 
117  for (Int_t n = 0; n < fxOwnWidths.GetSize(); n++)
118  switch (n) {
119  case 0: fxOwnWidths[0] = histo->GetXaxis()->GetBinWidth(fxIndexes[0] + 1); break;
120  case 1: fxOwnWidths[1] = histo->GetYaxis()->GetBinWidth(fxIndexes[1] + 1); break;
121  case 2: fxOwnWidths[2] = histo->GetZaxis()->GetBinWidth(fxIndexes[2] + 1); break;
122  }
123 
124  return ProduceScales(fxIndexes.GetArray(), fxOwnScales.GetArray(), fxOwnWidths.GetArray());
125 }
126 
128 {
129  return NextIndex(fxIndexes, fxLimits);
130 }
Bool_t ProduceScales(const Int_t *index, const Double_t *ownscales, const Double_t *ownwidths)
TArrayI fxIndexes
Definition: TGo4FitData.h:612
Double_t fdStandardDeviation
Definition: TGo4FitData.h:617
void SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned=kFALSE)
void Print(Option_t *option="") const override
void Print(Option_t *option="") const override
Double_t fdValue
Definition: TGo4FitData.h:616
Bool_t ReadCurrentPoint() override
Bool_t NextIndex(TArrayI &Index, TArrayI &Limits)
void Print(Option_t *option="") const override
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)
void FillSlotList(TSeqCollection *list) override
Bool_t GetDeviation()
std::unique_ptr< TGo4FitDataIter > MakeIter() override
void FillSlotList(TSeqCollection *list) override
void ClearObject()