Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
h2_cut.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook -js
4/// This example demonstrates how to display a 2D histogram and
5/// use TCutG object to select bins for drawing.
6/// Moving TCutG object one can change displayed region of histogram
7///
8/// \macro_image
9/// \macro_code
10///
11/// \author Sergey Linev
12
13void h2_cut()
14{
15 const int n = 6;
16 Float_t x[6] = { 1, 2, 1, -1, -2, -1 };
17 Float_t y[6] = { 2, 0, -2, -2, 0, 2 };
18 TCutG *cut = new TCutG("cut", 6, x, y);
19 TH2F *hist = new TH2F("hist", "Histogram with cut", 40, -10., 10., 40, -10., 10.);
20 for (int i = 0; i < 100000; i++)
21 hist->Fill(gRandom->Gaus(0., 3.), gRandom->Gaus(0., 3.));
22 TCanvas *c1 = new TCanvas("c1", "Histogram draw with TCutG", 600, 900);
23 hist->Draw("col [cut]");
24 cut->Draw("l");
25}
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:831
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:393
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:275
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