Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4Fit/TGo4Fitter.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 <iostream.h>
00020 
00021 #include "TH1.h"
00022 #include "TGraph.h"
00023 #include "TArrayD.h"
00024 
00025 #include "TObjArray.h"
00026 #include "TGo4FitParameter.h"
00027 #include "TGo4FitData.h"
00028 #include "TGo4FitDataHistogram.h"
00029 #include "TGo4FitDataGraph.h"
00030 #include "TGo4FitModel.h"
00031 #include "TGo4FitModelGauss1.h"
00032 #include "TGo4FitSlot.h"
00033 #include "TGo4FitterAbstract.h"
00034 #include "TGo4FitterConfig.h"
00035 
00036 typedef Double_t (*TUserFitFunction)(Double_t, Double_t, Double_t);
00037 
00041 class TGo4Fitter : public TGo4FitterAbstract {
00042    public:
00043       enum  { ff_least_squares = 0,
00044               ff_chi_square    = 1,
00045               ff_chi_Pearson   = 2,
00046               ff_chi_Neyman    = 3,
00047               ff_chi_gamma     = 4,
00048               ff_ML_Poisson    = 5,
00049               ff_user          = 6 };
00050 
00054       TGo4Fitter();
00055 
00059       TGo4Fitter(const char* iName, const char* iTitle);
00060 
00065       TGo4Fitter(const char * iName, Int_t iFitFunctionType, Bool_t IsAddStandardActions);
00066 
00070       virtual ~TGo4Fitter();
00071 
00084       void SetFitFunctionType(Int_t iFitFunctionType) { fiFitFunctionType = iFitFunctionType; }
00085 
00089       Int_t GetFitFunctionType() { return fiFitFunctionType; }
00090 
00101       void SetUserFitFunction(TUserFitFunction iFunc) { fxUserFitFunction = iFunc; fiFitFunctionType = ff_user; }
00102 
00111       void SetMemoryUsage(Int_t iMemoryUsage);
00112 
00117       Int_t GetMemoryUsage() { return fiMemoryUsage; }
00118 
00122       virtual void Clear(Option_t* option = 0);
00123 
00127       Int_t GetNumData() const { return fxDatas.GetLast()+1; }
00128 
00132       TGo4FitData* GetData(Int_t n) { return (n>=0) && (n<GetNumData()) ? dynamic_cast<TGo4FitData*> (fxDatas[n]) : 0; }
00133 
00137       const char* GetDataName(Int_t n) { return GetData(n) ? GetData(n)->GetName() : 0; }
00138 
00142       TGo4FitData* FindData(const char* DataName) { return (DataName==0) ? 0 : dynamic_cast<TGo4FitData*> (fxDatas.FindObject(DataName)); }
00143 
00147       TGo4FitData* AddData(TGo4FitData* d);
00148 
00152       TGo4FitDataHistogram* AddH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00153 
00157       TGo4FitDataHistogram* SetH1(const char* DataName, TH1* histo, Bool_t Owned = kFALSE);
00158 
00162       TGo4FitDataGraph* AddGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE, Double_t lrange = 0., Double_t rrange = 0.);
00163 
00167       TGo4FitDataGraph* SetGraph(const char* DataName, TGraph* gr, Bool_t Owned = kFALSE);
00168 
00172       TGo4FitData* RemoveData(const char* DataName, Bool_t IsDel = kFALSE);
00173 
00177       void DeleteAllData();
00178 
00182       Int_t GetNumModel() const { return fxModels.GetLast()+1; }
00183 
00187       TGo4FitModel* GetModel(Int_t n) { return (n>=0) && (n<GetNumModel()) ? dynamic_cast<TGo4FitModel*> (fxModels[n]) : 0; }
00188 
00192       TGo4FitModel* FindModel(const char* ModelName) { return (ModelName==0) ? 0 : dynamic_cast<TGo4FitModel*> (fxModels.FindObject(ModelName)); }
00193 
00197       TGo4FitModel* AddModel(TGo4FitModel* m);
00198 
00202       TGo4FitModel* AddModel(const char* DataName, TGo4FitModel* m);
00203 
00212       void AddPolynomX(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t GroupIndex = 0, Double_t lrange = 0., Double_t rrange = 0. );
00213 
00219        void AddPolynomX(const char* DataName, const char* NamePrefix, TArrayD& Coef, Int_t GroupIndex = 0);
00220 
00228       void AddPolynoms(const char* DataName, const char* NamePrefix, Int_t MaxOrder = 1, Int_t NumAxis = 1, Int_t GroupIndex = 0);
00229 
00233       TGo4FitModelGauss1* AddGauss1(const char* DataName, const char* ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl = 1., Int_t Axis = 0);
00234 
00238       Int_t NumModelsAssosiatedTo(const char* DataName);
00239 
00243       TGo4FitModel* RemoveModel(const char * ModelName, Bool_t IsDel);
00244 
00248       void DeleteModelsAssosiatedTo(const char* DataName);
00249 
00253       void DeleteAllModels();
00254 
00260       void AssignModelTo(const char* ModelName, const char* DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
00261 
00266       void ClearModelAssignmentTo(const char* ModelName, const char* DataName = 0);
00267 
00272       void ChangeDataNameInAssignments(const char* oldname, const char* newname);
00273 
00278       Int_t GetNumComp() const { return GetNumData()+GetNumModel(); }
00279 
00285       TGo4FitComponent* GetComp(Int_t n) {  if(n<GetNumData()) return GetData(n); else return GetModel(n-GetNumData()); }
00286 
00292       void EstimateAmplitudes(Int_t NumIters = 1);
00293 
00297       void AddAmplEstimation(Int_t NumIters = 1);
00298 
00303       void AddStandardActions();
00304 
00308       Double_t CalculateFitFunction(Double_t* pars = 0, Int_t FitFunctionType = -1, const char* DataName = 0);
00309 
00315       Int_t CalculateNDF(const char* DataName = 0);
00316 
00320       virtual void FillSlotList(TSeqCollection* list);
00321 
00326       virtual void Print(Option_t* option) const;
00327 
00332       Bool_t CalculatesMomentums(const char* DataName, Bool_t UseRanges, Bool_t SubstractModels, Double_t& first, Double_t& second);
00333       
00338       Double_t CalculatesIntegral(const char* DataName, const char* ModelName = 0, Bool_t OnlyCounts = kFALSE);
00339       
00344       Double_t CalculatesModelIntegral(const char* ModelName, Bool_t OnlyCounts = kFALSE);
00345 
00350       TObject* CreateDrawObject(const char* ObjName, const char* DataName, Bool_t IsModel = kFALSE, const char* ModelName = 0);
00351 
00360       virtual void Draw(Option_t* option);
00361 
00366       void ProvideLastDrawObjects(TObjArray& lst);
00367 
00371       void PrintAmpls() const;
00372 
00376       void PrintLines() const;
00377 
00378       TString FindNextName(const char* Head, Int_t start, Bool_t isModel = kTRUE);
00379 
00380    protected:
00381 
00382       friend class TGo4FitAmplEstimation;
00383 
00384       // a set of function to access data buffers
00385 
00386       Bool_t ModelBuffersAllocated(TGo4FitModel* model);
00387       Bool_t DataBuffersAllocated(TGo4FitData* data);
00388 
00389       Int_t GetDataBinsSize(TGo4FitData* data);
00390       Double_t* GetDataBinsValues(TGo4FitData* data);
00391       Double_t* GetDataBinsDevs(TGo4FitData* data);
00392       Double_t* GetDataBinsResult(TGo4FitData* data);
00393       Double_t* GetModelBinsValues(TGo4FitModel* model, const char* DataName);
00394 
00400       void RebuildAll(Bool_t ForceBuild = kFALSE);
00401 
00402 
00403       virtual void CollectAllPars();
00404 
00405       virtual Double_t DoCalculation();
00406       virtual Int_t DoNDFCalculation();
00407       Double_t CalculateFCN(Int_t FitFunctionType, TGo4FitData* selectdata = 0);
00408       Double_t PointFitFunction(Int_t FitFunctionType, Double_t value, Double_t modelvalue, Double_t standdev);
00409 
00410       virtual Bool_t InitFitterData();
00411       virtual void FinalizeFitterData();
00412 
00416       TObjArray fxDatas;
00417 
00421       TObjArray fxModels;
00422 
00426       Int_t fiFitFunctionType;
00427 
00431       Int_t fiMemoryUsage;
00432 
00433    private:
00434 
00435       void MoveDrawObjectsToROOT();
00436       void CheckSlotsBeforeDelete(TGo4FitComponent* comp);
00437 
00441       TUserFitFunction fxUserFitFunction;    
00442 
00443       TObjArray* fxDrawObjs;                 
00444 
00445 
00449       /*#  TGo4FitModel Models; */
00450 
00454       /*#  TGo4FitData Datas; */
00455    ClassDef(TGo4Fitter,1)
00456 };
00457 
00458 
00459 #endif // TGO4FITTER_H
00460 
00461 
00462 
00463 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:57 2005 for Go4-v2.10-5 by doxygen1.2.15