Logo ROOT  
Reference Guide
No Matches
h2_cut.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 h2_cut()
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]");
float Float_t
Definition RtypesCore.h:57
R__EXTERN TRandom * 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
Draw this graph with its current attributes.
Definition TGraph.cxx:809
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3047
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:258
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:347
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
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Sergey Linev

Definition in file h2_cut.C.