14 auto Canvas2 = (
TCanvas *)
gROOT->GetListOfCanvases()->FindObject(
"Canvas2");
16 auto histo = (
TH1F *)Canvas2->FindObject(
"histo");
24 Int_t hbin = histo->FindBin(p);
27 auto bh = (
TBox *)Canvas2->FindObject(
"TBox");
31 bh->SetFillStyle(3001);
36 bh->SetX1(histo->GetBinLowEdge(hbin));
37 bh->SetY1(histo->GetMinimum());
38 bh->SetX2(histo->GetBinWidth(hbin) + histo->GetBinLowEdge(hbin));
39 bh->SetY2(histo->GetBinContent(hbin));
41 auto th = (
TText *)Canvas2->FindObject(
"TText");
45 th->SetTextColor(bh->GetFillColor());
49 th->SetText(histo->GetXaxis()->GetXmax()*0.75, histo->GetMaximum()*0.5,
68void gr302_highlight2()
70 auto dir =
gROOT->GetTutorialDir();
71 dir.Append(
"/hsimple.C");
72 dir.ReplaceAll(
"/./",
"/");
74 auto file = (
TFile*)
gROOT->ProcessLineFast(
"hsimple(1)");
77 file->GetObject(
"ntuple", ntuple);
80 TCanvas *Canvas1 =
new TCanvas(
"Canvas1",
"Canvas1", 0, 0, 500, 500);
81 Canvas1->
HighlightConnect(
"HighlightBinId(TVirtualPad*,TObject*,Int_t,Int_t)");
83 const char *cut =
"pz > 3.0";
84 ntuple->Draw(
"px:py", cut);
87 auto info =
new TText(0.0, 4.5,
"please move the mouse over the graph");
88 info->SetTextAlign(22);
89 info->SetTextSize(0.03);
90 info->SetTextColor(
kRed+1);
96 auto Canvas2 =
new TCanvas(
"Canvas2",
"Canvas2", 505, 0, 600, 400);
97 ntuple->Draw(
"TMath::Sqrt(px*px + py*py + pz*pz)>>histo(100, 0, 15)", cut);
100 ntuple->Draw(
"px:py:pz:i", cut,
"goff");
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
virtual void SetHighlight(Bool_t set=kTRUE)
1-D histogram with a float per channel (see TH1 documentation)
A simple TTree restricted to a list of float variables only.
Mother of all ROOT objects.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Double_t Sqrt(Double_t x)
Returns the square root of x.