GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Fitter.h
Go to the documentation of this file.
1 // $Id: TGo4Fitter.h 747 2011-03-17 13:14:07Z linev $
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 für 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 
86 
98 
107  void SetMemoryUsage(Int_t iMemoryUsage);
108 
113  Int_t GetMemoryUsage() { return fiMemoryUsage; }
114 
118  virtual void Clear(Option_t* option = 0);
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 = 0);
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 = 0);
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 = 0, Int_t FitFunctionType = -1, const char* DataName = 0);
312 
318  Int_t CalculateNDF(const char* DataName = 0);
319 
323  virtual void FillSlotList(TSeqCollection* list);
324 
329  virtual void Print(Option_t* option) const;
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 = 0, 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 = 0);
354 
363  virtual void Draw(Option_t* option);
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);
393  Double_t* GetDataBinsValues(TGo4FitData* data);
394  Double_t* GetDataBinsDevs(TGo4FitData* data);
395  Double_t* GetDataBinsResult(TGo4FitData* data);
396  Double_t* GetModelBinsValues(TGo4FitModel* model, const char* DataName);
397 
403  void RebuildAll(Bool_t ForceBuild = kFALSE);
404 
405 
406  virtual void CollectAllPars();
407 
408  virtual Double_t DoCalculation();
409  virtual Int_t DoNDFCalculation();
410  Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData* selectdata = 0);
411  Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev);
412 
413  virtual Bool_t InitFitterData();
414  virtual void FinalizeFitterData();
415 
419  TObjArray fxDatas;
420 
424  TObjArray fxModels;
425 
430 
435 
436  private:
437 
438  void MoveDrawObjectsToROOT();
440 
445 
446  TObjArray* fxDrawObjs;
447 
448 
452  /*# TGo4FitModel Models; */
453 
457  /*# TGo4FitData Datas; */
459 };
460 
461 
462 #endif // TGO4FITTER_H
463 
464 
virtual void Print(Option_t *option) const
Definition: TGo4Fitter.cxx:707
TGo4FitDataGraph * AddGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:142
void PrintLines() const
void RebuildAll(Bool_t ForceBuild=kFALSE)
Definition: TGo4Fitter.cxx:627
virtual Double_t DoCalculation()
Definition: TGo4Fitter.cxx:617
void SetMemoryUsage(Int_t iMemoryUsage)
Definition: TGo4Fitter.cxx:72
TObjArray * fxDrawObjs
Definition: TGo4Fitter.h:446
virtual Int_t DoNDFCalculation()
Definition: TGo4Fitter.cxx:622
TGo4FitComponent * GetComp(Int_t n)
Definition: TGo4Fitter.cxx:220
void MoveDrawObjectsToROOT()
void SetFitFunctionType(Int_t iFitFunctionType)
Definition: TGo4Fitter.h:80
virtual void Draw(Option_t *option)
Definition: TGo4Fitter.cxx:983
void AddAmplEstimation(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:654
void ClearModelAssignmentTo(const char *ModelName, const char *DataName=0)
Definition: TGo4Fitter.cxx:439
virtual void CollectAllPars()
Definition: TGo4Fitter.cxx:79
virtual void FinalizeFitterData()
Definition: TGo4Fitter.cxx:484
Int_t GetDataBinsSize(TGo4FitData *data)
Definition: TGo4Fitter.cxx:682
void EstimateAmplitudes(Int_t NumIters=1)
Definition: TGo4Fitter.cxx:648
TGo4FitModel * FindModel(const char *ModelName)
Definition: TGo4Fitter.cxx:198
void AddPolynoms(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t NumAxis=1, Int_t GroupIndex=0)
Definition: TGo4Fitter.cxx:297
Double_t * GetDataBinsResult(TGo4FitData *data)
Definition: TGo4Fitter.cxx:697
Int_t NumModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:390
void CheckSlotsBeforeDelete(TGo4FitComponent *comp)
Definition: TGo4Fitter.cxx:157
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:225
Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev)
Definition: TGo4Fitter.cxx:491
void AssignModelTo(const char *ModelName, const char *DataName, Double_t RatioValue=1., Bool_t FixRatio=kFALSE)
Definition: TGo4Fitter.cxx:424
TObjArray fxModels
Definition: TGo4Fitter.h:424
TGo4FitData * RemoveData(const char *DataName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:172
void DeleteAllData()
Definition: TGo4Fitter.cxx:185
TGo4FitModel * RemoveModel(const char *ModelName, Bool_t IsDel=kFALSE)
Definition: TGo4Fitter.cxx:377
Int_t fiMemoryUsage
Definition: TGo4Fitter.h:434
TUserFitFunction fxUserFitFunction
Definition: TGo4Fitter.h:444
Double_t * GetDataBinsDevs(TGo4FitData *data)
Definition: TGo4Fitter.cxx:692
Int_t fiFitFunctionType
Definition: TGo4Fitter.h:429
void DeleteModelsAssosiatedTo(const char *DataName)
Definition: TGo4Fitter.cxx:398
virtual void FillSlotList(TSeqCollection *list)
Definition: TGo4Fitter.cxx:665
Double_t CalculatesIntegral(const char *DataName, const char *ModelName=0, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:808
Int_t GetMemoryUsage()
Definition: TGo4Fitter.h:113
TGo4FitData * AddData(TGo4FitData *d)
Definition: TGo4Fitter.cxx:118
Double_t(* TUserFitFunction)(Double_t, Double_t, Double_t)
Definition: TGo4Fitter.h:32
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:347
void ChangeDataNameInAssignments(const char *oldname, const char *newname)
Definition: TGo4Fitter.cxx:448
Int_t CalculateNDF(const char *DataName=0)
Definition: TGo4Fitter.cxx:595
TGo4FitDataGraph * SetGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:150
TGo4FitModel * GetModel(Int_t n)
Definition: TGo4Fitter.cxx:193
Double_t CalculatesModelIntegral(const char *ModelName, Bool_t OnlyCounts=kFALSE)
Definition: TGo4Fitter.cxx:846
TObjArray fxDatas
Definition: TGo4Fitter.h:419
Int_t GetNumComp() const
Definition: TGo4Fitter.h:281
ClassDef(TGo4FitSlotList, 1)
TString FindNextName(const char *Head, Int_t start, Bool_t isModel=kTRUE)
void PrintAmpls() const
TGo4FitData * GetData(Int_t n)
Definition: TGo4Fitter.cxx:103
virtual ~TGo4Fitter()
Definition: TGo4Fitter.cxx:66
Int_t GetFitFunctionType()
Definition: TGo4Fitter.h:85
Double_t * GetModelBinsValues(TGo4FitModel *model, const char *DataName)
Definition: TGo4Fitter.cxx:702
Double_t CalculateFitFunction(Double_t *pars=0, Int_t FitFunctionType=-1, const char *DataName=0)
Definition: TGo4Fitter.cxx:582
Bool_t DataBuffersAllocated(TGo4FitData *data)
Definition: TGo4Fitter.cxx:677
TGo4FitModel * CloneModel(const char *ModelName, const char *NewName=0)
Definition: TGo4Fitter.cxx:355
const char * GetDataName(Int_t n)
Definition: TGo4Fitter.cxx:108
Int_t GetNumModel() const
Definition: TGo4Fitter.h:178
TGo4FitModel * AddModel(TGo4FitModel *m)
Definition: TGo4Fitter.cxx:203
TObject * CreateDrawObject(const char *ObjName, const char *DataName, Bool_t IsModel=kFALSE, const char *ModelName=0)
Definition: TGo4Fitter.cxx:853
virtual Bool_t InitFitterData()
Definition: TGo4Fitter.cxx:454
void SetUserFitFunction(TUserFitFunction iFunc)
Definition: TGo4Fitter.h:97
TGo4FitDataHistogram * SetH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE)
Definition: TGo4Fitter.cxx:134
Bool_t CalculatesMomentums(const char *DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t &first, Double_t &second)
Definition: TGo4Fitter.cxx:732
Double_t * GetDataBinsValues(TGo4FitData *data)
Definition: TGo4Fitter.cxx:687
virtual void Clear(Option_t *option=0)
Definition: TGo4Fitter.cxx:96
TGo4FitData * FindData(const char *DataName)
Definition: TGo4Fitter.cxx:113
Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData *selectdata=0)
Definition: TGo4Fitter.cxx:523
void ProvideLastDrawObjects(TObjArray &lst)
Bool_t ModelBuffersAllocated(TGo4FitModel *model)
Definition: TGo4Fitter.cxx:672
void AddStandardActions()
Definition: TGo4Fitter.cxx:659
void DeleteAllModels()
Definition: TGo4Fitter.cxx:416
Int_t GetNumData() const
Definition: TGo4Fitter.h:123
TGo4FitDataHistogram * AddH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:126