00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TGO4FITMODEL_H
00017 #define TGO4FITMODEL_H
00018 #include "TString.h"
00019 #include "TGo4FitComponent.h"
00020 #include "TGo4FitParameter.h"
00021 #include "TGo4FitData.h"
00022 #include "TArrayC.h"
00023 #include "TNamed.h"
00024
00028 class TGo4FitAssignment : public TNamed {
00029 public:
00030
00034 TGo4FitAssignment();
00035
00039 TGo4FitAssignment(const char* DataName);
00040
00044 virtual ~TGo4FitAssignment();
00045
00046 Double_t RatioValue();
00047
00051 virtual void Print(Option_t* option) const;
00052
00056 TGo4FitParameter* fxRatio;
00057
00061 TGo4FitData* fxData;
00062
00066 Char_t* fxModelMask;
00067
00073 Double_t* fxModelBins;
00074
00075 ClassDef(TGo4FitAssignment,1);
00076 };
00077
00078
00082 class TGo4FitModel : public TGo4FitComponent {
00083 public:
00084
00088 TGo4FitModel();
00089
00095 TGo4FitModel(const char* iName, const char* iTitle, Bool_t MakeAmplitude = kFALSE);
00096
00100 virtual ~TGo4FitModel();
00101
00110 void SetGroupIndex(Int_t index = -1) { fiGroupIndex = index; }
00111
00115 void SetBackgroundGroupIndex() { fiGroupIndex = 0; }
00116
00120 Int_t GetGroupIndex() const { return fiGroupIndex; }
00121
00125 Int_t NumAssigments() const { return fxAssigments.GetLast()+1; }
00126
00130 const char* AssignmentName(Int_t n) { return GetAssigment(n) ? GetAssigment(n)->GetName() : 0; }
00131
00137 void AssignToData(const char* DataName, Double_t RatioValue = 1., Bool_t FixRatio = kFALSE);
00138
00142 Bool_t IsAssignTo(const char* DataName) const { return FindAssigment(DataName) != 0; }
00143
00147 void ChangeDataNameInAssignments(const char* oldname, const char* newname);
00148
00152 void ClearAssignmentTo(const char* DataName);
00153 void ClearAssigmentTo(const char* DataName) { ClearAssignmentTo(DataName); }
00154
00158 void ClearAssignments();
00159
00163 void ConnectToDataIfAssigned(TGo4FitData* data);
00164
00169 Double_t GetRatioValueFor(const char* DataName);
00170
00174 virtual void Print(Option_t* option) const;
00175
00179 virtual Double_t Evaluate(Double_t x);
00180
00184 virtual Double_t Evaluate(Double_t x, Double_t y);
00185
00189 virtual Double_t Evaluate(Double_t x, Double_t y, Double_t z);
00190
00194 virtual Double_t Evaluate(Double_t* v, Int_t ndim);
00195
00199 virtual Double_t Integral();
00200
00204 virtual Bool_t GetPosition(Int_t naxis, Double_t& pos);
00205
00209 virtual Bool_t SetPosition(Int_t naxis, Double_t pos);
00210
00214 virtual Bool_t GetWidth(Int_t naxis, Double_t& width);
00215
00219 virtual Bool_t SetWidth(Int_t naxis, Double_t width);
00220
00232 void SetIntegrationsProperty(Int_t iMinIntegrDepth, Int_t iMaxIntegrDepth = 0, Double_t iIntegrEps = 0., Bool_t iAbsoluteEps = kFALSE, Bool_t iIntegrScaling = kFALSE);
00233
00237 Bool_t NeedIntegration() { return (fiMinIntegrDepth>0) || (fiMaxIntegrDepth>0); }
00238
00243 virtual Bool_t BeforeEval(Int_t ndim);
00244
00249 virtual Double_t EvalN(const Double_t* v);
00250
00254 virtual void AfterEval() { return; }
00255
00260 virtual Double_t EvaluateAtPoint(TGo4FitData* data, Int_t nbin, Bool_t UseRanges = kTRUE);
00261
00265 virtual Double_t EvaluateAtPoint(TGo4FitDataIter* iter, Bool_t UseRanges = kTRUE);
00266
00271 Bool_t AddModelToDataResult(TGo4FitData* data);
00272
00273 virtual Int_t NumPars();
00274
00275 protected:
00276
00277 friend class TGo4Fitter;
00278
00279
00280 virtual TGo4FitParameter* Get(Int_t n);
00281
00285 Double_t EvaluateAndIntegrate(Int_t NumScales, const Double_t* Scales, const Double_t* Widths);
00286
00292 virtual Bool_t Initialize(Int_t UseBuffers = -1);
00293
00297 virtual void Finalize();
00298
00302 TGo4FitData* GetAssignedConnection(Int_t n);
00303
00307 Bool_t BuffersAllocated() const;
00308
00312 void RebuildShape(Bool_t ForceBuild = kFALSE);
00313
00317 Double_t* GetModelBins(const char* DataName) const;
00318
00322 void SetNeedToRebuild() { fbNeedToRebuild = kTRUE; }
00323
00329 virtual Double_t UserFunction(Double_t*, Double_t*) { return 0; }
00330
00334 virtual Int_t GetPosParIndex(Int_t) { return -1; }
00335
00339 virtual Int_t GetWidthParIndex(Int_t) { return -1; }
00340
00344 virtual TGo4FitParameter* GetPosPar(Int_t naxis = 0)
00345 { return Get(GetPosParIndex(naxis)); }
00346
00350 virtual TGo4FitParameter* GetWidthPar(Int_t naxis = 0)
00351 { return Get(GetWidthParIndex(naxis)); }
00352
00353 const Int_t* GetDataFullIndex(TGo4FitData* data, Int_t nbin);
00354 Int_t GetDataIndexesSize(TGo4FitData* data);
00355
00359 Int_t fiMinIntegrDepth;
00360
00364 Int_t fiMaxIntegrDepth;
00365
00369 Double_t fdIntegrEps;
00370
00374 Bool_t fbAbsoluteEps;
00375
00379 Bool_t fbIntegrScaling;
00380
00381 private:
00382
00386 void RemoveAllPars();
00387
00391 TGo4FitAssignment* GetAssigment(Int_t n) { return (TGo4FitAssignment*) fxAssigments[n]; }
00392 TGo4FitAssignment* GetAssigment(Int_t n) const { return (TGo4FitAssignment*) fxAssigments[n]; }
00393
00397 TGo4FitAssignment* FindAssigment(const char* DataName) const;
00398
00402 TString GetRatioName(Int_t n);
00403
00407 TObjArray fxAssigments;
00408
00412 Int_t fiGroupIndex;
00413
00417 TArrayD fxCurrentPars;
00418
00422 Double_t* fxCurrentParsArray;
00423
00427 Bool_t fbNeedToRebuild;
00428
00432 TGo4FitParsList* fxAllPars;
00433
00434 TArrayD* fxAllParsValues;
00435
00438
00439
00440 ClassDef(TGo4FitModel,1)
00441 };
00442 #endif // TGO4FITMODEL_H
00443
00444