Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TH1K.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Victor Perevoztchikov <perev@bnl.gov> 21/02/2001
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TH1K
13#define ROOT_TH1K
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TH1K //
19// //
20// 1-Dim histogram nearest K Neighbour class. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TH1.h"
25
26class TH1K : public TH1, public TArrayF {
27
28private:
29 void Sort();
30protected:
31 Int_t fReady = 0; //!
33 Int_t fKOrd = 3; //!
34 Int_t fKCur = 0; //!
35
36 Double_t RetrieveBinContent(Int_t bin) const override { return GetBinContent(bin); }
37 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Float_t (content); }
38
39public:
40 TH1K();
41 TH1K(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup,Int_t k=0);
42
43 /// Increment bin content by 1.
44 /// Passing an out-of-range bin leads to undefined behavior
45 void AddBinContent(Int_t bin) override {++fArray[bin];}
46 /// Increment bin content by a weight w.
47 /// \warning The value of w is cast to `Float_t` before being added.
48 /// Passing an out-of-range bin leads to undefined behavior
49 void AddBinContent(Int_t bin, Double_t w) override
50 { fArray[bin] += Float_t (w); }
51
52 void Copy(TObject &obj) const override;
53 Int_t Fill(Double_t x) override;
54 Int_t Fill(Double_t x,Double_t w) override{return TH1::Fill(x,w);}
55 Int_t Fill(const char *name,Double_t w) override{return TH1::Fill(name,w);}
56 Double_t GetBinContent(Int_t bin) const override;
57 Double_t GetBinContent(Int_t bin,Int_t) const override {return GetBinContent(bin);}
58 Double_t GetBinContent(Int_t bin,Int_t,Int_t) const override {return GetBinContent(bin);}
59
60 Double_t GetBinError(Int_t bin) const override;
61 Double_t GetBinError(Int_t bin,Int_t) const override {return GetBinError(bin);}
62 Double_t GetBinError(Int_t bin,Int_t,Int_t) const override {return GetBinError(bin);}
63
64
65 void Reset(Option_t *option="") override;
66 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
67
68 void SetKOrd(Int_t k){fKOrd=k;}
69
70 ClassDefOverride(TH1K,2) //1-Dim Nearest Kth neighbour method
71};
72
73#endif
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
Array of floats (32 bits per element).
Definition TArrayF.h:27
Float_t * fArray
Definition TArrayF.h:30
void Reset()
Definition TArrayF.h:47
TH1K class supports the nearest K Neighbours method, widely used in cluster analysis.
Definition TH1K.h:26
Double_t GetBinContent(Int_t bin, Int_t, Int_t) const override
Definition TH1K.h:58
Double_t GetBinError(Int_t bin) const override
Return content of global bin error.
Definition TH1K.cxx:129
Int_t fReady
Definition TH1K.h:31
Int_t fKOrd
Definition TH1K.h:33
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH1K.h:45
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out Note the following restrictions in the code...
Definition TH1K.cxx:153
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH1K.h:36
Int_t Fill(Double_t x, Double_t w) override
Increment bin with abscissa X with a weight w.
Definition TH1K.h:54
Int_t fKCur
Definition TH1K.h:34
Double_t GetBinError(Int_t bin, Int_t, Int_t) const override
Definition TH1K.h:62
Int_t fNIn
Definition TH1K.h:32
Int_t Fill(const char *name, Double_t w) override
Increment bin with namex with a weight w.
Definition TH1K.h:55
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH1K.h:37
void AddBinContent(Int_t bin, Double_t w) override
Increment bin content by a weight w.
Definition TH1K.h:49
Int_t Fill(Double_t x) override
Increment bin with abscissa X by 1.
Definition TH1K.cxx:78
void Copy(TObject &obj) const override
Copy this histogram structure to newth1.
Definition TH1K.cxx:62
Double_t GetBinError(Int_t bin, Int_t) const override
Definition TH1K.h:61
TH1K()
Constructor.
Definition TH1K.cxx:39
void Sort()
Sort.
Definition TH1K.cxx:216
void SetKOrd(Int_t k)
Definition TH1K.h:68
Double_t GetBinContent(Int_t bin) const override
Return content of global bin number bin.
Definition TH1K.cxx:101
Double_t GetBinContent(Int_t bin, Int_t) const override
Definition TH1K.h:57
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3315
Mother of all ROOT objects.
Definition TObject.h:41
Double_t x[n]
Definition legend1.C:17