Logo ROOT  
Reference Guide
th2polyHoneycomb.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook -js
4/// This tutorial illustrates how to create an histogram with hexagonal
5/// bins (TH2Poly). The method TH2Poly::Honeycomb allows to build automatically
6/// an honeycomb binning.
7///
8/// \macro_code
9/// \macro_image
10///
11/// \author Olivier Couet
12
13void th2polyHoneycomb(){
14 TH2Poly *hc = new TH2Poly();
15 hc->SetTitle("Honeycomb example");
16 hc->Honeycomb(0,0,.1,25,25);
17
18 TRandom ran;
19 for (int i = 0; i<30000; i++) {
20 hc->Fill(ran.Gaus(2.,1), ran.Gaus(2.,1));
21 }
22
23 hc->Draw("colz");
24}
void SetTitle(const char *title) override
See GetStatOverflows for more information.
Definition: TH1.cxx:6708
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition: TH1.cxx:3070
2D Histogram with Polygonal Bins
Definition: TH2Poly.h:66
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s)
Bins the histogram using a honeycomb structure.
Definition: TH2Poly.cxx:938
Int_t Fill(Double_t x, Double_t y) override
Increment the bin containing (x,y) by 1.
Definition: TH2Poly.cxx:589
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:274