Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
hist018_TH2_cutg.C File Reference

Detailed Description

View in nbviewer Open in SWAN
This example demonstrates how to display a 2D histogram and use TCutG object to select bins for drawing.

Moving TCutG object one can change displayed region of histogram

void hist018_TH2_cutg()
{
const int n = 6;
Float_t x[6] = {1, 2, 1, -1, -2, -1};
Float_t y[6] = {2, 0, -2, -2, 0, 2};
TCutG *cut = new TCutG("cut", 6, x, y);
TH2F *hist = new TH2F("hist", "Histogram with cut", 40, -10., 10., 40, -10., 10.);
for (int i = 0; i < 100000; i++)
hist->Fill(gRandom->Gaus(0., 3.), gRandom->Gaus(0., 3.));
TCanvas *c1 = new TCanvas("c1", "Histogram draw with TCutG", 600, 900);
hist->Draw("col [cut]");
cut->Draw("l");
}
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
externTRandom * gRandom
Definition TRandom.h:62
The Canvas class.
Definition TCanvas.h:23
Graphical cut class.
Definition TCutG.h:20
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3097
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:345
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:363
return c1
Definition legend1.C:41
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Date
January 2023
Author
Sergey Linev

Definition in file hist018_TH2_cutg.C.