GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4FitModel.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 TGO4FITMODEL_H
15#define TGO4FITMODEL_H
16
17#include "TNamed.h"
18#include "TGo4FitComponent.h"
19
21class TGo4FitData;
22class TGo4FitDataIter;
23
29class TGo4FitAssignment : public TNamed {
30 public:
31
36
40 TGo4FitAssignment(const char *DataName);
41
45 virtual ~TGo4FitAssignment();
46
47 Double_t RatioValue();
48
52 void Print(Option_t *option = "") const override;
53
58
62 TGo4FitData *fxData{nullptr};
63
67 Char_t *fxModelMask{nullptr};
68
74 Double_t *fxModelBins{nullptr};
75
77};
78
79
84 public:
85
90
96 TGo4FitModel(const char *iName, const char *iTitle, Bool_t MakeAmplitude = kFALSE);
97
101 virtual ~TGo4FitModel();
102
111 void SetGroupIndex(Int_t index = -1) { fiGroupIndex = index; }
112
117
121 Int_t GetGroupIndex() const { return fiGroupIndex; }
122
126 Int_t NumAssigments() const { return fxAssigments.GetLast()+1; }
127
131 const char *AssignmentName(Int_t n) { return GetAssigment(n) ? GetAssigment(n)->GetName() : nullptr; }
132
138 void AssignToData(const char *DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
139
143 Bool_t IsAssignTo(const char *DataName) const { return FindAssigment(DataName) != nullptr; }
144
148 void ChangeDataNameInAssignments(const char *oldname, const char *newname);
149
153 void ClearAssignmentTo(const char *DataName);
154 void ClearAssigmentTo(const char *DataName) { ClearAssignmentTo(DataName); }
155
159 void ClearAssignments();
160
165
170 Double_t GetRatioValueFor(const char *DataName);
171
175 void Print(Option_t *option = "") const override;
176
180 virtual Double_t Evaluate(Double_t x);
181
185 virtual Double_t Evaluate(Double_t x, Double_t y);
186
190 virtual Double_t Evaluate(Double_t x, Double_t y, Double_t z);
191
195 virtual Double_t Evaluate(Double_t *v, Int_t ndim);
196
200 virtual Double_t Integral();
201
205 virtual Bool_t GetPosition(Int_t naxis, Double_t& pos);
206
210 virtual Bool_t SetPosition(Int_t naxis, Double_t pos);
211
215 virtual Bool_t GetWidth(Int_t naxis, Double_t& width);
216
220 virtual Bool_t SetWidth(Int_t naxis, Double_t width);
221
233 void SetIntegrationsProperty(Int_t iMinIntegrDepth, Int_t iMaxIntegrDepth = 0, Double_t iIntegrEps = 0., Bool_t iAbsoluteEps = kFALSE, Bool_t iIntegrScaling = kFALSE);
234
238 Bool_t NeedIntegration() const { return (fiMinIntegrDepth > 0) || (fiMaxIntegrDepth > 0); }
239
244 virtual Bool_t BeforeEval(Int_t ndim);
245
250 virtual Double_t EvalN(const Double_t *v);
251
255 virtual void AfterEval() {}
256
261 virtual Double_t EvaluateAtPoint(TGo4FitData *data, Int_t nbin, Bool_t UseRanges = kTRUE);
262
266 virtual Double_t EvaluateAtPoint(std::unique_ptr<TGo4FitDataIter> &iter, Bool_t UseRanges = kTRUE);
267
272 Bool_t AddModelToDataResult(TGo4FitData *data);
273
274 Int_t NumPars() override;
275
276 protected:
277
278 friend class TGo4Fitter;
279
280
281 TGo4FitParameter *Get(Int_t n) override;
282
286 Double_t EvaluateAndIntegrate(Int_t NumScales, const Double_t *Scales, const Double_t *Widths);
287
293 virtual Bool_t Initialize(Int_t UseBuffers = -1);
294
298 virtual void Finalize();
299
304
308 Bool_t BuffersAllocated() const;
309
313 void RebuildShape(Bool_t ForceBuild = kFALSE);
314
318 Double_t *GetModelBins(const char *DataName) const;
319
324
330 virtual Double_t UserFunction(Double_t *, Double_t *) { return 0.; }
331
335 virtual Int_t GetPosParIndex(Int_t) { return -1; }
336
340 virtual Int_t GetWidthParIndex(Int_t) { return -1; }
341
345 virtual TGo4FitParameter *GetPosPar(Int_t naxis = 0)
346 { return Get(GetPosParIndex(naxis)); }
347
351 virtual TGo4FitParameter *GetWidthPar(Int_t naxis = 0)
352 { return Get(GetWidthParIndex(naxis)); }
353
354 const Int_t *GetDataFullIndex(TGo4FitData *data, Int_t nbin);
355 Int_t GetDataIndexesSize(TGo4FitData *data);
356
361
366
370 Double_t fdIntegrEps{0};
371
375 Bool_t fbAbsoluteEps{kFALSE};
376
380 Bool_t fbIntegrScaling{kFALSE};
381
382 private:
383
387 void RemoveAllPars();
388
394
398 TGo4FitAssignment* FindAssigment(const char *DataName) const;
399
403 TString GetRatioName(Int_t n);
404
408 TObjArray fxAssigments;
409
413 Int_t fiGroupIndex{0};
414
419
423 Double_t *fxCurrentParsArray{nullptr};
424
428 Bool_t fbNeedToRebuild{kFALSE};
429
434
435 TArrayD* fxAllParsValues{nullptr};
436
437 ClassDefOverride(TGo4FitModel,1)
438};
439
440#endif // TGO4FITMODEL_H
Internal class, used for assignment of model component to data.
virtual ~TGo4FitAssignment()
Destroys TGo4FitAssignment object.
TGo4FitData * fxData
Pointer on assigned data.
TGo4FitAssignment()
Default constructor.
TGo4FitParameter * fxRatio
Parameter for ratio value.
Double_t RatioValue()
Char_t * fxModelMask
Array of boolean values, selected model bins.
ClassDefOverride(TGo4FitAssignment, 1)
Double_t * fxModelBins
Array of model bins for assigned data.
void Print(Option_t *option="") const override
Print information about object on standard output.
TGo4FitComponent()
Default constructor.
Iterator class for data object.
Basic abstract class for representing data, which should be fitted.
Definition TGo4FitData.h:39
Basic abstract class for representing model components of fitted data.
void ClearAssignments()
Remove all assignments.
Bool_t fbAbsoluteEps
States, if integration precision absolute or relative.
TArrayD fxCurrentPars
Array of values of parameters.
Double_t * GetModelBins(const char *DataName) const
Get model bins for specified data (if exists)
void SetNeedToRebuild()
Sets flag, that shape bins should be refilled next time, when RebuildShape() routine will be called.
Double_t * fxCurrentParsArray
Pointer on array of parameters values.
void SetBackgroundGroupIndex()
Set group index to background (index = 0).
virtual Double_t EvalN(const Double_t *v)
Calculates value of model according current parameters values and provided axes values.
Bool_t AddModelToDataResult(TGo4FitData *data)
Evaluate model values for all data point and add them to result buffer.
Double_t fdIntegrEps
Integration precision.
void ConnectToDataIfAssigned(TGo4FitData *data)
Check, if model assigned to such a data (via name) and store pointer on this data object.
Bool_t BuffersAllocated() const
Checks if model allocate buffers for calculations.
virtual void Finalize()
Deletes all buffers, created during initialization.
virtual Bool_t SetPosition(Int_t naxis, Double_t pos)
Sets position of model component, if possible.
virtual Bool_t Initialize(Int_t UseBuffers=-1)
Initialize model object.
void Print(Option_t *option="") const override
Print information about model object on standard output.
const char * AssignmentName(Int_t n)
Returns name of data, to which model object is assigned.
virtual Double_t UserFunction(Double_t *, Double_t *)
Another place, where user specific code can be placed for model values calculation.
TGo4FitAssignment * FindAssigment(const char *DataName) const
Find assignment to given data.
TString GetRatioName(Int_t n)
Set name of ratio parameter.
virtual TGo4FitParameter * GetWidthPar(Int_t naxis=0)
Return parameter (if exist), which represent width of model component for given axis.
Int_t GetGroupIndex() const
Returns group index of model.
void RemoveAllPars()
Clear all buffers, allocated during initialization.
virtual Bool_t BeforeEval(Int_t ndim)
Prepares (if necessary) some intermediate variables to be able calculate values of model via EvalN() ...
virtual ~TGo4FitModel()
Delete TGo4FitModel object.
Double_t EvaluateAndIntegrate(Int_t NumScales, const Double_t *Scales, const Double_t *Widths)
Make integration of model inside given point, if integration specified.
Bool_t NeedIntegration() const
Returns kTRUE, if integration properties were specified.
Int_t fiGroupIndex
Store group index of specified model.
Int_t NumPars() override
Return number of parameters in list.
friend class TGo4Fitter
virtual Bool_t GetWidth(Int_t naxis, Double_t &width)
Returns with of model component, if exists.
virtual Bool_t GetPosition(Int_t naxis, Double_t &pos)
Return position of model, if exists.
Bool_t IsAssignTo(const char *DataName) const
Checks, if model assigned to given data.
virtual Double_t EvaluateAtPoint(TGo4FitData *data, Int_t nbin, Bool_t UseRanges=kTRUE)
Evaluate model value for specified data point.
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
Change name of data in assignments.
Bool_t fbNeedToRebuild
Internal flag.
TGo4FitParsList * fxAllPars
List of all parameters, associated not only with component directly but also with encapsulated object...
Int_t fiMaxIntegrDepth
Maximum integration depth.
virtual Int_t GetWidthParIndex(Int_t)
Return index of parameter (if exist), which represent width of model component for given axis.
Bool_t fbIntegrScaling
Scale integral to integration volume.
Int_t GetDataIndexesSize(TGo4FitData *data)
void RebuildShape(Bool_t ForceBuild=kFALSE)
Recalculates shape of object.
virtual Double_t Integral()
Calculates integral of model component.
void SetGroupIndex(Int_t index=-1)
Set group index of model.
virtual Double_t Evaluate(Double_t x)
Calculates value of model for given x value.
TGo4FitParameter * Get(Int_t n) override
void ClearAssigmentTo(const char *DataName)
void AssignToData(const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Assign model to specified data object.
TGo4FitAssignment * GetAssigment(Int_t n) const
virtual Int_t GetPosParIndex(Int_t)
Return index of parameter (if exist), which represent position of model for given axis.
const Int_t * GetDataFullIndex(TGo4FitData *data, Int_t nbin)
TGo4FitModel()
Default constructor.
virtual void AfterEval()
Clear buffers, which were created by BeforeEval() method.
TGo4FitAssignment * GetAssigment(Int_t n)
Return TGo4FitAssignment object with given index.
virtual TGo4FitParameter * GetPosPar(Int_t naxis=0)
Return parameter (if exist), which represent position of model for given axis.
void SetIntegrationsProperty(Int_t iMinIntegrDepth, Int_t iMaxIntegrDepth=0, Double_t iIntegrEps=0., Bool_t iAbsoluteEps=kFALSE, Bool_t iIntegrScaling=kFALSE)
Set integration properties.
TObjArray fxAssigments
List of TGo4FitAssignment objects.
TGo4FitData * GetAssignedConnection(Int_t n)
Return pointer on assigned data.
Int_t fiMinIntegrDepth
Minimum depth of integration.
TArrayD * fxAllParsValues
Double_t GetRatioValueFor(const char *DataName)
Returns ratio value for specified data object.
virtual Bool_t SetWidth(Int_t naxis, Double_t width)
Sets width of model component, if possible.
void ClearAssignmentTo(const char *DataName)
Remove assignment to given data (if exists).
Int_t NumAssigments() const
Returns number of assignment for this model.
Model and data objects parameter.
TGo4FitParsList()
Default constructor.