TGo4Fitter.h

Go to the documentation of this file.
00001 // $Id: TGo4Fitter.h 555 2010-01-27 12:40:54Z linev $
00002 //-----------------------------------------------------------------------
00003 //       The GSI Online Offline Object Oriented (Go4) Project
00004 //         Experiment Data Processing at EE department, GSI
00005 //-----------------------------------------------------------------------
00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
00007 //                     Planckstr. 1, 64291 Darmstadt, Germany
00008 // Contact:            http://go4.gsi.de
00009 //-----------------------------------------------------------------------
00010 // This software can be used under the license agreements as stated
00011 // in Go4License.txt file which is part of the distribution.
00012 //-----------------------------------------------------------------------
00013 
00014 #ifndef TGO4FITTER_H
00015 #define TGO4FITTER_H
00016 
00017 #include "TGo4FitterAbstract.h"
00018 
00019 class TH1;
00020 class TGraph;
00021 
00022 #include "TArrayD.h"
00023 #include "TObjArray.h"
00024 
00025 class TGo4FitComponent;
00026 class TGo4FitData;
00027 class TGo4FitDataHistogram;
00028 class TGo4FitDataGraph;
00029 class TGo4FitModel;
00030 class TGo4FitModelGauss1;
00031 
00032 typedef Double_t (*TUserFitFunction)(Double_t, Double_t, Double_t);
00033 
00037 class TGo4Fitter : public TGo4FitterAbstract {
00038    public:
00039       enum  { ff_least_squares = 0,
00040               ff_chi_square    = 1,
00041               ff_chi_Pearson   = 2,
00042               ff_chi_Neyman    = 3,
00043               ff_chi_gamma     = 4,
00044               ff_ML_Poisson    = 5,
00045               ff_user          = 6 };
00046 
00050       TGo4Fitter();
00051 
00055       TGo4Fitter(const char* iName, const char* iTitle);
00056 
00061       TGo4Fitter(const char * iName, Int_t iFitFunctionType, Bool_t IsAddStandardActions);
00062 
00066       virtual ~TGo4Fitter();
00067 
00080       void SetFitFunctionType(Int_t iFitFunctionType) { fiFitFunctionType = iFitFunctionType; }
00081 
00085       Int_t GetFitFunctionType() { return fiFitFunctionType; }
00086 
00097       void SetUserFitFunction(TUserFitFunction iFunc) { fxUserFitFunction = iFunc; fiFitFunctionType = ff_user; }
00098 
00107       void SetMemoryUsage(Int_t iMemoryUsage);
00108 
00113       Int_t GetMemoryUsage() { return fiMemoryUsage; }
00114 
00118       virtual void Clear(Option_t* option = 0);
00119 
00123       Int_t GetNumData() const { return fxDatas.GetLast()+1; }
00124 
00128       TGo4FitData* GetData(Int_t n);
00129 
00133       const char* GetDataName(Int_t n);
00134 
00138       TGo4FitData* FindData(const char* DataName);
00139 
00143       TGo4FitData* AddData(TGo4FitData* d);
00144 
00148       TGo4FitDataHistogram* AddH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00149 
00153       TGo4FitDataHistogram* SetH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE);
00154 
00158       TGo4FitDataGraph* AddGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00159 
00163       TGo4FitDataGraph* SetGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE);
00164 
00168       TGo4FitData* RemoveData(const char* DataName, Bool_t IsDel = kFALSE);
00169 
00173       void DeleteAllData();
00174 
00178       Int_t GetNumModel() const { return fxModels.GetLast()+1; }
00179 
00183       TGo4FitModel* GetModel(Int_t n);
00184 
00188       TGo4FitModel* FindModel(const char* ModelName);
00189 
00193       TGo4FitModel* AddModel(TGo4FitModel* m);
00194 
00198       TGo4FitModel* AddModel(const char* DataName, TGo4FitModel* m);
00199 
00208       void AddPolynomX(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t GroupIndex = 0, Double_t lrange = 0., Double_t rrange = 0. );
00209 
00215        void AddPolynomX(const char* DataName, const char* NamePrefix, TArrayD& Coef, Int_t GroupIndex = 0);
00216 
00224       void AddPolynoms(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t NumAxis = 1, Int_t GroupIndex = 0);
00225 
00229       TGo4FitModelGauss1* AddGauss1(const char* DataName, const char* ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl = 1., Int_t Axis = 0);
00230 
00234       Int_t NumModelsAssosiatedTo(const char* DataName);
00235 
00239       TGo4FitModel* CloneModel(const char* ModelName, const char* NewName = 0);
00240 
00246       TGo4FitModel* RemoveModel(const char* ModelName, Bool_t IsDel = kFALSE);
00247 
00251       void DeleteModelsAssosiatedTo(const char* DataName);
00252 
00256       void DeleteAllModels();
00257 
00263       void AssignModelTo(const char* ModelName, const char* DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
00264 
00269       void ClearModelAssignmentTo(const char* ModelName, const char* DataName = 0);
00270 
00275       void ChangeDataNameInAssignments(const char* oldname, const char* newname);
00276 
00281       Int_t GetNumComp() const { return GetNumData()+GetNumModel(); }
00282 
00288       TGo4FitComponent* GetComp(Int_t n);
00289 
00295       void EstimateAmplitudes(Int_t NumIters = 1);
00296 
00300       void AddAmplEstimation(Int_t NumIters = 1);
00301 
00306       void AddStandardActions();
00307 
00311       Double_t CalculateFitFunction(Double_t* pars = 0, Int_t FitFunctionType = -1, const char* DataName = 0);
00312 
00318       Int_t CalculateNDF(const char* DataName = 0);
00319 
00323       virtual void FillSlotList(TSeqCollection* list);
00324 
00329       virtual void Print(Option_t* option) const;
00330 
00335       Bool_t CalculatesMomentums(const char* DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t& first, Double_t& second);
00336 
00341       Double_t CalculatesIntegral(const char* DataName, const char* ModelName = 0, Bool_t OnlyCounts = kFALSE);
00342 
00347       Double_t CalculatesModelIntegral(const char* ModelName, Bool_t OnlyCounts = kFALSE);
00348 
00353       TObject* CreateDrawObject(const char* ObjName, const char* DataName, Bool_t IsModel = kFALSE, const char* ModelName = 0);
00354 
00363       virtual void Draw(Option_t* option);
00364 
00369       void ProvideLastDrawObjects(TObjArray& lst);
00370 
00374       void PrintAmpls() const;
00375 
00379       void PrintLines() const;
00380 
00381       TString FindNextName(const char* Head, Int_t start, Bool_t isModel = kTRUE);
00382 
00383    protected:
00384 
00385       friend class TGo4FitAmplEstimation;
00386 
00387       // a set of function to access data buffers
00388 
00389       Bool_t ModelBuffersAllocated(TGo4FitModel* model);
00390       Bool_t DataBuffersAllocated(TGo4FitData* data);
00391 
00392       Int_t GetDataBinsSize(TGo4FitData* data);
00393       Double_t* GetDataBinsValues(TGo4FitData* data);
00394       Double_t* GetDataBinsDevs(TGo4FitData* data);
00395       Double_t* GetDataBinsResult(TGo4FitData* data);
00396       Double_t* GetModelBinsValues(TGo4FitModel* model, const char* DataName);
00397 
00403       void RebuildAll(Bool_t ForceBuild = kFALSE);
00404 
00405 
00406       virtual void CollectAllPars();
00407 
00408       virtual Double_t DoCalculation();
00409       virtual Int_t DoNDFCalculation();
00410       Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData* selectdata = 0);
00411       Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev);
00412 
00413       virtual Bool_t InitFitterData();
00414       virtual void FinalizeFitterData();
00415 
00419       TObjArray fxDatas;
00420 
00424       TObjArray fxModels;
00425 
00429       Int_t fiFitFunctionType;
00430 
00434       Int_t fiMemoryUsage;
00435 
00436    private:
00437 
00438       void MoveDrawObjectsToROOT();
00439       void CheckSlotsBeforeDelete(TGo4FitComponent* comp);
00440 
00444       TUserFitFunction fxUserFitFunction;    
00445 
00446       TObjArray* fxDrawObjs;                 
00447 
00448 
00452       /*#  TGo4FitModel Models; */
00453 
00457       /*#  TGo4FitData Datas; */
00458    ClassDef(TGo4Fitter,1)
00459 };
00460 
00461 
00462 #endif // TGO4FITTER_H
00463 
00464 

Generated on Thu Oct 28 15:54:12 2010 for Go4-Fitpackagev4.04-2 by  doxygen 1.5.1