Mouse Driven ROOT

The first exercise shows how much you can do with almost no typing.

Run ROOT:-
root
and you should get the ROOT prompt (root [0] - the number increments each time you
type in a new command).

Type:-
TFile* f = new TFile("$MINOS_TUTORIAL_DATA/F00018143_0000.sntp.root");
which creates a new TFile from the specified file and returns a pointer to it
in the variable f. Don't worry about all the warnings of the type:-

Warning in : no dictionary for class ... is available

they just mean that although ROOT knows about the data for the classes it doesn't
have the code for them. We could fix this with commands like:-

gSystem->Load(libCandTrackSR.so);

to add our code to ROOT but we won't do this now just to show how
much we can do simply with ROOT.

Now create a TBrowser by typing:-
TBrowser b;
A ROOT Object Browser window should open.

In the left hand pane click on the ROOT Files icon, and this should
show a right hand pane with a single object - the TFile we have just
created. If it's not obvious that it is a TFile right click and
context menu opens, the top line of which will tell you the type of
any object.

Double click on this TFile and now you should see an NtpSR TTree and that
can be double clicked to get to a single TBranchElelement called
NtpSRrecord. Keep double clicking until you get to a TBranchElement
that is shown as a leaf. You have reached the data.

If you double click on any leaf a histogram of it gets displayed.

On either axis you can

Zoom by moving mouse over axis (pointer turns to hand), left
click and drag to select the zoom area. To unzoom right click axis
(the context menu TAxis should appear) and select UnZoom.

Switch between log and linear scales by right clicking outside the
histogram (the context menu TCanvas or TPad should appear) and select the scale
you require.

For more sophisticated manipulation of n-tuples right click on
the TTree NtpSR icon and the context menu TTree appears. Select StartViewer
and a TreeViewer window opens.

The right hand pane has two columns. The right hand column lists
the members of the ntuple which can be dragged onto icons in the left
hand column.

Drag evthdr.ndigit onto X: and evthdr.ph.raw onto Y: and then
press the button in the bottom left hand corner that has a graph icon.
A plot of the number of hits versus the total raw pulse height is produced.
and at the same time, on the ROOT terminal window a line similar to:-

tv__tree->Draw("evthdr.ph.raw:evthdr.ndigit","","", 21, 0);

which shows you how you could have done the same thing as a command.

To plot a function of the member variables right click one of the
E() icons and select Edit Expression. An Expression editor opens
which allows you to fill in an expression and also an alias (used as
the axis title). For example you could set:

Expression evthdr.ph.raw
Alias Raw charge squared

Click Done to update the expression. This can now be double clicked
to produce a 1-d plot or dragged onto the X: Y: or Z: to start
assembling a 2- or 3-d plot.

The scissors icon represents a weight. Like X: Y: and Z: an expression
or member variable can be dragged onto it. Now, when plotting, a weight
is assigned according to this expression. Logical expressions are
supported e.g.:-

evthdr.ph.raw > 20

and then the weight reduces to a simple 0 or 1 value and acts as cut.

You can embellish histograms by going to their window, clicking on the Edit
menu and then selecting Editor. This produces a separate window
that has a menu of objects that you can click on to select and then
left click on the histogram window to insert.

To exit from ROOT type:-
.q

Macro Driven ROOT

The above demonstration gives a taste for the type of thing
you can do just with the mouse, but there is a limit
to what you can do, and then its time
to write a ROOT macro. In fact there is one
already written. Take a look at
analysing_data_with_root.C

Run ROOT and the type:-

.x $MINOS_TUTORIAL_MACROS/analysing_data_with_root.C
and then look at the macro and try to understand how it works.
Note to Maintainers: When making changes please follow the maintenance rules