GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitData.h
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 #ifndef TGO4FITDATA_H
15 #define TGO4FITDATA_H
16 
17 #include "TGo4FitComponent.h"
18 
19 #include "TArrayI.h"
20 #include "TArrayD.h"
21 #include <memory>
22 #include "RVersion.h"
23 
24 #if ROOT_VERSION_CODE < ROOT_VERSION(6,26,0)
25 #include "ROOT/RMakeUnique.hxx"
26 #endif
27 
28 class TH1;
29 class TGraph;
30 class TGo4FitSlot;
31 
32 class TGo4FitAxisTrans;
33 class TGo4FitDataIter;
34 
38 class TGo4FitData : public TGo4FitComponent {
39  public:
40  enum { dtHistogram = 1, dtGraph = 2 };
41 
45  TGo4FitData();
46 
53  TGo4FitData(const char *iName, const char *iTitle, Int_t iDataType = dtHistogram, Bool_t AddAmpl = kFALSE);
54 
58  virtual ~TGo4FitData();
59 
63  Int_t GetDataType() const { return fiDataType; }
64 
68  Bool_t GetUseBinScale() const { return fbUseBinScale; }
69 
73  void SetUseBinScale(Bool_t iUseBinScale) { fbUseBinScale = iUseBinScale; }
74 
80  Bool_t CanAmplTouch() override { return kTRUE; }
81 
89  Int_t GetSigmaSource() const { return fiTakeSigmasFrom; }
90 
95  Double_t GetSigmaValue() const { return fdSigmaValue; }
96 
101  void SetSigmaSource(Int_t TakeFrom, Double_t SigmaValue = 1.)
102  {
103  fiTakeSigmasFrom = TakeFrom;
104  if ((TakeFrom == 2) && (SigmaValue > 0))
105  fdSigmaValue = SigmaValue;
106  }
107 
112  void SetSigmaValue(Double_t SigmaValue) { fdSigmaValue = SigmaValue; }
113 
117  void SetExcludeLessThen(Double_t limit = 0.) { fdExcludeLessThen = limit; }
118 
122  Double_t GetExcludeLessThen() const { return fdExcludeLessThen; }
123 
131  Bool_t SetNumberOfTransSlots(Int_t nslots);
132 
136  Int_t GetNumberOfTransSlots() const { return fxAxisTrans.GetLast()+1; }
137 
141  TGo4FitSlot *GetAxisTransSlot(Int_t nslot) const;
142 
146  TGo4FitAxisTrans *GetAxisTrans(Int_t nslot) const;
147 
152  void SetAxisTrans(Int_t nslot, TGo4FitAxisTrans *Trans, Bool_t TransOwned = kFALSE);
153 
158  void AddAxisTrans(TGo4FitAxisTrans *Trans, Bool_t TransOwned = kFALSE);
159 
163  void SetAxisTransNeeded(Int_t nslot, Bool_t iNeeded = kFALSE);
164 
169  virtual Bool_t IsAnyDataTransform() const;
170 
175  virtual std::unique_ptr<TGo4FitDataIter> MakeIter() { return nullptr; }
176 
181  TObject *CreateDrawObject(const char *ObjName);
182 
187  Bool_t DefineScaleMinMax(Int_t naxis, Double_t& min, Double_t& max);
188 
193  Int_t DefineDimensions();
194 
199  Int_t DefineBinsSize();
200 
206  Bool_t IsCompatibleData(TGo4FitData *data);
207 
214  void ApplyRangesForModelMask(TGo4FitComponent *model, Char_t *ModelMask);
215 
219  void FillSlotList(TSeqCollection *list) override;
220 
224  void Print(Option_t *option = "") const override;
225 
226  protected:
227 
228  friend class TGo4FitModel;
229  friend class TGo4Fitter;
230 
238  virtual Bool_t Initialize(Int_t UseBuffers = -1);
239 
243  virtual void Finalize();
244 
248  Bool_t BuffersAllocated() const { return fxValues && fxFullScale; }
249 
253  Int_t GetBinsSize() const { return fiBinsSize; }
254 
259  Int_t GetScalesSize() const { return fiScalesSize; }
260 
265  Double_t *GetBinsValues() const { return fxValues; }
266 
271  Double_t *GetBinsDevs() const { return fxStandDev; }
272 
277  Double_t *GetBinsResult() const { return fxBinsResult; }
278 
283  const Double_t *GetScaleValues(Int_t nbin) const;
284 
289  const Double_t *GetWidthValues(Int_t nbin) const;
290 
295  const Int_t *GetFullIndex(Int_t nbin) const;
296 
301  Int_t GetIndexesSize() const { return fiIndexesSize; }
302 
307  Int_t fiDataType{0};
308 
313  Bool_t fbUseBinScale{kFALSE};
314 
320 
324  Double_t fdSigmaValue{0};
325 
329  Double_t fdExcludeLessThen{0};
330 
334  TObjArray fxAxisTrans;
335 
336  private:
337 
341  void ResetAllPoinetrs();
342 
346  void ReleaseAllPointers();
347 
351  Int_t fiBinsSize{0};
352 
356  Int_t fiIndexesSize{0};
357 
361  Int_t fiScalesSize{0};
362 
366  Double_t *fxValues{nullptr};
367 
371  Double_t *fxStandDev{nullptr};
372 
376  Double_t *fxBinsResult{nullptr};
377 
383  Double_t *fxFullScale{nullptr};
384 
390  Double_t *fxFullWidth{nullptr};
391 
397  Int_t *fxFullIndex{nullptr};
398 
399  ClassDefOverride(TGo4FitData,1)
400 };
401 
418 class TGo4FitDataIter : public TObject {
419  public:
420 
424  TGo4FitDataIter();
425 
429  virtual ~TGo4FitDataIter();
430 
436  virtual Bool_t Reset(Bool_t UseRanges = kTRUE);
437 
444  virtual Bool_t Next(Bool_t UseRanges = kTRUE);
445 
449  Bool_t HasIndexes() const { return IndexesSize() > 0; }
450 
454  Int_t IndexesSize() const { return fxIndexes.GetSize(); }
455 
459  const Int_t *Indexes() const { return fxIndexes.GetArray(); }
460 
464  Bool_t DefineIndexesLimits(TArrayI& Limits);
465 
469  Int_t ScalesSize() const { return fxScales.GetSize(); }
470 
474  const Double_t *Scales() const { return fxScales.GetSize() > 0 ? fxScales.GetArray() : nullptr; }
475 
479  Double_t x() const { return fxScales.GetSize() > 0 ? fxScales[0] : 0.; }
480 
484  Double_t y() const { return fxScales.GetSize() > 1 ? fxScales[1] : 0.; }
485 
489  Double_t z() const { return fxScales.GetSize() > 2 ? fxScales[2] : 0.; }
490 
494  Bool_t HasWidths() const { return fxWidths.GetSize() > 0; }
495 
499  const Double_t *Widths() const { return fxWidths.GetSize() > 0 ? fxWidths.GetArray() : nullptr; }
500 
504  Double_t xWidths() const;
505 
509  Double_t Value() const { return fdValue; }
510 
514  Double_t StandardDeviation() const { return fdStandardDeviation; }
515 
519  Int_t Point() const { return fiNumPoint; }
520 
524  Bool_t CheckPointForRange();
525 
530  Int_t CountPoints(Bool_t UseRanges = kTRUE);
531 
536  Bool_t ReachEnd() const { return fbReachEnd; }
537 
543  TH1 *CreateHistogram(const char *HistoName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
544 
552  TGraph *CreateGraph(const char *GraphName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
553 
557  TObject *CreateDrawObject(const char *ObjName);
558 
559  protected:
560 
565  virtual TGo4FitData *GetData() const = 0;
566 
571  virtual Bool_t StartReset() = 0;
572 
577  virtual Bool_t ReadCurrentPoint() = 0;
578 
583  virtual Bool_t ShiftToNextPoint() = 0;
584 
589  Bool_t ReserveArrays(Int_t NumDimen, Int_t NumOwnAxis, Bool_t HasWidth);
590 
594  void TransformScales(Double_t *scales);
595 
600  Bool_t ProduceScales(const Int_t *index, const Double_t *ownscales, const Double_t *ownwidths);
601 
605  Bool_t NextIndex(TArrayI& Index, TArrayI& Limits);
606 
610  Bool_t GetDeviation();
611 
612  TArrayI fxIndexes;
613 
614  TArrayD fxScales;
615  TArrayD fxWidths;
616  Double_t fdValue{0.};
617  Double_t fdStandardDeviation{0.};
618 
619  Int_t fiNumPoint{0};
620 
621  Bool_t fbReachEnd{kFALSE};
622 
623  ClassDefOverride(TGo4FitDataIter,1)
624 };
625 
626 
627 #endif // TGO4FITDATA_H
Bool_t DefineScaleMinMax(Int_t naxis, Double_t &min, Double_t &max)
Int_t fiBinsSize
Definition: TGo4FitData.h:351
TArrayD fxWidths
Definition: TGo4FitData.h:615
TArrayI fxIndexes
Definition: TGo4FitData.h:612
Int_t GetSigmaSource() const
Definition: TGo4FitData.h:89
Double_t fdSigmaValue
Definition: TGo4FitData.h:324
void Print(Option_t *option="") const override
Double_t * fxBinsResult
Definition: TGo4FitData.h:376
Double_t * fxFullScale
Definition: TGo4FitData.h:383
Bool_t SetNumberOfTransSlots(Int_t nslots)
Definition: TGo4FitData.cxx:53
void SetSigmaValue(Double_t SigmaValue)
Definition: TGo4FitData.h:112
Int_t fiScalesSize
Definition: TGo4FitData.h:361
const Double_t * Scales() const
Definition: TGo4FitData.h:474
virtual void Finalize()
Double_t x() const
Definition: TGo4FitData.h:479
Int_t fiDataType
Definition: TGo4FitData.h:307
Double_t * GetBinsDevs() const
Definition: TGo4FitData.h:271
void SetExcludeLessThen(Double_t limit=0.)
Definition: TGo4FitData.h:117
Int_t fiTakeSigmasFrom
Definition: TGo4FitData.h:319
void SetSigmaSource(Int_t TakeFrom, Double_t SigmaValue=1.)
Definition: TGo4FitData.h:101
const Double_t * GetScaleValues(Int_t nbin) const
void ReleaseAllPointers()
Int_t ScalesSize() const
Definition: TGo4FitData.h:469
Double_t * GetBinsResult() const
Definition: TGo4FitData.h:277
const Double_t * Widths() const
Definition: TGo4FitData.h:499
virtual Bool_t Initialize(Int_t UseBuffers=-1)
virtual Bool_t IsAnyDataTransform() const
void ResetAllPoinetrs()
Int_t DefineBinsSize()
Bool_t IsCompatibleData(TGo4FitData *data)
const Int_t * GetFullIndex(Int_t nbin) const
Int_t GetNumberOfTransSlots() const
Definition: TGo4FitData.h:136
virtual ~TGo4FitData()
Definition: TGo4FitData.cxx:48
Double_t StandardDeviation() const
Definition: TGo4FitData.h:514
Bool_t CanAmplTouch() override
Definition: TGo4FitData.h:80
Bool_t ReachEnd() const
Definition: TGo4FitData.h:536
Double_t Value() const
Definition: TGo4FitData.h:509
Double_t * fxStandDev
Definition: TGo4FitData.h:371
TObject * CreateDrawObject(const char *ObjName)
Double_t y() const
Definition: TGo4FitData.h:484
Double_t * GetBinsValues() const
Definition: TGo4FitData.h:265
void FillSlotList(TSeqCollection *list) override
Double_t z() const
Definition: TGo4FitData.h:489
virtual std::unique_ptr< TGo4FitDataIter > MakeIter()
Definition: TGo4FitData.h:175
Int_t DefineDimensions()
void SetAxisTrans(Int_t nslot, TGo4FitAxisTrans *Trans, Bool_t TransOwned=kFALSE)
Definition: TGo4FitData.cxx:87
const Double_t * GetWidthValues(Int_t nbin) const
Int_t IndexesSize() const
Definition: TGo4FitData.h:454
Bool_t fbUseBinScale
Definition: TGo4FitData.h:313
Bool_t HasIndexes() const
Definition: TGo4FitData.h:449
Int_t GetIndexesSize() const
Definition: TGo4FitData.h:301
Bool_t BuffersAllocated() const
Definition: TGo4FitData.h:248
Int_t fiIndexesSize
Definition: TGo4FitData.h:356
TGo4FitAxisTrans * GetAxisTrans(Int_t nslot) const
Definition: TGo4FitData.cxx:81
Int_t GetDataType() const
Definition: TGo4FitData.h:63
const Int_t * Indexes() const
Definition: TGo4FitData.h:459
void SetUseBinScale(Bool_t iUseBinScale)
Definition: TGo4FitData.h:73
Double_t fdExcludeLessThen
Definition: TGo4FitData.h:329
void AddAxisTrans(TGo4FitAxisTrans *Trans, Bool_t TransOwned=kFALSE)
Definition: TGo4FitData.cxx:96
TGo4FitSlot * GetAxisTransSlot(Int_t nslot) const
Definition: TGo4FitData.cxx:76
Double_t GetExcludeLessThen() const
Definition: TGo4FitData.h:122
Double_t GetSigmaValue() const
Definition: TGo4FitData.h:95
TObjArray fxAxisTrans
Definition: TGo4FitData.h:334
void ApplyRangesForModelMask(TGo4FitComponent *model, Char_t *ModelMask)
Int_t * fxFullIndex
Definition: TGo4FitData.h:397
Bool_t HasWidths() const
Definition: TGo4FitData.h:494
Double_t * fxValues
Definition: TGo4FitData.h:366
Bool_t GetUseBinScale() const
Definition: TGo4FitData.h:68
TArrayD fxScales
Definition: TGo4FitData.h:614
Int_t GetBinsSize() const
Definition: TGo4FitData.h:253
Double_t * fxFullWidth
Definition: TGo4FitData.h:390
void SetAxisTransNeeded(Int_t nslot, Bool_t iNeeded=kFALSE)
Int_t GetScalesSize() const
Definition: TGo4FitData.h:259
Int_t Point() const
Definition: TGo4FitData.h:519