jets.C: script illustrating the use of a Tree using the JetEvent class. | Trees I/O, Queries, Graphics | parallelcoord.C: script illustrating the use of the TParalleCoord class |
#include "TCanvas.h" #include "TFile.h" #include "TNtuple.h" #include "TProfile.h" #include "TBenchmark.h" #include "TStyle.h" #include "TPaveText.h" #include "TFrame.h" #include "TF1.h" void ntuple1() { //Small tree analysis script // To see the output of this macro, click begin_html <a href="gif/ntuple1.gif">here</a> end_html //Author:: Rene Brun //just in case this script is executed multiple times delete gROOT->GetListOfFiles()->FindObject("hsimple.root"); delete gROOT->GetListOfCanvases()->FindObject("c1"); gBenchmark->Start("ntuple1"); // // Connect ROOT histogram/ntuple demonstration file // generated by example $ROOTSYS/tutorials/hsimple.C. TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); dir.ReplaceAll("ntuple1.C","../hsimple.C"); dir.ReplaceAll("/./","/"); if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data()); TFile *f1 = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); if (!f1) return; // // Create a canvas, with 4 pads // TCanvas *c1 = new TCanvas("c1","The Ntuple canvas",200,10,700,780); 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); pad1->Draw(); pad2->Draw(); pad3->Draw(); pad4->Draw(); // // Change default style for the statistics box gStyle->SetStatW(0.30); gStyle->SetStatH(0.20); gStyle->SetStatColor(42); // // Display a function of one ntuple column imposing a condition // on another column. pad1->cd(); pad1->SetGrid(); pad1->SetLogy(); pad1->GetFrame()->SetFillColor(15); TNtuple *ntuple = (TNtuple*)f1->Get("ntuple"); 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"); pad1->RedrawAxis(); // // Display the profile of two columns // The profile histogram produced is saved in the current directory with // the name hprofs pad2->cd(); pad2->SetGrid(); pad2->GetFrame()->SetFillColor(32); ntuple->Draw("pz:px>>hprofs","","goffprofs"); TProfile *hprofs = (TProfile*)gDirectory->Get("hprofs"); hprofs->SetMarkerColor(5); hprofs->SetMarkerSize(0.7); hprofs->SetMarkerStyle(21); hprofs->Fit("pol2"); // Get pointer to fitted function and modify its attributes TF1 *fpol2 = hprofs->GetFunction("pol2"); fpol2->SetLineWidth(4); fpol2->SetLineColor(2); // // Display a scatter plot of two columns with a selection. // Superimpose the result of another cut with a different marker color pad3->cd(); pad3->GetFrame()->SetFillColor(38); pad3->GetFrame()->SetBorderSize(8); ntuple->SetMarkerColor(1); ntuple->Draw("py:px","pz>1"); ntuple->SetMarkerColor(2); ntuple->Draw("py:px","pz<1","same"); // // Display a 3-D scatter plot of 3 columns. Superimpose a different selection. pad4->cd(); 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"); TPaveText *l4 = new TPaveText(-0.9,0.5,0.9,0.95); l4->SetFillColor(42); l4->SetTextAlign(12); 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"); l4->Draw(); // c1->cd(); c1->Update(); gStyle->SetStatColor(19); gBenchmark->Show("ntuple1"); } ntuple1.C:1 ntuple1.C:2 ntuple1.C:3 ntuple1.C:4 ntuple1.C:5 ntuple1.C:6 ntuple1.C:7 ntuple1.C:8 ntuple1.C:9 ntuple1.C:10 ntuple1.C:11 ntuple1.C:12 ntuple1.C:13 ntuple1.C:14 ntuple1.C:15 ntuple1.C:16 ntuple1.C:17 ntuple1.C:18 ntuple1.C:19 ntuple1.C:20 ntuple1.C:21 ntuple1.C:22 ntuple1.C:23 ntuple1.C:24 ntuple1.C:25 ntuple1.C:26 ntuple1.C:27 ntuple1.C:28 ntuple1.C:29 ntuple1.C:30 ntuple1.C:31 ntuple1.C:32 ntuple1.C:33 ntuple1.C:34 ntuple1.C:35 ntuple1.C:36 ntuple1.C:37 ntuple1.C:38 ntuple1.C:39 ntuple1.C:40 ntuple1.C:41 ntuple1.C:42 ntuple1.C:43 ntuple1.C:44 ntuple1.C:45 ntuple1.C:46 ntuple1.C:47 ntuple1.C:48 ntuple1.C:49 ntuple1.C:50 ntuple1.C:51 ntuple1.C:52 ntuple1.C:53 ntuple1.C:54 ntuple1.C:55 ntuple1.C:56 ntuple1.C:57 ntuple1.C:58 ntuple1.C:59 ntuple1.C:60 ntuple1.C:61 ntuple1.C:62 ntuple1.C:63 ntuple1.C:64 ntuple1.C:65 ntuple1.C:66 ntuple1.C:67 ntuple1.C:68 ntuple1.C:69 ntuple1.C:70 ntuple1.C:71 ntuple1.C:72 ntuple1.C:73 ntuple1.C:74 ntuple1.C:75 ntuple1.C:76 ntuple1.C:77 ntuple1.C:78 ntuple1.C:79 ntuple1.C:80 ntuple1.C:81 ntuple1.C:82 ntuple1.C:83 ntuple1.C:84 ntuple1.C:85 ntuple1.C:86 ntuple1.C:87 ntuple1.C:88 ntuple1.C:89 ntuple1.C:90 ntuple1.C:91 ntuple1.C:92 ntuple1.C:93 ntuple1.C:94 ntuple1.C:95 ntuple1.C:96 ntuple1.C:97 ntuple1.C:98 ntuple1.C:99 ntuple1.C:100 ntuple1.C:101 ntuple1.C:102 ntuple1.C:103 ntuple1.C:104 ntuple1.C:105 ntuple1.C:106 ntuple1.C:107 ntuple1.C:108 ntuple1.C:109 ntuple1.C:110 ntuple1.C:111 ntuple1.C:112 |
|