GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Fitter.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 TGO4FITTER_H
15 #define TGO4FITTER_H
16 
17 #include "TGo4FitterAbstract.h"
18 
19 class TH1;
20 class TGraph;
21 
22 #include "TArrayD.h"
23 #include "TObjArray.h"
24 
25 class TGo4FitComponent;
26 class TGo4FitData;
28 class TGo4FitDataGraph;
29 class TGo4FitModel;
30 class TGo4FitModelGauss1;
31 
32 typedef Double_t (*TUserFitFunction)(Double_t, Double_t, Double_t);
33 
38  public:
39  enum { ff_least_squares = 0,
45  ff_user = 6 };
46 
50  TGo4Fitter();
51 
55  TGo4Fitter(const char *iName, const char *iTitle);
56 
61  TGo4Fitter(const char *iName, Int_t iFitFunctionType, Bool_t IsAddStandardActions);
62 
66  virtual ~TGo4Fitter();
67 
80  void SetFitFunctionType(Int_t iFitFunctionType) { fiFitFunctionType = iFitFunctionType; }
81 
85  Int_t GetFitFunctionType() const { return fiFitFunctionType; }
86 
98 
107  void SetMemoryUsage(Int_t iMemoryUsage);
108 
113  Int_t GetMemoryUsage() const { return fiMemoryUsage; }
114 
118  void Clear(Option_t *option = "") override;
119 
123  Int_t GetNumData() const { return fxDatas.GetLast()+1; }
124 
128  TGo4FitData *GetData(Int_t n);
129 
133  const char *GetDataName(Int_t n);
134 
138  TGo4FitData *FindData(const char *DataName);
139 
144 
148  TGo4FitDataHistogram* AddH1(const char *DataName, TH1 *histo, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
149 
153  TGo4FitDataHistogram* SetH1(const char *DataName, TH1 *histo, Bool_t Owned = kFALSE);
154 
158  TGo4FitDataGraph* AddGraph(const char *DataName, TGraph *gr, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
159 
163  TGo4FitDataGraph* SetGraph(const char *DataName, TGraph *gr, Bool_t Owned = kFALSE);
164 
168  TGo4FitData *RemoveData(const char *DataName, Bool_t IsDel = kFALSE);
169 
173  void DeleteAllData();
174 
178  Int_t GetNumModel() const { return fxModels.GetLast()+1; }
179 
183  TGo4FitModel *GetModel(Int_t n);
184 
188  TGo4FitModel *FindModel(const char *ModelName);
189 
194 
198  TGo4FitModel *AddModel(const char *DataName, TGo4FitModel *m);
199 
208  void AddPolynomX(const char *DataName, const char *NamePrefix, Int_t MaxOrder = 1, Int_t GroupIndex = 0, Double_t lrange = 0., Double_t rrange = 0.);
209 
215  void AddPolynomX(const char *DataName, const char *NamePrefix, TArrayD& Coef, Int_t GroupIndex = 0);
216 
224  void AddPolynoms(const char *DataName, const char *NamePrefix, Int_t MaxOrder = 1, Int_t NumAxis = 1, Int_t GroupIndex = 0);
225 
229  TGo4FitModelGauss1 *AddGauss1(const char *DataName, const char *ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl = 1., Int_t Axis = 0);
230 
234  Int_t NumModelsAssosiatedTo(const char *DataName);
235 
239  TGo4FitModel *CloneModel(const char *ModelName, const char *NewName = nullptr);
240 
246  TGo4FitModel *RemoveModel(const char *ModelName, Bool_t IsDel = kFALSE);
247 
251  void DeleteModelsAssosiatedTo(const char *DataName);
252 
256  void DeleteAllModels();
257 
263  void AssignModelTo(const char *ModelName, const char *DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
264 
269  void ClearModelAssignmentTo(const char *ModelName, const char *DataName = nullptr);
270 
275  void ChangeDataNameInAssignments(const char *oldname, const char *newname);
276 
281  Int_t GetNumComp() const { return GetNumData() + GetNumModel(); }
282 
288  TGo4FitComponent *GetComp(Int_t n);
289 
295  void EstimateAmplitudes(Int_t NumIters = 1);
296 
300  void AddAmplEstimation(Int_t NumIters = 1);
301 
306  void AddStandardActions();
307 
311  Double_t CalculateFitFunction(Double_t *pars = nullptr, Int_t FitFunctionType = -1, const char *DataName = nullptr);
312 
318  Int_t CalculateNDF(const char *DataName = nullptr);
319 
323  void FillSlotList(TSeqCollection *) override;
324 
329  void Print(Option_t *option = "") const override;
330 
335  Bool_t CalculatesMomentums(const char *DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t& first, Double_t& second);
336 
341  Double_t CalculatesIntegral(const char *DataName, const char *ModelName = nullptr, Bool_t OnlyCounts = kFALSE);
342 
347  Double_t CalculatesModelIntegral(const char *ModelName, Bool_t OnlyCounts = kFALSE);
348 
353  TObject *CreateDrawObject(const char *ObjName, const char *DataName, Bool_t IsModel = kFALSE, const char *ModelName = nullptr);
354 
363  void Draw(Option_t *option) override;
364 
369  void ProvideLastDrawObjects(TObjArray& lst);
370 
374  void PrintAmpls() const;
375 
379  void PrintLines() const;
380 
381  TString FindNextName(const char *Head, Int_t start, Bool_t isModel = kTRUE);
382 
383  protected:
384 
385  friend class TGo4FitAmplEstimation;
386 
387  // a set of function to access data buffers
388 
389  Bool_t ModelBuffersAllocated(TGo4FitModel *model);
390  Bool_t DataBuffersAllocated(TGo4FitData *data);
391 
392  Int_t GetDataBinsSize(TGo4FitData *data) const;
393  Double_t *GetDataBinsValues(TGo4FitData *data) const;
394  Double_t *GetDataBinsDevs(TGo4FitData *data) const;
395  Double_t *GetDataBinsResult(TGo4FitData *data) const;
396  Double_t *GetModelBinsValues(TGo4FitModel *model, const char *DataName) const;
397 
403  void RebuildAll(Bool_t ForceBuild = kFALSE);
404 
405  void CollectAllPars() override;
406 
407  Double_t DoCalculation() override;
408  Int_t DoNDFCalculation() override;
409  Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData *selectdata = nullptr);
410  Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev);
411 
412  Bool_t InitFitterData() override;
413  void FinalizeFitterData() override;
414 
418  TObjArray fxDatas;
419 
423  TObjArray fxModels;
424 
429 
433  Int_t fiMemoryUsage{0};
434 
435  private:
436 
437  void MoveDrawObjectsToROOT();
439 
444 
445  TObjArray *fxDrawObjs{nullptr};
446 
447  ClassDefOverride(TGo4Fitter,1)
448 };
449 
450 #endif // TGO4FITTER_H
Int_t GetNumData() const
Definition: TGo4Fitter.h:123
Double_t CalculatesIntegral(const char *DataName, const char *ModelName=nullptr, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:894
TGo4FitDataGraph * AddGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:144
void RebuildAll(Bool_t ForceBuild=kFALSE)
Definition: TGo4Fitter.cxx:697
void SetMemoryUsage(Int_t iMemoryUsage)
Definition: TGo4Fitter.cxx:70
TObjArray * fxDrawObjs
Definition: TGo4Fitter.h:445
TGo4FitComponent * GetComp(Int_t n)
Definition: TGo4Fitter.cxx:227
void MoveDrawObjectsToROOT()
void SetFitFunctionType(Int_t iFitFunctionType)
Definition: TGo4Fitter.h:80
void AddAmplEstimation(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:726
void EstimateAmplitudes(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:720
TGo4FitModel * FindModel(const char *ModelName)
Definition: TGo4Fitter.cxx:205
void ClearModelAssignmentTo(const char *ModelName, const char *DataName=nullptr)
Definition: TGo4Fitter.cxx:482
Double_t CalculateFitFunction(Double_t *pars=nullptr, Int_t FitFunctionType=-1, const char *DataName=nullptr)
Definition: TGo4Fitter.cxx:652
void AddPolynoms(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t NumAxis=1, Int_t GroupIndex=0)
Definition: TGo4Fitter.cxx:323
Bool_t InitFitterData() override
Definition: TGo4Fitter.cxx:500
Int_t NumModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:431
Double_t * GetDataBinsDevs(TGo4FitData *data) const
Definition: TGo4Fitter.cxx:764
void CheckSlotsBeforeDelete(TGo4FitComponent *comp)
Definition: TGo4Fitter.cxx:161
Double_t DoCalculation() override
Definition: TGo4Fitter.cxx:687
void AddPolynomX(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t GroupIndex=0, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:235
Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev)
Definition: TGo4Fitter.cxx:550
void AssignModelTo(const char *ModelName, const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Definition: TGo4Fitter.cxx:467
TObjArray fxModels
Definition: TGo4Fitter.h:423
TGo4FitData * RemoveData(const char *DataName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:175
Double_t * GetDataBinsResult(TGo4FitData *data) const
Definition: TGo4Fitter.cxx:769
Int_t GetDataBinsSize(TGo4FitData *data) const
Definition: TGo4Fitter.cxx:754
void DeleteAllData()
Definition: TGo4Fitter.cxx:192
TGo4FitModel * RemoveModel(const char *ModelName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:414
Int_t fiMemoryUsage
Definition: TGo4Fitter.h:433
TUserFitFunction fxUserFitFunction
Definition: TGo4Fitter.h:443
void CollectAllPars() override
Definition: TGo4Fitter.cxx:80
Int_t fiFitFunctionType
Definition: TGo4Fitter.h:428
void DeleteModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:440
void PrintLines() const
TGo4FitData * AddData(TGo4FitData *d)
Definition: TGo4Fitter.cxx:119
Double_t * GetDataBinsValues(TGo4FitData *data) const
Definition: TGo4Fitter.cxx:759
void FillSlotList(TSeqCollection *) override
Definition: TGo4Fitter.cxx:737
TGo4FitModelGauss1 * AddGauss1(const char *DataName, const char *ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl=1., Int_t Axis=0)
Definition: TGo4Fitter.cxx:382
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
Definition: TGo4Fitter.cxx:494
Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData *selectdata=nullptr)
Definition: TGo4Fitter.cxx:591
TGo4FitDataGraph * SetGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:153
void FinalizeFitterData() override
Definition: TGo4Fitter.cxx:541
TGo4FitModel * GetModel(Int_t n)
Definition: TGo4Fitter.cxx:200
Double_t CalculatesModelIntegral(const char *ModelName, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:927
TObjArray fxDatas
Definition: TGo4Fitter.h:418
Int_t DoNDFCalculation() override
Definition: TGo4Fitter.cxx:692
Int_t GetNumComp() const
Definition: TGo4Fitter.h:281
TString FindNextName(const char *Head, Int_t start, Bool_t isModel=kTRUE)
Int_t GetNumModel() const
Definition: TGo4Fitter.h:178
TGo4FitData * GetData(Int_t n)
Definition: TGo4Fitter.cxx:104
virtual ~TGo4Fitter()
Definition: TGo4Fitter.cxx:64
TObject * CreateDrawObject(const char *ObjName, const char *DataName, Bool_t IsModel=kFALSE, const char *ModelName=nullptr)
Definition: TGo4Fitter.cxx:935
Int_t GetFitFunctionType() const
Definition: TGo4Fitter.h:85
Bool_t DataBuffersAllocated(TGo4FitData *data)
Definition: TGo4Fitter.cxx:749
Double_t(* TUserFitFunction)(Double_t, Double_t, Double_t)
Definition: TGo4Fitter.h:32
const char * GetDataName(Int_t n)
Definition: TGo4Fitter.cxx:109
TGo4FitModel * AddModel(TGo4FitModel *m)
Definition: TGo4Fitter.cxx:210
TGo4FitModel * CloneModel(const char *ModelName, const char *NewName=nullptr)
Definition: TGo4Fitter.cxx:391
Double_t * GetModelBinsValues(TGo4FitModel *model, const char *DataName) const
Definition: TGo4Fitter.cxx:774
void SetUserFitFunction(TUserFitFunction iFunc)
Definition: TGo4Fitter.h:97
TGo4FitDataHistogram * SetH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:136
Bool_t CalculatesMomentums(const char *DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t &first, Double_t &second)
Definition: TGo4Fitter.cxx:813
TGo4FitData * FindData(const char *DataName)
Definition: TGo4Fitter.cxx:114
Int_t CalculateNDF(const char *DataName=nullptr)
Definition: TGo4Fitter.cxx:665
void ProvideLastDrawObjects(TObjArray &lst)
void Draw(Option_t *option) override
void Clear(Option_t *option="") override
Definition: TGo4Fitter.cxx:97
Bool_t ModelBuffersAllocated(TGo4FitModel *model)
Definition: TGo4Fitter.cxx:744
Int_t GetMemoryUsage() const
Definition: TGo4Fitter.h:113
void PrintAmpls() const
void AddStandardActions()
Definition: TGo4Fitter.cxx:731
void DeleteAllModels()
Definition: TGo4Fitter.cxx:459
TGo4FitDataHistogram * AddH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:127
void Print(Option_t *option="") const override
Definition: TGo4Fitter.cxx:779