ROOT   Reference Guide
hksimple.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook
4/// Illustrates the advantages of a TH1K histogram
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Victor Perevovchikov
10
12{
17 if (!tl) return;
18 TListIter next(tl);
19 TObject *to;
20 while ((to=next())) {
22 if (flag) return;
24}
25
26void hksimple()
27{
28// Create a new canvas.
29 TCanvas* c1 = new TCanvas("c1","Dynamic Filling Example",200,10,600,900);
30
31// Create a normal histogram and two TH1K histograms
32 TH1 *hpx[3];
33 hpx[0] = new TH1F("hp0","Normal histogram",1000,-4,4);
34 hpx[1] = new TH1K("hk1","Nearest Neighbour of order 3",1000,-4,4);
35 hpx[2] = new TH1K("hk2","Nearest Neighbour of order 16",1000,-4,4,16);
36 c1->Divide(1,3);
37 Int_t j;
38 for (j=0;j<3;j++) {
39 c1->cd(j+1);
40 hpx[j]->SetFillColor(48);
41 hpx[j]->Draw();
42 }
43
44// Fill histograms randomly
45 gRandom->SetSeed(12345);
46 Float_t px, py, pz;
47 const Int_t kUPDATE = 10;
48 for (Int_t i = 0; i <= 300; i++) {
49 gRandom->Rannor(px,py);
50 for (j=0;j<3;j++) {hpx[j]->Fill(px);}
51 if (i && (i%kUPDATE) == 0) {
53 }
54 }
55
56 for (j=0;j<3;j++) hpx[j]->Fit("gaus");
58}
void Class()
Definition: Class.C:29
int Int_t
Definition: RtypesCore.h:45
float Float_t
Definition: RtypesCore.h:57
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
The Canvas class.
Definition: TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
TH1K class supports the nearest K Neighbours method, widely used in cluster analysis.
Definition: TH1K.h:27
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3350
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:3073
Definition: TList.h:200
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
The most important graphics class in the ROOT system.
TList * GetListOfPrimitives() const override
void Update() override
void Modified(Bool_t flag=1) override