Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4Fitter.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #ifndef TGO4FITTER_H
00017 #define TGO4FITTER_H
00018 
00019 #include "TGo4FitterAbstract.h"
00020 
00021 class TH1;
00022 class TGraph;
00023 
00024 #include "TArrayD.h"
00025 #include "TObjArray.h"
00026 
00027 class TGo4FitComponent;
00028 class TGo4FitData;
00029 class TGo4FitDataHistogram;
00030 class TGo4FitDataGraph;
00031 class TGo4FitModel;
00032 class TGo4FitModelGauss1;
00033 
00034 typedef Double_t (*TUserFitFunction)(Double_t, Double_t, Double_t);
00035 
00039 class TGo4Fitter : public TGo4FitterAbstract {
00040    public:
00041       enum  { ff_least_squares = 0,
00042               ff_chi_square    = 1,
00043               ff_chi_Pearson   = 2,
00044               ff_chi_Neyman    = 3,
00045               ff_chi_gamma     = 4,
00046               ff_ML_Poisson    = 5,
00047               ff_user          = 6 };
00048 
00052       TGo4Fitter();
00053 
00057       TGo4Fitter(const char* iName, const char* iTitle);
00058 
00063       TGo4Fitter(const char * iName, Int_t iFitFunctionType, Bool_t IsAddStandardActions);
00064 
00068       virtual ~TGo4Fitter();
00069 
00082       void SetFitFunctionType(Int_t iFitFunctionType) { fiFitFunctionType = iFitFunctionType; }
00083 
00087       Int_t GetFitFunctionType() { return fiFitFunctionType; }
00088 
00099       void SetUserFitFunction(TUserFitFunction iFunc) { fxUserFitFunction = iFunc; fiFitFunctionType = ff_user; }
00100 
00109       void SetMemoryUsage(Int_t iMemoryUsage);
00110 
00115       Int_t GetMemoryUsage() { return fiMemoryUsage; }
00116 
00120       virtual void Clear(Option_t* option = 0);
00121 
00125       Int_t GetNumData() const { return fxDatas.GetLast()+1; }
00126 
00130       TGo4FitData* GetData(Int_t n);
00131 
00135       const char* GetDataName(Int_t n);
00136 
00140       TGo4FitData* FindData(const char* DataName);
00141 
00145       TGo4FitData* AddData(TGo4FitData* d);
00146 
00150       TGo4FitDataHistogram* AddH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00151 
00155       TGo4FitDataHistogram* SetH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE);
00156 
00160       TGo4FitDataGraph* AddGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00161 
00165       TGo4FitDataGraph* SetGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE);
00166 
00170       TGo4FitData* RemoveData(const char* DataName, Bool_t IsDel = kFALSE);
00171 
00175       void DeleteAllData();
00176 
00180       Int_t GetNumModel() const { return fxModels.GetLast()+1; }
00181 
00185       TGo4FitModel* GetModel(Int_t n);
00186 
00190       TGo4FitModel* FindModel(const char* ModelName);
00191 
00195       TGo4FitModel* AddModel(TGo4FitModel* m);
00196 
00200       TGo4FitModel* AddModel(const char* DataName, TGo4FitModel* m);
00201 
00210       void AddPolynomX(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t GroupIndex = 0, Double_t lrange = 0., Double_t rrange = 0. );
00211 
00217        void AddPolynomX(const char* DataName, const char* NamePrefix, TArrayD& Coef, Int_t GroupIndex = 0);
00218 
00226       void AddPolynoms(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t NumAxis = 1, Int_t GroupIndex = 0);
00227 
00231       TGo4FitModelGauss1* AddGauss1(const char* DataName, const char* ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl = 1., Int_t Axis = 0);
00232 
00236       Int_t NumModelsAssosiatedTo(const char* DataName);
00237 
00241       TGo4FitModel* CloneModel(const char* ModelName, const char* NewName = 0);
00242 
00248       TGo4FitModel* RemoveModel(const char* ModelName, Bool_t IsDel = kFALSE);
00249 
00253       void DeleteModelsAssosiatedTo(const char* DataName);
00254 
00258       void DeleteAllModels();
00259 
00265       void AssignModelTo(const char* ModelName, const char* DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
00266 
00271       void ClearModelAssignmentTo(const char* ModelName, const char* DataName = 0);
00272 
00277       void ChangeDataNameInAssignments(const char* oldname, const char* newname);
00278 
00283       Int_t GetNumComp() const { return GetNumData()+GetNumModel(); }
00284 
00290       TGo4FitComponent* GetComp(Int_t n);
00291 
00297       void EstimateAmplitudes(Int_t NumIters = 1);
00298 
00302       void AddAmplEstimation(Int_t NumIters = 1);
00303 
00308       void AddStandardActions();
00309 
00313       Double_t CalculateFitFunction(Double_t* pars = 0, Int_t FitFunctionType = -1, const char* DataName = 0);
00314 
00320       Int_t CalculateNDF(const char* DataName = 0);
00321 
00325       virtual void FillSlotList(TSeqCollection* list);
00326 
00331       virtual void Print(Option_t* option) const;
00332 
00337       Bool_t CalculatesMomentums(const char* DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t& first, Double_t& second);
00338 
00343       Double_t CalculatesIntegral(const char* DataName, const char* ModelName = 0, Bool_t OnlyCounts = kFALSE);
00344 
00349       Double_t CalculatesModelIntegral(const char* ModelName, Bool_t OnlyCounts = kFALSE);
00350 
00355       TObject* CreateDrawObject(const char* ObjName, const char* DataName, Bool_t IsModel = kFALSE, const char* ModelName = 0);
00356 
00365       virtual void Draw(Option_t* option);
00366 
00371       void ProvideLastDrawObjects(TObjArray& lst);
00372 
00376       void PrintAmpls() const;
00377 
00381       void PrintLines() const;
00382 
00383       TString FindNextName(const char* Head, Int_t start, Bool_t isModel = kTRUE);
00384 
00385    protected:
00386 
00387       friend class TGo4FitAmplEstimation;
00388 
00389       // a set of function to access data buffers
00390 
00391       Bool_t ModelBuffersAllocated(TGo4FitModel* model);
00392       Bool_t DataBuffersAllocated(TGo4FitData* data);
00393 
00394       Int_t GetDataBinsSize(TGo4FitData* data);
00395       Double_t* GetDataBinsValues(TGo4FitData* data);
00396       Double_t* GetDataBinsDevs(TGo4FitData* data);
00397       Double_t* GetDataBinsResult(TGo4FitData* data);
00398       Double_t* GetModelBinsValues(TGo4FitModel* model, const char* DataName);
00399 
00405       void RebuildAll(Bool_t ForceBuild = kFALSE);
00406 
00407 
00408       virtual void CollectAllPars();
00409 
00410       virtual Double_t DoCalculation();
00411       virtual Int_t DoNDFCalculation();
00412       Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData* selectdata = 0);
00413       Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev);
00414 
00415       virtual Bool_t InitFitterData();
00416       virtual void FinalizeFitterData();
00417 
00421       TObjArray fxDatas;
00422 
00426       TObjArray fxModels;
00427 
00431       Int_t fiFitFunctionType;
00432 
00436       Int_t fiMemoryUsage;
00437 
00438    private:
00439 
00440       void MoveDrawObjectsToROOT();
00441       void CheckSlotsBeforeDelete(TGo4FitComponent* comp);
00442 
00446       TUserFitFunction fxUserFitFunction;    
00447 
00448       TObjArray* fxDrawObjs;                 
00449 
00450 
00454       /*#  TGo4FitModel Models; */
00455 
00459       /*#  TGo4FitData Datas; */
00460    ClassDef(TGo4Fitter,1)
00461 };
00462 
00463 
00464 #endif // TGO4FITTER_H
00465 
00466 
00467 
00468 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:13 2008 for Go4-v3.04-1 by  doxygen 1.4.2