GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
28class TH1;
29class TGraph;
30class TGo4FitSlot;
31
33class TGo4FitDataIter;
34
40 public:
41 enum { dtHistogram = 1, dtGraph = 2 };
42
47
54 TGo4FitData(const char *iName, const char *iTitle, Int_t iDataType = dtHistogram, Bool_t AddAmpl = kFALSE);
55
59 virtual ~TGo4FitData();
60
64 Int_t GetDataType() const { return fiDataType; }
65
69 Bool_t GetUseBinScale() const { return fbUseBinScale; }
70
74 void SetUseBinScale(Bool_t iUseBinScale) { fbUseBinScale = iUseBinScale; }
75
81 Bool_t CanAmplTouch() override { return kTRUE; }
82
90 Int_t GetSigmaSource() const { return fiTakeSigmasFrom; }
91
96 Double_t GetSigmaValue() const { return fdSigmaValue; }
97
102 void SetSigmaSource(Int_t TakeFrom, Double_t SigmaValue = 1.)
103 {
104 fiTakeSigmasFrom = TakeFrom;
105 if ((TakeFrom == 2) && (SigmaValue > 0))
106 fdSigmaValue = SigmaValue;
107 }
108
113 void SetSigmaValue(Double_t SigmaValue) { fdSigmaValue = SigmaValue; }
114
118 void SetExcludeLessThen(Double_t limit = 0.) { fdExcludeLessThen = limit; }
119
123 Double_t GetExcludeLessThen() const { return fdExcludeLessThen; }
124
132 Bool_t SetNumberOfTransSlots(Int_t nslots);
133
137 Int_t GetNumberOfTransSlots() const { return fxAxisTrans.GetLast()+1; }
138
142 TGo4FitSlot *GetAxisTransSlot(Int_t nslot) const;
143
147 TGo4FitAxisTrans *GetAxisTrans(Int_t nslot) const;
148
153 void SetAxisTrans(Int_t nslot, TGo4FitAxisTrans *Trans, Bool_t TransOwned = kFALSE);
154
159 void AddAxisTrans(TGo4FitAxisTrans *Trans, Bool_t TransOwned = kFALSE);
160
164 void SetAxisTransNeeded(Int_t nslot, Bool_t iNeeded = kFALSE);
165
170 virtual Bool_t IsAnyDataTransform() const;
171
176 virtual std::unique_ptr<TGo4FitDataIter> MakeIter() { return nullptr; }
177
182 TObject *CreateDrawObject(const char *ObjName);
183
188 Bool_t DefineScaleMinMax(Int_t naxis, Double_t& min, Double_t& max);
189
194 Int_t DefineDimensions();
195
200 Int_t DefineBinsSize();
201
207 Bool_t IsCompatibleData(TGo4FitData *data);
208
215 void ApplyRangesForModelMask(TGo4FitComponent *model, Char_t *ModelMask);
216
220 void FillSlotList(TSeqCollection *list) override;
221
225 void Print(Option_t *option = "") const override;
226
227 protected:
228
229 friend class TGo4FitModel;
230 friend class TGo4Fitter;
231
239 virtual Bool_t Initialize(Int_t UseBuffers = -1);
240
244 virtual void Finalize();
245
249 Bool_t BuffersAllocated() const { return fxValues && fxFullScale; }
250
254 Int_t GetBinsSize() const { return fiBinsSize; }
255
260 Int_t GetScalesSize() const { return fiScalesSize; }
261
266 Double_t *GetBinsValues() const { return fxValues; }
267
272 Double_t *GetBinsDevs() const { return fxStandDev; }
273
278 Double_t *GetBinsResult() const { return fxBinsResult; }
279
284 const Double_t *GetScaleValues(Int_t nbin) const;
285
290 const Double_t *GetWidthValues(Int_t nbin) const;
291
296 const Int_t *GetFullIndex(Int_t nbin) const;
297
302 Int_t GetIndexesSize() const { return fiIndexesSize; }
303
308 Int_t fiDataType{0};
309
314 Bool_t fbUseBinScale{kFALSE};
315
321
325 Double_t fdSigmaValue{0};
326
330 Double_t fdExcludeLessThen{0};
331
335 TObjArray fxAxisTrans;
336
337 private:
338
342 void ResetAllPoinetrs();
343
347 void ReleaseAllPointers();
348
352 Int_t fiBinsSize{0};
353
357 Int_t fiIndexesSize{0};
358
362 Int_t fiScalesSize{0};
363
367 Double_t *fxValues{nullptr};
368
372 Double_t *fxStandDev{nullptr};
373
377 Double_t *fxBinsResult{nullptr};
378
384 Double_t *fxFullScale{nullptr};
385
391 Double_t *fxFullWidth{nullptr};
392
398 Int_t *fxFullIndex{nullptr};
399
400 ClassDefOverride(TGo4FitData,1)
401};
402
418
419class TGo4FitDataIter : public TObject {
420 public:
421
426
430 virtual ~TGo4FitDataIter();
431
437 virtual Bool_t Reset(Bool_t UseRanges = kTRUE);
438
445 virtual Bool_t Next(Bool_t UseRanges = kTRUE);
446
450 Bool_t HasIndexes() const { return IndexesSize() > 0; }
451
455 Int_t IndexesSize() const { return fxIndexes.GetSize(); }
456
460 const Int_t *Indexes() const { return fxIndexes.GetArray(); }
461
465 Bool_t DefineIndexesLimits(TArrayI& Limits);
466
470 Int_t ScalesSize() const { return fxScales.GetSize(); }
471
475 const Double_t *Scales() const { return fxScales.GetSize() > 0 ? fxScales.GetArray() : nullptr; }
476
480 Double_t x() const { return fxScales.GetSize() > 0 ? fxScales[0] : 0.; }
481
485 Double_t y() const { return fxScales.GetSize() > 1 ? fxScales[1] : 0.; }
486
490 Double_t z() const { return fxScales.GetSize() > 2 ? fxScales[2] : 0.; }
491
495 Bool_t HasWidths() const { return fxWidths.GetSize() > 0; }
496
500 const Double_t *Widths() const { return fxWidths.GetSize() > 0 ? fxWidths.GetArray() : nullptr; }
501
505 Double_t xWidths() const;
506
510 Double_t Value() const { return fdValue; }
511
515 Double_t StandardDeviation() const { return fdStandardDeviation; }
516
520 Int_t Point() const { return fiNumPoint; }
521
525 Bool_t CheckPointForRange();
526
531 Int_t CountPoints(Bool_t UseRanges = kTRUE);
532
537 Bool_t ReachEnd() const { return fbReachEnd; }
538
544 TH1 *CreateHistogram(const char *HistoName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
545
553 TGraph *CreateGraph(const char *GraphName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
554
558 TObject *CreateDrawObject(const char *ObjName);
559
560 protected:
561
566 virtual TGo4FitData *GetData() const = 0;
567
572 virtual Bool_t StartReset() = 0;
573
578 virtual Bool_t ReadCurrentPoint() = 0;
579
584 virtual Bool_t ShiftToNextPoint() = 0;
585
590 Bool_t ReserveArrays(Int_t NumDimen, Int_t NumOwnAxis, Bool_t HasWidth);
591
595 void TransformScales(Double_t *scales);
596
601 Bool_t ProduceScales(const Int_t *index, const Double_t *ownscales, const Double_t *ownwidths);
602
606 Bool_t NextIndex(TArrayI& Index, TArrayI& Limits);
607
611 Bool_t GetDeviation();
612
613 TArrayI fxIndexes;
614
615 TArrayD fxScales;
616 TArrayD fxWidths;
617 Double_t fdValue{0.};
618 Double_t fdStandardDeviation{0.};
619
620 Int_t fiNumPoint{0};
621
622 Bool_t fbReachEnd{kFALSE};
623
624 ClassDefOverride(TGo4FitDataIter,1)
625};
626
627
628#endif // TGO4FITDATA_H
Base class for axis transformation objects.
Basic abstract class, combining common properties of data and model.
TGo4FitComponent()
Default constructor.
Iterator class for data object.
TGraph * CreateGraph(const char *GraphName, Bool_t UseRanges=kFALSE, Bool_t SetBins=kFALSE)
Create TGraph object with appropriate to data object size.
Double_t xWidths() const
Return production of all width parameters (1 if no widths)
const Double_t * Widths() const
Return scales widths values.
Double_t fdStandardDeviation
virtual ~TGo4FitDataIter()
Destroys TGo4FitDataIter object.
virtual Bool_t Next(Bool_t UseRanges=kTRUE)
Shift pointer to next data point.
virtual Bool_t StartReset()=0
Reset pointer and other specific values to the beginning of data.
Bool_t ProduceScales(const Int_t *index, const Double_t *ownscales, const Double_t *ownwidths)
Converts scale values.
Bool_t GetDeviation()
Calculates standard deviation from GetSigmaValue() of data object.
Bool_t DefineIndexesLimits(TArrayI &Limits)
Iterate over all data points and returns maximum value for indexes.
Bool_t NextIndex(TArrayI &Index, TArrayI &Limits)
Producing next indexes set according limits values.
virtual Bool_t Reset(Bool_t UseRanges=kTRUE)
Initialize iterator and positioning pointer on first point.
Bool_t HasWidths() const
Return kTRUE, if scale widths values exists.
Bool_t HasIndexes() const
Return kTRUE, if data object has indexes.
const Int_t * Indexes() const
Return indexes for current data point.
Int_t CountPoints(Bool_t UseRanges=kTRUE)
Counts total number of points in data object.
Double_t StandardDeviation() const
Return standard deviation of bin content (Value) for current point.
Double_t Value() const
Return bin content (Value) for current point.
virtual Bool_t ReadCurrentPoint()=0
Perform specific actions to read all values from data object.
Bool_t CheckPointForRange()
Check range conditions and amplitude threshold for current point.
void TransformScales(Double_t *scales)
Transform scales values, using transformation objects in data.
Bool_t ReachEnd() const
Checks, if iterator already reach end of data object.
Double_t x() const
Return current x coordinate if exists, otherwise 0.
TGo4FitDataIter()
Default constructor.
const Double_t * Scales() const
Return scale values for current data points.
TH1 * CreateHistogram(const char *HistoName, Bool_t UseRanges=kFALSE, Bool_t SetBins=kFALSE)
Create histogram (if possible) with appropriate to data object dimensions number and size.
Bool_t ReserveArrays(Int_t NumDimen, Int_t NumOwnAxis, Bool_t HasWidth)
Reserve buffers for indexes, scales and width values.
virtual Bool_t ShiftToNextPoint()=0
Move pointer to following data point.
virtual TGo4FitData * GetData() const =0
Return pointer on correspondent TGo4FitData object, which create iterator.
Double_t z() const
Return current z coordinate if exists, otherwise 0.
Int_t ScalesSize() const
Return size (number) of scale values for each data point.
Double_t y() const
Return current y coordinate if exists, otherwise 0.
Int_t Point() const
Return number of current point, starting from 0.
Int_t IndexesSize() const
Return size (number of dimensions) of data indexes.
TObject * CreateDrawObject(const char *ObjName)
Create either histogram or graph object.
Basic abstract class for representing data, which should be fitted.
Definition TGo4FitData.h:39
Bool_t CanAmplTouch() override
Always return kTRUE.
Definition TGo4FitData.h:81
Double_t * fxStandDev
Buffer for standard deviations of bins values.
const Double_t * GetWidthValues(Int_t nbin) const
Return scales width values for specified index from buffer.
const Double_t * GetScaleValues(Int_t nbin) const
Return scale values for specified index from buffer.
Bool_t fbUseBinScale
Use binary numbers as scale values.
Int_t GetNumberOfTransSlots() const
Return number of slots for scale transformation objects.
TGo4FitAxisTrans * GetAxisTrans(Int_t nslot) const
Return transformation object for given slot.
Int_t DefineDimensions()
Define dimension number of data Create iterator and checks number of dimension.
Double_t * fxBinsResult
Buffer for complete model of bins values.
TObject * CreateDrawObject(const char *ObjName)
Creates object, which can be drawn on canvas by ROOT.
void SetSigmaValue(Double_t SigmaValue)
Set constant sigma value.
Int_t * fxFullIndex
Store combination of indexes for each data bins.
void SetSigmaSource(Int_t TakeFrom, Double_t SigmaValue=1.)
Sets source of sigma for data.
Double_t * GetBinsResult() const
Returns pointer on buffer with complete model of data bins.
Double_t fdSigmaValue
Value of sigma when fiTakeSigmasFrom = 2.
Bool_t BuffersAllocated() const
Checks, if buffers allocated for data.
Int_t GetBinsSize() const
Return number of data bins in buffers.
Int_t fiDataType
Specified type of data: 0 - Histogram, 1 - graphics, 2 and so on - user defined.
void SetAxisTrans(Int_t nslot, TGo4FitAxisTrans *Trans, Bool_t TransOwned=kFALSE)
Sets transformation object for given slot.
void SetAxisTransNeeded(Int_t nslot, Bool_t iNeeded=kFALSE)
Specified, when iNeeded = kTRUE, that transformation object should always be provided to data.
void SetExcludeLessThen(Double_t limit=0.)
Sets limit to exclude bins, which not less then this limit.
Int_t fiTakeSigmasFrom
Specify sigma source.
Double_t * fxFullScale
Array of axis values for each bins.
void ResetAllPoinetrs()
Clears (sets to 0) all pointers, used for buffer allocations.
Int_t GetSigmaSource() const
Return source of sigma values.
Definition TGo4FitData.h:90
Double_t * GetBinsDevs() const
Returns pointer on buffer with standard deviations for each data bins.
Int_t GetIndexesSize() const
Returns dimension of indexes arrays.
Double_t * fxValues
Buffer for bins values.
const Int_t * GetFullIndex(Int_t nbin) const
Return indexes values for specified data bin from buffer.
virtual ~TGo4FitData()
Destroys TGo4FitData object.
friend class TGo4Fitter
Int_t fiScalesSize
Number of scales values for each point.
Int_t GetDataType() const
Returns type of data source.
Definition TGo4FitData.h:64
Double_t * GetBinsValues() const
Returns pointer on buffer with data bins values.
friend class TGo4FitModel
Int_t fiIndexesSize
Number of indexes for each point.
Bool_t SetNumberOfTransSlots(Int_t nslots)
Sets number of slots for scale transformation objects.
Bool_t DefineScaleMinMax(Int_t naxis, Double_t &min, Double_t &max)
Return scales minimum and maximum for specified axis.
Int_t fiBinsSize
Number of entries in buffers.
void FillSlotList(TSeqCollection *list) override
Copy pointers on all slots of data object to list.
TGo4FitData()
Default constructor.
virtual void Finalize()
Removes all buffers, created in initialize() routine.
virtual Bool_t Initialize(Int_t UseBuffers=-1)
Initialize data object.
Bool_t GetUseBinScale() const
Returns kTRUE, if binary numbers used as scale values.
Definition TGo4FitData.h:69
void SetUseBinScale(Bool_t iUseBinScale)
If kTRUE, binary numbers will be used as scale values.
Definition TGo4FitData.h:74
void AddAxisTrans(TGo4FitAxisTrans *Trans, Bool_t TransOwned=kFALSE)
Add transformation object to data.
Double_t GetSigmaValue() const
Return constant sigma value.
Definition TGo4FitData.h:96
Double_t GetExcludeLessThen() const
Returns limit, which uses to exclude bins, less then this limit.
virtual Bool_t IsAnyDataTransform() const
Return kTRUE, if either initial data axis or data bins are transformed by TGo4FitData object.
Double_t fdExcludeLessThen
Sets limit for exclude bins, which less then this limit.
void ReleaseAllPointers()
Release all memory, allocated for buffers.
virtual std::unique_ptr< TGo4FitDataIter > MakeIter()
Creates iterator for data object.
Double_t * fxFullWidth
Array of width values for each bin.
void Print(Option_t *option="") const override
Display information about data object on standard output.
Int_t DefineBinsSize()
Defines number of selected bins in data Creates iterator and sequentially checks all points.
TGo4FitSlot * GetAxisTransSlot(Int_t nslot) const
Return slot for transformation object.
TObjArray fxAxisTrans
Array of slots for scale transformation objects.
Int_t GetScalesSize() const
Returns number of axis values for each point.
void ApplyRangesForModelMask(TGo4FitComponent *model, Char_t *ModelMask)
Exclude points from model according model range conditions.
Bool_t IsCompatibleData(TGo4FitData *data)
Checks, if data has same dimensions number and size of each dimensions.
Managing pointers on specific objects.
Definition TGo4FitSlot.h:28