File indexing completed on 2024-04-06 12:31:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef SimG4Core_TotemRPProtonTransportParametrization_TMultiDimFet_H
0014 #define SimG4Core_TotemRPProtonTransportParametrization_TMultiDimFet_H
0015
0016 #ifndef ROOT_TNamed
0017 #include "TNamed.h"
0018 #endif
0019 #ifndef ROOT_TVectorD
0020 #include "TVectorD.h"
0021 #endif
0022 #ifndef ROOT_TMatrixD
0023 #include "TMatrixD.h"
0024 #endif
0025 #ifndef ROOT_TList
0026 #include "TList.h"
0027 #endif
0028 #ifndef ROOT_TVirtualFitter
0029 #include "TVirtualFitter.h"
0030 #endif
0031
0032 #include <vector>
0033
0034
0035
0036 class TMultiDimFet : public TNamed {
0037 public:
0038 enum EMDFPolyType { kMonomials, kChebyshev, kLegendre };
0039
0040 protected:
0041 TVectorD fQuantity;
0042 TVectorD fSqError;
0043 Double_t fMeanQuantity;
0044 Double_t fMaxQuantity;
0045 Double_t fMinQuantity;
0046 Double_t fSumSqQuantity;
0047 Double_t fSumSqAvgQuantity;
0048
0049 TVectorD fVariables;
0050 Int_t fNVariables;
0051 TVectorD fMeanVariables;
0052 TVectorD fMaxVariables;
0053 TVectorD fMinVariables;
0054
0055 Int_t fSampleSize;
0056
0057 TVectorD fTestQuantity;
0058 TVectorD fTestSqError;
0059 TVectorD fTestVariables;
0060
0061 Int_t fTestSampleSize;
0062
0063 Double_t fMinAngle;
0064 Double_t fMaxAngle;
0065 Int_t fMaxTerms;
0066 Double_t fMinRelativeError;
0067 std::vector<Int_t> fMaxPowers;
0068 Double_t fPowerLimit;
0069
0070 TMatrixD fFunctions;
0071 Int_t fMaxFunctions;
0072 std::vector<Int_t> fFunctionCodes;
0073 Int_t fMaxStudy;
0074
0075 TMatrixD fOrthFunctions;
0076 TVectorD fOrthFunctionNorms;
0077
0078 std::vector<Int_t> fMaxPowersFinal;
0079 Int_t fMaxFunctionsTimesNVariables;
0080 std::vector<Int_t> fPowers;
0081 std::vector<Int_t> fPowerIndex;
0082
0083 TVectorD fResiduals;
0084 Double_t fMaxResidual;
0085 Double_t fMinResidual;
0086 Int_t fMaxResidualRow;
0087 Int_t fMinResidualRow;
0088 Double_t fSumSqResidual;
0089
0090 Int_t fNCoefficients;
0091 TVectorD fOrthCoefficients;
0092 TMatrixD fOrthCurvatureMatrix;
0093 TVectorD fCoefficients;
0094 TVectorD fCoefficientsRMS;
0095 Double_t fRMS;
0096 Double_t fChi2;
0097 Int_t fParameterisationCode;
0098
0099 Double_t fError;
0100 Double_t fTestError;
0101 Double_t fPrecision;
0102 Double_t fTestPrecision;
0103 Double_t fCorrelationCoeff;
0104 TMatrixD fCorrelationMatrix;
0105 Double_t fTestCorrelationCoeff;
0106
0107 TList *fHistograms;
0108 Byte_t fHistogramMask;
0109
0110
0111
0112 EMDFPolyType fPolyType;
0113 Bool_t fShowCorrelation;
0114 Bool_t fIsUserFunction;
0115 Bool_t fIsVerbose;
0116
0117 virtual Double_t EvalFactor(Int_t p, Double_t x) const;
0118 virtual Double_t EvalControl(const Int_t *powers);
0119 virtual void MakeCoefficientErrors();
0120 virtual void MakeCorrelation();
0121 virtual Double_t MakeGramSchmidt(Int_t function);
0122 virtual void MakeCoefficients();
0123 virtual void MakeCandidates();
0124 virtual void MakeNormalized();
0125 virtual void MakeParameterization();
0126 virtual void MakeRealCode(const char *filename, const char *classname, Option_t *option = "");
0127 virtual Bool_t Select(const Int_t *iv);
0128 virtual Bool_t TestFunction(Double_t squareResidual, Double_t dResidur);
0129
0130 public:
0131 TMultiDimFet();
0132 TMultiDimFet(const TMultiDimFet &in) = default;
0133 const TMultiDimFet &operator=(const TMultiDimFet &in);
0134
0135 TMultiDimFet(Int_t dimension, EMDFPolyType type = kMonomials, Option_t *option = "");
0136 ~TMultiDimFet() override;
0137
0138 virtual void AddRow(const Double_t *x, Double_t D, Double_t E = 0);
0139 virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E = 0);
0140
0141 void Clear(Option_t *option = "") override;
0142
0143 virtual Double_t Eval(const Double_t *x, const Double_t *coeff = nullptr) const;
0144 virtual void FindParameterization(double precision);
0145
0146
0147 Double_t GetChi2() const { return fChi2; }
0148 const TMatrixD *GetCorrelationMatrix() const { return &fCorrelationMatrix; }
0149 const TVectorD *GetCoefficients() const { return &fCoefficients; }
0150 Double_t GetError() const { return fError; }
0151 std::vector<Int_t> GetFunctionCodes() const { return fFunctionCodes; }
0152 const TMatrixD *GetFunctions() const { return &fFunctions; }
0153 virtual TList *GetHistograms() const { return fHistograms; }
0154 Double_t GetMaxAngle() const { return fMaxAngle; }
0155 Int_t GetMaxFunctions() const { return fMaxFunctions; }
0156 std::vector<Int_t> GetMaxPowers() const { return fMaxPowers; }
0157 Double_t GetMaxQuantity() const { return fMaxQuantity; }
0158 Int_t GetMaxStudy() const { return fMaxStudy; }
0159 Int_t GetMaxTerms() const { return fMaxTerms; }
0160 const TVectorD *GetMaxVariables() const { return &fMaxVariables; }
0161 Double_t GetMeanQuantity() const { return fMeanQuantity; }
0162 const TVectorD *GetMeanVariables() const { return &fMeanVariables; }
0163 Double_t GetMinAngle() const { return fMinAngle; }
0164 Double_t GetMinQuantity() const { return fMinQuantity; }
0165 Double_t GetMinRelativeError() const { return fMinRelativeError; }
0166 const TVectorD *GetMinVariables() const { return &fMinVariables; }
0167 Int_t GetNVariables() const { return fNVariables; }
0168 Int_t GetNCoefficients() const { return fNCoefficients; }
0169 Int_t GetPolyType() const { return fPolyType; }
0170 std::vector<Int_t> GetPowerIndex() const { return fPowerIndex; }
0171 Double_t GetPowerLimit() const { return fPowerLimit; }
0172 std::vector<Int_t> GetPowers() const { return fPowers; }
0173 Double_t GetPrecision() const { return fPrecision; }
0174 const TVectorD *GetQuantity() const { return &fQuantity; }
0175 Double_t GetResidualMax() const { return fMaxResidual; }
0176 Double_t GetResidualMin() const { return fMinResidual; }
0177 Int_t GetResidualMaxRow() const { return fMaxResidualRow; }
0178 Int_t GetResidualMinRow() const { return fMinResidualRow; }
0179 Double_t GetResidualSumSq() const { return fSumSqResidual; }
0180 Double_t GetRMS() const { return fRMS; }
0181 Int_t GetSampleSize() const { return fSampleSize; }
0182 const TVectorD *GetSqError() const { return &fSqError; }
0183 Double_t GetSumSqAvgQuantity() const { return fSumSqAvgQuantity; }
0184 Double_t GetSumSqQuantity() const { return fSumSqQuantity; }
0185 Double_t GetTestError() const { return fTestError; }
0186 Double_t GetTestPrecision() const { return fTestPrecision; }
0187 const TVectorD *GetTestQuantity() const { return &fTestQuantity; }
0188 Int_t GetTestSampleSize() const { return fTestSampleSize; }
0189 const TVectorD *GetTestSqError() const { return &fTestSqError; }
0190 const TVectorD *GetTestVariables() const { return &fTestVariables; }
0191 const TVectorD *GetVariables() const { return &fVariables; }
0192
0193
0194 Bool_t IsFolder() const override { return kTRUE; }
0195 virtual Double_t MakeChi2(const Double_t *coeff = nullptr);
0196 virtual void MakeCode(const char *functionName = "MDF", Option_t *option = "");
0197 virtual void MakeHistograms(Option_t *option = "A");
0198 virtual void MakeMethod(const Char_t *className = "MDF", Option_t *option = "");
0199 void Print(Option_t *option = "ps") const override;
0200 virtual void PrintPolynomialsSpecial(Option_t *option = "m") const;
0201
0202 void SetMaxAngle(Double_t angle = 0);
0203 void SetMaxFunctions(Int_t n) { fMaxFunctions = n; }
0204 void SetMaxPowers(const Int_t *powers);
0205 void SetMaxStudy(Int_t n) { fMaxStudy = n; }
0206 void SetMaxTerms(Int_t terms) { fMaxTerms = terms; }
0207 void SetMinRelativeError(Double_t error);
0208 void SetMinAngle(Double_t angle = 1);
0209 void SetPowerLimit(Double_t limit = 1e-3);
0210 virtual void SetPowers(const Int_t *powers, Int_t terms);
0211
0212 void ReducePolynomial(double error);
0213 void ZeroDoubiousCoefficients(double error);
0214
0215 ClassDefOverride(TMultiDimFet, 1)
0216 };
0217 #endif