File indexing completed on 2024-11-15 09:57:09
0001
0002
0003
0004 #ifndef ROOT_TFractionFitter
0005 #define ROOT_TFractionFitter
0006
0007 #ifndef ROOT_TVirtualFitter
0008 # include "TVirtualFitter.h"
0009 #endif
0010
0011 #ifndef ROOT_TObjArray
0012 # include "TObjArray.h"
0013 #endif
0014
0015 #include "TFitResultPtr.h"
0016
0017 #include <vector>
0018
0019 class TH1;
0020
0021 namespace ROOT {
0022 namespace Fit {
0023 class Fitter;
0024 }
0025 }
0026
0027 class TFractionFitter: public TObject {
0028 public:
0029 TFractionFitter();
0030 TFractionFitter(TH1* data, TObjArray *MCs, Option_t *option="");
0031 ~TFractionFitter() override;
0032
0033
0034 ROOT::Fit::Fitter* GetFitter() const;
0035 void ErrorAnalysis(Double_t UP);
0036 void SetRangeX(Int_t low, Int_t high);
0037 void ReleaseRangeX();
0038 void SetRangeY(Int_t low, Int_t high);
0039 void ReleaseRangeY();
0040 void SetRangeZ(Int_t low, Int_t high);
0041 void ReleaseRangeZ();
0042 void ExcludeBin(Int_t bin);
0043 void IncludeBin(Int_t bin);
0044 void Constrain(Int_t parm, Double_t low, Double_t high);
0045 void UnConstrain(Int_t parm);
0046 void SetData(TH1 *data);
0047 void SetMC(Int_t parm, TH1 *MC);
0048 void SetWeight(Int_t parm, TH1* weight);
0049 TFitResultPtr Fit();
0050
0051 void GetResult(Int_t parm, Double_t& value, Double_t& error) const;
0052 TH1* GetPlot();
0053
0054
0055
0056
0057
0058 Double_t GetChisquare() const;
0059 Int_t GetNDF() const;
0060 Double_t GetProb() const;
0061
0062
0063 TH1* GetMCPrediction(Int_t parm) const;
0064
0065
0066 Double_t EvaluateFCN(const Double_t * par) {
0067 Double_t f = 0;
0068 ComputeFCN(f, par, 0);
0069 return f;
0070 }
0071
0072 private:
0073 void CheckParNo(Int_t parm) const;
0074 void CheckConsistency();
0075 void FindPrediction(int bin, double& t_i, int& k_0, double& A_ki) const;
0076 void ComputeFCN(Double_t& f, const Double_t* par, Int_t flag);
0077 void GetRanges(Int_t& minX, Int_t& maxX, Int_t& minY, Int_t& maxY,
0078 Int_t& minZ, Int_t& maxZ) const;
0079 void ComputeChisquareLambda();
0080 bool IsExcluded(Int_t bin) const;
0081
0082 protected:
0083 Bool_t fFitDone;
0084 Int_t fLowLimitX;
0085 Int_t fHighLimitX;
0086 Int_t fLowLimitY;
0087 Int_t fHighLimitY;
0088 Int_t fLowLimitZ;
0089 Int_t fHighLimitZ;
0090 std::vector<Int_t> fExcludedBins;
0091
0092 Int_t fNpfits;
0093 Int_t fNDF;
0094 Double_t fChisquare;
0095
0096 TObjArray fAji;
0097
0098
0099
0100 TH1* fData;
0101 TObjArray fMCs;
0102 TObjArray fWeights;
0103 Double_t fIntegralData;
0104 Double_t* fIntegralMCs;
0105 Double_t* fFractions;
0106 TH1* fPlot;
0107 ROOT::Fit::Fitter *fFractionFitter;
0108
0109
0110 Int_t fNpar;
0111
0112 ClassDefOverride(TFractionFitter, 0);
0113 };
0114
0115
0116
0117
0118
0119
0120
0121 void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
0122
0123 #endif