23 auto dir =
gROOT->GetTutorialDir();
24 dir.Append(
"/hsimple.C");
25 dir.ReplaceAll(
"/./",
"/");
31 file->GetObject(
"ntuple", ntuple);
33 const char *cut =
"pz > 3.0";
35 TCanvas *Canvas1 =
new TCanvas(
"Canvas1",
"Canvas1", 0, 0, 700, 500);
37 TCanvas *Canvas2 =
new TCanvas(
"Canvas2",
"Canvas2", 705, 0, 500, 500);
41 ntuple->
Draw(
"pz>>histo1(100, 2.0, 12.0)", cut);
42 auto histo1 = (
TH1F *)
gPad->FindObject(
"histo1");
43 auto info1 =
new TText(7.0, histo1->GetMaximum()*0.6,
44 "please move the mouse over the frame");
45 info1->SetTextColor(histo1->GetLineColor());
51 ntuple->
Draw(
"(px*py*pz)>>histo2(100, -50.0, 50.0)", cut);
52 auto histo2 = (
TH1F *)
gPad->FindObject(
"histo2");
53 histo2->SetLineColor(
kGreen+2);
54 auto info2 =
new TText(10.0, histo2->GetMaximum()*0.6, info1->GetTitle());
55 info2->SetTextColor(histo2->GetLineColor());
60 histo1->SetHighlight();
61 histo2->SetHighlight();
66 ntuple->
Draw(
"px:py", cut);
67 auto gcommon = (
TGraph *)
gPad->FindObject(
"Graph");
69 auto htemp = (
TH2F *)
gPad->FindObject(
"htemp");
70 gcommon->SetTitle(htemp->GetTitle());
71 gcommon->GetXaxis()->SetTitle(htemp->GetXaxis()->GetTitle());
72 gcommon->GetYaxis()->SetTitle(htemp->GetYaxis()->GetTitle());
76 ntuple->
Draw(
"px:py:pz", cut,
"goff");
77 histo1->SetUniqueID(1);
78 histo2->SetUniqueID(2);
79 InitGraphs(ntuple, histo1);
80 InitGraphs(ntuple, histo2);
91 auto list =
new TList();
99 for (bin = 0; bin < nbins; bin++) {
103 g->SetMarkerStyle(25);
109 for (
Long64_t ie = 0; ie < nev; ie++) {
111 if (histo->
GetUniqueID() == 2) value = px[ie]*py[ie]*pz[ie];
112 bin = histo->
FindBin(value) - 1;
115 g->SetPoint(
g->GetN(), py[ie], px[ie]);
122 auto histo = (
TH1F *)obj;
126 if (!Canvas2)
return;
128 if (!gcommon)
return;
142 if (
g->GetN() > 0)
g->Draw(
"P");
virtual Color_t GetLineColor() const
Return the line color.
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
virtual void Update()
Update canvas pad buffers.
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
1-D histogram with a float per channel (see TH1 documentation)}
virtual Int_t GetNbinsX() const
virtual Bool_t IsHighlight() const
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
2-D histogram with a float per channel (see TH1 documentation)}
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual const char * GetName() const
Returns name of object.
A simple TTree restricted to a list of float variables only.
Mother of all ROOT objects.
virtual UInt_t GetUniqueID() const
Return the unique object id.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
virtual TObject * FindObject(const char *name) const
Search if object named name is inside this pad or in pads inside this pad.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Base class for several text objects.
virtual Long64_t GetSelectedRows()
virtual Double_t * GetV3()
virtual Double_t * GetV1()
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
virtual Double_t * GetV2()
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0