GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitDataHistogram.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitDataHistogram.cxx 2749 2020-04-16 10:05:15Z 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 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 
21  TGo4FitData(), fxHistogram(this, TH1::Class()) {
22 }
23 
24 TGo4FitDataHistogram::TGo4FitDataHistogram(const char* iName, TH1 *iHistogram, Bool_t iHistogramOwned, Bool_t AddAmpl) :
25  TGo4FitData(iName,"TH1 and derived classes", dtHistogram, AddAmpl),
26  fxHistogram("Histogram","Histogram object of TH1 class ",this, TH1::Class(), kTRUE, iHistogram, iHistogramOwned) {
27 }
28 
30 }
31 
32 void TGo4FitDataHistogram::SetHistogram(TH1 *iHistogram, Bool_t iHistogramOwned)
33 {
35  fxHistogram.SetObject(iHistogram,iHistogramOwned);
36 }
37 
39  return new TGo4FitDataHistogramIter(this);
40 }
41 
42 void TGo4FitDataHistogram::FillSlotList(TSeqCollection* list) {
44  list->Add(&fxHistogram);
45 }
46 
47 void TGo4FitDataHistogram::Print(Option_t* option) const {
48  TGo4FitData::Print(option);
49  std::cout << " ";
50  fxHistogram.Print(option);
51 }
52 
53 // *********************************************************************************
54 
55 
57  fxData(0), fxLimits(), fxOwnScales(), fxOwnWidths() {
58 }
59 
61  TGo4FitDataIter(), fxData(data), fxLimits(), fxOwnScales(), fxOwnWidths() {
62 }
63 
65 }
66 
68 {
69  if (fxData==0) return kFALSE;
70  TH1* histo = fxData->GetHistogram();
71  if (histo==0) return kFALSE;
72 
73  Int_t NumDimen = histo->GetDimension();
74  fxLimits.Set(NumDimen);
75  fxLimits[0] = histo->GetNbinsX();
76  if (NumDimen>1) fxLimits[1] = histo->GetNbinsY();
77  if (NumDimen>2) fxLimits[2] = histo->GetNbinsZ();
78 
79  fxOwnScales.Set(NumDimen); fxOwnScales.Reset(0.);
80  fxOwnWidths.Set(NumDimen); fxOwnWidths.Reset(0.);
81 
82  return ReserveArrays(NumDimen, NumDimen, kTRUE);
83 }
84 
86 {
87  if (fxData==0) return kFALSE;
88  TH1* histo = fxData->GetHistogram();
89  if (histo==0) return kFALSE;
90 
91  switch (histo->GetDimension()) {
92  case 1: fdValue = histo->GetBinContent(fxIndexes[0]+1); break;
93  case 2: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1); break;
94  case 3: fdValue = histo->GetBinContent(fxIndexes[0]+1, fxIndexes[1]+1, fxIndexes[2]+1); break;
95  default: fdValue = 0;
96  }
97 
99 
100  for (Int_t n=0;n<fxOwnScales.GetSize();n++)
101  switch (n) {
102  case 0: fxOwnScales[0] = histo->GetXaxis()->GetBinCenter(fxIndexes[0]+1); break;
103  case 1: fxOwnScales[1] = histo->GetYaxis()->GetBinCenter(fxIndexes[1]+1); break;
104  case 2: fxOwnScales[2] = histo->GetZaxis()->GetBinCenter(fxIndexes[2]+1); break;
105  }
106 
107  for (Int_t n=0;n<fxOwnWidths.GetSize();n++)
108  switch (n) {
109  case 0: fxOwnWidths[0] = histo->GetXaxis()->GetBinWidth(fxIndexes[0]+1); break;
110  case 1: fxOwnWidths[1] = histo->GetYaxis()->GetBinWidth(fxIndexes[1]+1); break;
111  case 2: fxOwnWidths[2] = histo->GetZaxis()->GetBinWidth(fxIndexes[2]+1); break;
112  }
113 
114  return ProduceScales(fxIndexes.GetArray(), fxOwnScales.GetArray(), fxOwnWidths.GetArray());
115 }
116 
118  return NextIndex(fxIndexes,fxLimits);
119 }
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