00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TGO4FITDATA_H
00017 #define TGO4FITDATA_H
00018
00019 #include "TArrayI.h"
00020 #include "TArrayD.h"
00021 #include "TArrayC.h"
00022 #include "TH1.h"
00023 #include "TGraph.h"
00024 #include "TGo4FitSlot.h"
00025 #include "TGo4FitComponent.h"
00026 #include "TGo4FitAxisTrans.h"
00027
00028 class TGo4FitDataIter;
00029
00033 class TGo4FitData : public TGo4FitComponent {
00034 public:
00035 enum { dtHistogram = 1, dtGraph = 2 };
00036
00040 TGo4FitData();
00041
00048 TGo4FitData(const char* iName, const char* iTitle, Int_t iDataType = dtHistogram, Bool_t AddAmpl = kFALSE);
00049
00053 virtual ~TGo4FitData();
00054
00058 const Int_t GetDataType() { return fiDataType; }
00059
00063 Bool_t GetUseBinScale() { return fbUseBinScale; }
00064
00068 void SetUseBinScale(Bool_t iUseBinScale) { fbUseBinScale=iUseBinScale; }
00069
00075 virtual Bool_t CanAmplTouch() { return kTRUE; }
00076
00084 Int_t GetSigmaSource() const { return fiTakeSigmasFrom; }
00085
00090 Double_t GetSigmaValue() const { return fdSigmaValue; }
00091
00096 void SetSigmaSource(Int_t TakeFrom, Double_t SigmaValue = 1.)
00097 { fiTakeSigmasFrom = TakeFrom; if ((TakeFrom==2) && (SigmaValue>0)) fdSigmaValue = SigmaValue; }
00098
00103 void SetSigmaValue(Double_t SigmaValue) { fdSigmaValue = SigmaValue; }
00104
00108 void SetExcludeLessThen(Double_t limit = 0.) { fdExcludeLessThen = limit; }
00109
00113 Double_t GetExcludeLessThen() const { return fdExcludeLessThen; }
00114
00122 Bool_t SetNumberOfTransSlots(Int_t nslots);
00123
00127 Int_t GetNumberOfTransSlots() { return fxAxisTrans.GetLast()+1; }
00128
00132 TGo4FitSlot* GetAxisTransSlot(Int_t nslot);
00133
00137 TGo4FitAxisTrans* GetAxisTrans(Int_t nslot);
00138
00143 void SetAxisTrans(Int_t nslot, TGo4FitAxisTrans* Trans, Bool_t TransOwned = kFALSE);
00144
00149 void AddAxisTrans(TGo4FitAxisTrans* Trans, Bool_t TransOwned = kFALSE);
00150
00154 void SetAxisTransNeeded(Int_t nslot, Bool_t iNeeded = kFALSE);
00155
00160 virtual Bool_t IsAnyDataTransform();
00161
00166 virtual TGo4FitDataIter* MakeIter() { return 0; }
00167
00172 TObject* CreateDrawObject(const char* ObjName);
00173
00178 Bool_t DefineScaleMinMax(Int_t naxis, Double_t& min, Double_t& max);
00179
00184 Int_t DefineDimensions();
00185
00190 Int_t DefineBinsSize();
00191
00197 Bool_t IsCompatibleData(TGo4FitData* data);
00198
00205 void ApplyRangesForModelMask(TGo4FitComponent* model, Char_t* ModelMask);
00206
00210 virtual void FillSlotList(TSeqCollection* list);
00211
00215 virtual void Print(Option_t* option) const;
00216
00217 protected:
00218
00219 friend class TGo4FitModel;
00220 friend class TGo4Fitter;
00221
00229 virtual Bool_t Initialize(Int_t UseBuffers = -1);
00230
00234 virtual void Finalize();
00235
00239 Bool_t BuffersAllocated() const { return (fxValues!=0) && (fxFullScale!=0); }
00240
00244 Int_t GetBinsSize() const { return fiBinsSize; }
00245
00250 Int_t GetScalesSize() const { return fiScalesSize; }
00251
00256 Double_t* GetBinsValues() { return fxValues; }
00257
00262 Double_t* GetBinsDevs() { return fxStandDev; }
00263
00268 Double_t* GetBinsResult() { return fxBinsResult; }
00269
00274 const Double_t* GetScaleValues(const Int_t nbin);
00275
00280 const Double_t* GetWidthValues(const Int_t nbin);
00281
00286 const Int_t* GetFullIndex(Int_t nbin);
00287
00292 Int_t GetIndexesSize() const { return fiIndexesSize; }
00293
00298 Int_t fiDataType;
00299
00304 Bool_t fbUseBinScale;
00305
00310 Int_t fiTakeSigmasFrom;
00311
00315 Double_t fdSigmaValue;
00316
00320 Double_t fdExcludeLessThen;
00321
00322
00326 TObjArray fxAxisTrans;
00327
00333 private:
00334
00338 void ResetAllPoinetrs();
00339
00343 void ReleaseAllPointers();
00344
00348 Int_t fiBinsSize;
00349
00353 Int_t fiIndexesSize;
00354
00358 Int_t fiScalesSize;
00359
00363 Double_t* fxValues;
00364
00368 Double_t* fxStandDev;
00369
00373 Double_t* fxBinsResult;
00374
00380 Double_t* fxFullScale;
00381
00387 Double_t* fxFullWidth;
00388
00394 Int_t* fxFullIndex;
00395
00398
00399
00403
00404
00405
00406 ClassDef(TGo4FitData,1)
00407 };
00408
00425 class TGo4FitDataIter : public TObject {
00426 public:
00427
00431 TGo4FitDataIter();
00432
00436 virtual ~TGo4FitDataIter();
00437
00443 virtual Bool_t Reset(Bool_t UseRanges = kTRUE);
00444
00451 virtual Bool_t Next(Bool_t UseRanges = kTRUE);
00452
00456 Bool_t HasIndexes() const { return IndexesSize() > 0; }
00457
00461 Int_t IndexesSize() const { return fxIndexes.GetSize(); }
00462
00466 const Int_t* Indexes() const { return fxIndexes.GetArray(); }
00467
00471 Bool_t DefineIndexesLimits(TArrayI& Limits);
00472
00476 Int_t ScalesSize() const { return fxScales.GetSize(); }
00477
00481 const Double_t* Scales() const { return fxScales.GetSize() > 0 ? fxScales.GetArray() : 0; }
00482
00486 Double_t x() const { return fxScales.GetSize() > 0 ? fxScales[0] : 0.; }
00487
00491 Double_t y() const { return fxScales.GetSize() > 1 ? fxScales[1] : 0.; }
00492
00496 Double_t z() const { return fxScales.GetSize() > 2 ? fxScales[2] : 0.; }
00497
00501 Bool_t HasWidths() const { return fxWidths.GetSize() > 0; }
00502
00506 const Double_t* Widths() const { return fxWidths.GetSize() > 0 ? fxWidths.GetArray() : 0; }
00507
00511 Double_t xWidths() const;
00512
00516 Double_t Value() const { return fdValue; }
00517
00521 Double_t StandardDeviation() const { return fdStandardDeviation; }
00522
00526 Int_t Point() const { return fiNumPoint; }
00527
00531 Bool_t CheckPointForRange();
00532
00537 Int_t CountPoints(Bool_t UseRanges = kTRUE);
00538
00543 Bool_t ReachEnd() const { return fbReachEnd; }
00544
00550 TH1* CreateHistogram(const char* HistoName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
00551
00559 TGraph* CreateGraph(const char* GraphName, Bool_t UseRanges = kFALSE, Bool_t SetBins = kFALSE);
00560
00564 TObject* CreateDrawObject(const char* ObjName);
00565
00566 protected:
00567
00572 virtual TGo4FitData* GetData() const = 0;
00573
00578 virtual Bool_t StartReset() = 0;
00579
00584 virtual Bool_t ReadCurrentPoint() = 0;
00585
00590 virtual Bool_t ShiftToNextPoint() = 0;
00591
00596 Bool_t ReserveArrays(Int_t NumDimen, Int_t NumOwnAxis, Bool_t HasWidth);
00597
00601 void TransformScales(Double_t* scales);
00602
00607 Bool_t ProduceScales(const Int_t* index, const Double_t* ownscales, const Double_t* ownwidths);
00608
00612 Bool_t NextIndex(TArrayI& Index, TArrayI& Limits);
00613
00617 Bool_t GetDeviation();
00618
00619 TArrayI fxIndexes;
00620
00621 TArrayD fxScales;
00622 TArrayD fxWidths;
00623 Double_t fdValue;
00624 Double_t fdStandardDeviation;
00625
00626 Int_t fiNumPoint;
00627
00628 Bool_t fbReachEnd;
00629
00630 ClassDef(TGo4FitDataIter,1)
00631 };
00632
00633
00634 #endif // TGO4FITDATA_H
00635
00636