File indexing completed on 2025-01-18 10:12:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TStatistic
0013 #define ROOT_TStatistic
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "TObject.h"
0026
0027 #include "TMath.h"
0028
0029 #include "TString.h"
0030
0031 class TCollection;
0032
0033 class TStatistic : public TObject {
0034
0035 private:
0036 TString fName;
0037 Long64_t fN;
0038 Double_t fW;
0039 Double_t fW2;
0040 Double_t fM;
0041 Double_t fM2;
0042 Double_t fMin;
0043 Double_t fMax;
0044
0045 public:
0046
0047 TStatistic(const char *name = "") : fName(name), fN(0), fW(0.), fW2(0.), fM(0.), fM2(0.), fMin(TMath::Limits<Double_t>::Max()), fMax(-TMath::Limits<Double_t>::Max()) { }
0048 TStatistic(const char *name, Int_t n, const Double_t *val, const Double_t *w = nullptr);
0049 ~TStatistic() override;
0050
0051
0052 const char *GetName() const override { return fName; }
0053 ULong_t Hash() const override { return fName.Hash(); }
0054
0055 inline Long64_t GetN() const { return fN; }
0056 inline Long64_t GetNeff() const { return fW*fW/fW2; }
0057 inline Double_t GetM2() const { return fM2; }
0058 inline Double_t GetMean() const { return (fW > 0) ? fM/fW : 0; }
0059 inline Double_t GetMeanErr() const { return (fW > 0.) ? TMath::Sqrt( GetVar()/ GetNeff() ) : 0; }
0060 inline Double_t GetRMS() const { double var = GetVar(); return (var>0) ? TMath::Sqrt(var) : -1; }
0061 inline Double_t GetVar() const { return (fW>0) ? ( (fN>1) ? (fM2 / fW)*(fN / (fN-1.)) : 0 ) : -1; }
0062 inline Double_t GetW() const { return fW; }
0063 inline Double_t GetW2() const { return fW2; }
0064 inline Double_t GetMin() const { return fMin; }
0065 inline Double_t GetMax() const { return fMax; }
0066
0067
0068 Int_t Merge(TCollection *in);
0069
0070
0071 void Fill(Double_t val, Double_t w = 1.);
0072
0073
0074 void Print(Option_t * = "") const override;
0075 void ls(Option_t *opt = "") const override { Print(opt); }
0076
0077 ClassDefOverride(TStatistic,3)
0078 };
0079
0080 #endif