Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:12:58

0001 // @(#)root/hist:$Id$
0002 // Author: Victor Perevoztchikov <perev@bnl.gov>  21/02/2001
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TH1K
0013 #define ROOT_TH1K
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TH1K                                                                 //
0019 //                                                                      //
0020 // 1-Dim histogram nearest K Neighbour class.                           //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TH1.h"
0025 
0026 class TH1K : public TH1, public TArrayF {
0027 
0028 private:
0029    void Sort();
0030 protected:
0031    Int_t fReady = 0;  //!
0032    Int_t fNIn = 0;
0033    Int_t fKOrd = 3;   //!
0034    Int_t fKCur = 0;   //!
0035 
0036    Double_t RetrieveBinContent(Int_t bin) const override { return GetBinContent(bin); }
0037    void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Float_t (content); }
0038 
0039 public:
0040    TH1K();
0041    TH1K(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup,Int_t k=0);
0042 
0043    /// Increment bin content by 1.
0044    /// Passing an out-of-range bin leads to undefined behavior
0045    void     AddBinContent(Int_t bin) override {++fArray[bin];}
0046    /// Increment bin content by a weight w.
0047    /// \warning The value of w is cast to `Float_t` before being added.
0048    /// Passing an out-of-range bin leads to undefined behavior
0049    void     AddBinContent(Int_t bin, Double_t w) override
0050                           { fArray[bin] += Float_t (w); }
0051 
0052    void      Copy(TObject &obj) const override;
0053    Int_t     Fill(Double_t x) override;
0054    Int_t     Fill(Double_t x,Double_t w) override{return TH1::Fill(x,w);}
0055    Int_t     Fill(const char *name,Double_t w) override{return TH1::Fill(name,w);}
0056    Double_t  GetBinContent(Int_t bin) const override;
0057    Double_t  GetBinContent(Int_t bin,Int_t) const override {return GetBinContent(bin);}
0058    Double_t  GetBinContent(Int_t bin,Int_t,Int_t) const override {return GetBinContent(bin);}
0059 
0060    Double_t  GetBinError(Int_t bin) const override;
0061    Double_t  GetBinError(Int_t bin,Int_t) const override {return GetBinError(bin);}
0062    Double_t  GetBinError(Int_t bin,Int_t,Int_t) const override {return GetBinError(bin);}
0063 
0064 
0065    void      Reset(Option_t *option="") override;
0066    void      SavePrimitive(std::ostream &out, Option_t *option = "") override;
0067 
0068    void    SetKOrd(Int_t k){fKOrd=k;}
0069 
0070    ClassDefOverride(TH1K,2)  //1-Dim Nearest Kth neighbour method
0071 };
0072 
0073 #endif