GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
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 
20 class TGo4FitParameter;
21 class TGo4FitData;
22 class TGo4FitDataIter;
23 
27 class TGo4FitAssignment : public TNamed {
28  public:
29 
34 
38  TGo4FitAssignment(const char *DataName);
39 
43  virtual ~TGo4FitAssignment();
44 
45  Double_t RatioValue();
46 
50  void Print(Option_t *option = "") const override;
51 
56 
60  TGo4FitData *fxData{nullptr};
61 
65  Char_t *fxModelMask{nullptr};
66 
72  Double_t *fxModelBins{nullptr};
73 
75 };
76 
77 
82  public:
83 
87  TGo4FitModel();
88 
94  TGo4FitModel(const char *iName, const char *iTitle, Bool_t MakeAmplitude = kFALSE);
95 
99  virtual ~TGo4FitModel();
100 
109  void SetGroupIndex(Int_t index = -1) { fiGroupIndex = index; }
110 
114  void SetBackgroundGroupIndex() { fiGroupIndex = 0; }
115 
119  Int_t GetGroupIndex() const { return fiGroupIndex; }
120 
124  Int_t NumAssigments() const { return fxAssigments.GetLast()+1; }
125 
129  const char *AssignmentName(Int_t n) { return GetAssigment(n) ? GetAssigment(n)->GetName() : nullptr; }
130 
136  void AssignToData(const char *DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
137 
141  Bool_t IsAssignTo(const char *DataName) const { return FindAssigment(DataName) != nullptr; }
142 
146  void ChangeDataNameInAssignments(const char *oldname, const char *newname);
147 
151  void ClearAssignmentTo(const char *DataName);
152  void ClearAssigmentTo(const char *DataName) { ClearAssignmentTo(DataName); }
153 
157  void ClearAssignments();
158 
162  void ConnectToDataIfAssigned(TGo4FitData *data);
163 
168  Double_t GetRatioValueFor(const char *DataName);
169 
173  void Print(Option_t *option = "") const override;
174 
178  virtual Double_t Evaluate(Double_t x);
179 
183  virtual Double_t Evaluate(Double_t x, Double_t y);
184 
188  virtual Double_t Evaluate(Double_t x, Double_t y, Double_t z);
189 
193  virtual Double_t Evaluate(Double_t *v, Int_t ndim);
194 
198  virtual Double_t Integral();
199 
203  virtual Bool_t GetPosition(Int_t naxis, Double_t& pos);
204 
208  virtual Bool_t SetPosition(Int_t naxis, Double_t pos);
209 
213  virtual Bool_t GetWidth(Int_t naxis, Double_t& width);
214 
218  virtual Bool_t SetWidth(Int_t naxis, Double_t width);
219 
231  void SetIntegrationsProperty(Int_t iMinIntegrDepth, Int_t iMaxIntegrDepth = 0, Double_t iIntegrEps = 0., Bool_t iAbsoluteEps = kFALSE, Bool_t iIntegrScaling = kFALSE);
232 
236  Bool_t NeedIntegration() const { return (fiMinIntegrDepth > 0) || (fiMaxIntegrDepth > 0); }
237 
242  virtual Bool_t BeforeEval(Int_t ndim);
243 
248  virtual Double_t EvalN(const Double_t *v);
249 
253  virtual void AfterEval() {}
254 
259  virtual Double_t EvaluateAtPoint(TGo4FitData *data, Int_t nbin, Bool_t UseRanges = kTRUE);
260 
264  virtual Double_t EvaluateAtPoint(std::unique_ptr<TGo4FitDataIter> &iter, Bool_t UseRanges = kTRUE);
265 
270  Bool_t AddModelToDataResult(TGo4FitData *data);
271 
272  Int_t NumPars() override;
273 
274  protected:
275 
276  friend class TGo4Fitter;
277 
278 
279  TGo4FitParameter *Get(Int_t n) override;
280 
284  Double_t EvaluateAndIntegrate(Int_t NumScales, const Double_t *Scales, const Double_t *Widths);
285 
291  virtual Bool_t Initialize(Int_t UseBuffers = -1);
292 
296  virtual void Finalize();
297 
301  TGo4FitData *GetAssignedConnection(Int_t n);
302 
306  Bool_t BuffersAllocated() const;
307 
311  void RebuildShape(Bool_t ForceBuild = kFALSE);
312 
316  Double_t *GetModelBins(const char *DataName) const;
317 
321  void SetNeedToRebuild() { fbNeedToRebuild = kTRUE; }
322 
328  virtual Double_t UserFunction(Double_t *, Double_t *) { return 0.; }
329 
333  virtual Int_t GetPosParIndex(Int_t) { return -1; }
334 
338  virtual Int_t GetWidthParIndex(Int_t) { return -1; }
339 
343  virtual TGo4FitParameter *GetPosPar(Int_t naxis = 0)
344  { return Get(GetPosParIndex(naxis)); }
345 
349  virtual TGo4FitParameter *GetWidthPar(Int_t naxis = 0)
350  { return Get(GetWidthParIndex(naxis)); }
351 
352  const Int_t *GetDataFullIndex(TGo4FitData *data, Int_t nbin);
353  Int_t GetDataIndexesSize(TGo4FitData *data);
354 
358  Int_t fiMinIntegrDepth{0};
359 
363  Int_t fiMaxIntegrDepth{0};
364 
368  Double_t fdIntegrEps{0};
369 
373  Bool_t fbAbsoluteEps{kFALSE};
374 
378  Bool_t fbIntegrScaling{kFALSE};
379 
380  private:
381 
385  void RemoveAllPars();
386 
390  TGo4FitAssignment* GetAssigment(Int_t n) { return (TGo4FitAssignment*) fxAssigments[n]; }
391  TGo4FitAssignment* GetAssigment(Int_t n) const { return (TGo4FitAssignment*) fxAssigments[n]; }
392 
396  TGo4FitAssignment* FindAssigment(const char *DataName) const;
397 
401  TString GetRatioName(Int_t n);
402 
406  TObjArray fxAssigments;
407 
411  Int_t fiGroupIndex{0};
412 
416  TArrayD fxCurrentPars;
417 
421  Double_t *fxCurrentParsArray{nullptr};
422 
426  Bool_t fbNeedToRebuild{kFALSE};
427 
431  TGo4FitParsList* fxAllPars{nullptr};
432 
433  TArrayD* fxAllParsValues{nullptr};
434 
436 };
437 
438 #endif // TGO4FITMODEL_H
TArrayD fxCurrentPars
Definition: TGo4FitModel.h:416
Double_t RatioValue()
void ClearAssigmentTo(const char *DataName)
Definition: TGo4FitModel.h:152
virtual Int_t GetWidthParIndex(Int_t)
Definition: TGo4FitModel.h:338
ClassDefOverride(TGo4FitAssignment, 1)
Char_t * fxModelMask
Definition: TGo4FitModel.h:65
virtual ~TGo4FitAssignment()
TGo4FitData * fxData
Definition: TGo4FitModel.h:60
TGo4FitAssignment * GetAssigment(Int_t n) const
Definition: TGo4FitModel.h:391
virtual TGo4FitParameter * GetWidthPar(Int_t naxis=0)
Definition: TGo4FitModel.h:349
const char * AssignmentName(Int_t n)
Definition: TGo4FitModel.h:129
Bool_t IsAssignTo(const char *DataName) const
Definition: TGo4FitModel.h:141
TObjArray fxAssigments
Definition: TGo4FitModel.h:406
Bool_t NeedIntegration() const
Definition: TGo4FitModel.h:236
virtual Double_t UserFunction(Double_t *, Double_t *)
Definition: TGo4FitModel.h:328
Double_t * fxModelBins
Definition: TGo4FitModel.h:72
Int_t GetGroupIndex() const
Definition: TGo4FitModel.h:119
void SetNeedToRebuild()
Definition: TGo4FitModel.h:321
TGo4FitAssignment * GetAssigment(Int_t n)
Definition: TGo4FitModel.h:390
virtual Int_t GetPosParIndex(Int_t)
Definition: TGo4FitModel.h:333
TGo4FitParameter * fxRatio
Definition: TGo4FitModel.h:55
virtual void AfterEval()
Definition: TGo4FitModel.h:253
void SetGroupIndex(Int_t index=-1)
Definition: TGo4FitModel.h:109
Int_t NumAssigments() const
Definition: TGo4FitModel.h:124
TGo4FitParameter * Get(Int_t n) override
virtual TGo4FitParameter * GetPosPar(Int_t naxis=0)
Definition: TGo4FitModel.h:343
virtual Bool_t Initialize()
void SetBackgroundGroupIndex()
Definition: TGo4FitModel.h:114
void Print(Option_t *option="") const override