This tutorial demonstrates how the highlight mechanism can be used on a ntuple.
TList *list1 =
nullptr, *list2 =
nullptr;
{
for (
Int_t bin = 0; bin < nbins; bin++) {
}
auto g =
dynamic_cast<TGraph *
>(list->At(bin));
}
return list;
}
{
auto histo =
dynamic_cast<TH1F *
>(obj);
if(!histo) return;
if (!Canvas2) return;
if (!gcommon) return;
if (!strcmp(histo->
GetName(),
"histo1"))
list = list1;
else if (!strcmp(histo->
GetName(),
"histo2"))
list = list2;
if (!list) return;
if (savepad) savepad->
cd();
}
void hlHisto3()
{
auto dir =
gROOT->GetTutorialDir();
dir.Append("/hsimple.C");
dir.ReplaceAll("/./","/");
auto file = (
TFile*)
gROOT->ProcessLineFast(
"hsimple(1)");
if (!file) return;
file->GetObject("ntuple", ntuple);
if (!ntuple) return;
const char *cut = "pz > 3.0";
TCanvas *Canvas2 =
new TCanvas(
"Canvas2",
"Canvas2", 705, 0, 500, 500);
ntuple->
Draw(
"pz>>histo1(100, 2.0, 12.0)", cut);
auto histo1 = (
TH1F *)
gPad->FindObject(
"histo1");
auto info1 =
new TText(7.0, histo1->GetMaximum()*0.6,
"please move the mouse over the frame");
info1->SetTextColor(histo1->GetLineColor());
info1->Draw();
ntuple->
Draw(
"(px*py*pz)>>histo2(100, -50.0, 50.0)", cut);
auto histo2 = (
TH1F *)
gPad->FindObject(
"histo2");
histo2->SetLineColor(
kGreen+2);
auto info2 =
new TText(10.0, histo2->GetMaximum()*0.6, info1->GetTitle());
info2->SetTextColor(histo2->GetLineColor());
info2->Draw();
histo1->SetHighlight();
histo2->SetHighlight();
ntuple->
Draw(
"px:py", cut);
auto htemp = (
TH2F *)
gPad->FindObject(
"htemp");
ntuple->
Draw(
"px:py:pz", cut,
"goff");
list1 = InitGraphs(ntuple, histo1, true);
list2 = InitGraphs(ntuple, histo2, false);
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
void Update() override
Update canvas pad buffers.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
TAxis * GetXaxis() const
Get x axis of the graph.
TAxis * GetYaxis() const
Get y axis of the graph.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
void SetTitle(const char *title="") override
Change (i.e.
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)
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
A simple TTree restricted to a list of float variables only.
Mother of all ROOT objects.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
TObject * FindObject(const char *name) const override
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()
void Draw(Option_t *opt) override
Default Draw method for all objects.
virtual Double_t * GetV3()
virtual Double_t * GetV1()
virtual Double_t * GetV2()
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0