Trees



Interactive work with the GUI TtreeViewer
If you have a file opened with a tree ntp1,
gSystem->Load("$ROOTSYS/lib/libTreeViewer.so");

TTreeViewer b("ntp1");

How to print the variable names in a tree
ntp1->Print();
ntp1->Print(); >filename.txt // to dump it to a filename (Note the semicolon after parenthesis)

How to scan events in a tree
ntp1->Scan("var1:var2")
Only the first 14 events:
ntp1->Scan("var1:var2", "","", 14 )
Only those satisfying a cut
ntp1->Scan("var1:var2", "var3>123.")

How to draw variable(s) from a tree
ntp1->Draw("var1");
ntp1->Draw("var1:var2"); // two variables against each other
ntp1->Draw("var1*var1 + var2"); // combination of variables
ntp1->Draw("var1*var1 + var2", "var3<0.1&&var4!=0);
// apply a cut
ntp1->Draw("var1:var2", "", "P"); // use current marker instead of histogram style

How to fill a histogram with the variables of a tree
ntp1->Draw("var1>>h1"); // h1 is reset before it is filled
ntp1->Draw("var1>>+h1"); // previous contents of h1 is not deleted

How to make simple selections
ntp1->Draw("var1", "var2!=0 && var3 > 123.");

How to get a skeleton function (class) for a tree (the equivalent of uwfunc):
There are several ways, older and better.

You get a straight-forward function by doing
ntp1->MakeCode();
This will generate ntp1.C and is quite closely the equivalent to what uwfunc generates.

You get a class by invoking

ntp1->MakeClass();
This will generate ntp1.h and ntp1.C which you can modify to your needs.