This is slight modification of ntuple1.C example.
A canvas with sub-pads is produced, stored to an sql data base and read back To run this macro, you need the hsimple.root file, produced by the hsimple.C macro
const char* dbname = "mysql://host.domain/test";
const char* username = "user";
const char* userpass = "pass";
void sqlcanvas()
{
canvas_write();
canvas_read();
}
void canvas_write()
{
delete gROOT->GetListOfFiles()->FindObject(
"hsimple.root");
delete gROOT->GetListOfCanvases()->FindObject(
"c1");
TPad *pad1 =
new TPad(
"pad1",
"This is pad1",0.02,0.52,0.48,0.98,21);
TPad *pad2 =
new TPad(
"pad2",
"This is pad2",0.52,0.52,0.98,0.98,21);
TPad *pad3 =
new TPad(
"pad3",
"This is pad3",0.02,0.02,0.48,0.48,21);
TPad *pad4 =
new TPad(
"pad4",
"This is pad4",0.52,0.02,0.98,0.48,1);
ntuple->SetLineColor(1);
ntuple->SetFillStyle(1001);
ntuple->SetFillColor(45);
ntuple->Draw("3*px+2","px**2+py**2>1");
ntuple->SetFillColor(38);
ntuple->Draw("2*px+2","pz>2","same");
ntuple->SetFillColor(5);
ntuple->Draw("1.3*px+2","(px^2+py^2>4) && py>0","same");
ntuple->Draw("pz:px>>hprofs","","goffprofs");
ntuple->SetMarkerColor(1);
ntuple->Draw("py:px","pz>1");
ntuple->SetMarkerColor(2);
ntuple->Draw("py:px","pz<1","same");
ntuple->Draw("pz:py:px","(pz<10 && pz>6)+(pz<4 && pz>3)");
ntuple->SetMarkerColor(4);
ntuple->Draw("pz:py:px","pz<6 && pz>4","same");
ntuple->SetMarkerColor(5);
ntuple->Draw("pz:py:px","pz<4 && pz>3","same");
l4->
AddText(
"You can interactively rotate this view in 2 ways:");
l4->
AddText(
" - With the RotateCube in clicking in this pad");
l4->
AddText(
" - Selecting View with x3d in the View menu");
if (fsql1->
IsZombie()) {
delete fsql1;
return; }
delete fsql1;
}
void canvas_read()
{
if (f2->
IsZombie()) {
delete f2;
return; }
delete f2;
}
externTBenchmark * gBenchmark
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
void Draw(Option_t *option="") override
Draw a canvas.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
void ls(Option_t *option="") const override
List file contents.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.
A simple TTree restricted to a list of float variables only.
The most important graphics class in the ROOT system.
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
void RedrawAxis(Option_t *option="") override
Redraw the frame axis.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
TFrame * GetFrame() override
Get frame.
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
void Draw(Option_t *option="") override
Draw this pave with its current attributes.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Access an SQL db via the TFile interface.
virtual void SetBorderSize(Short_t bordersize)