12 const char* dbname =
"mysql://host.domain/test";
13 const char* username =
"user";
14 const char* userpass =
"pass";
30 delete gROOT->GetListOfFiles()->FindObject(
"hsimple.root");
31 delete gROOT->GetListOfCanvases()->FindObject(
"c1");
33 gBenchmark->Start(
"ntuple1");
37 TFile *f1 =
new TFile(
"hsimple.root");
41 TCanvas *c1 =
new TCanvas(
"c1",
"The Ntuple canvas",200,10,700,780);
42 TPad *pad1 =
new TPad(
"pad1",
"This is pad1",0.02,0.52,0.48,0.98,21);
43 TPad *pad2 =
new TPad(
"pad2",
"This is pad2",0.52,0.52,0.98,0.98,21);
44 TPad *pad3 =
new TPad(
"pad3",
"This is pad3",0.02,0.02,0.48,0.48,21);
45 TPad *pad4 =
new TPad(
"pad4",
"This is pad4",0.52,0.02,0.98,0.48,1);
52 gStyle->SetStatW(0.30);
53 gStyle->SetStatH(0.20);
54 gStyle->SetStatColor(42);
61 pad1->GetFrame()->SetFillColor(15);
62 TNtuple *ntuple = (TNtuple*)f1->Get(
"ntuple");
63 ntuple->SetLineColor(1);
64 ntuple->SetFillStyle(1001);
65 ntuple->SetFillColor(45);
66 ntuple->Draw(
"3*px+2",
"px**2+py**2>1");
67 ntuple->SetFillColor(38);
68 ntuple->Draw(
"2*px+2",
"pz>2",
"same");
69 ntuple->SetFillColor(5);
70 ntuple->Draw(
"1.3*px+2",
"(px^2+py^2>4) && py>0",
"same");
78 pad2->GetFrame()->SetFillColor(32);
79 ntuple->Draw(
"pz:px>>hprofs",
"",
"goffprofs");
80 TProfile *hprofs = (TProfile*)gDirectory->Get(
"hprofs");
81 hprofs->SetMarkerColor(5);
82 hprofs->SetMarkerSize(0.7);
83 hprofs->SetMarkerStyle(21);
86 TF1 *fpol2 = hprofs->GetFunction(
"pol2");
87 fpol2->SetLineWidth(4);
88 fpol2->SetLineColor(2);
93 pad3->GetFrame()->SetFillColor(38);
94 pad3->GetFrame()->SetBorderSize(8);
95 ntuple->SetMarkerColor(1);
96 ntuple->Draw(
"py:px",
"pz>1");
97 ntuple->SetMarkerColor(2);
98 ntuple->Draw(
"py:px",
"pz<1",
"same");
102 ntuple->Draw(
"pz:py:px",
"(pz<10 && pz>6)+(pz<4 && pz>3)");
103 ntuple->SetMarkerColor(4);
104 ntuple->Draw(
"pz:py:px",
"pz<6 && pz>4",
"same");
105 ntuple->SetMarkerColor(5);
106 ntuple->Draw(
"pz:py:px",
"pz<4 && pz>3",
"same");
107 TPaveText *l4 =
new TPaveText(-0.9,0.5,0.9,0.95);
108 l4->SetFillColor(42);
109 l4->SetTextAlign(12);
110 l4->AddText(
"You can interactively rotate this view in 2 ways:");
111 l4->AddText(
" - With the RotateCube in clicking in this pad");
112 l4->AddText(
" - Selecting View with x3d in the View menu");
117 gStyle->SetStatColor(19);
118 gBenchmark->Show(
"ntuple1");
120 TSQLFile* fsql1 =
new TSQLFile(dbname,
"recreate", username, userpass);
121 if (fsql1->IsZombie()) {
delete fsql1;
return; }
136 gBenchmark->Start(
"writeSQL");
138 gBenchmark->Show(
"writeSQL");
144 TFile* f2 =
new TSQLFile(dbname,
"open", username, userpass);
145 if (f2->IsZombie()) {
delete f2;
return; }
148 gBenchmark->Start(
"readSQL");
149 TCanvas* cc = (TCanvas*) f2->Get(
"Canvas");
150 gBenchmark->Show(
"readSQL");
151 if (cc!=0) cc->Draw();