Tutorial - Kanga++ Interactive Access to CM2 Data

This tutorial has been updated for release 14.5.1 (analysis-20) and later. The original tutorial is here.

First you need to check out a release >= 14.5.1 and set up the workdir:

prompt> newrel -t 14.5.1 my14.5.1
prompt> cd my14.5.1
prompt> srtpath <ret> <ret>
prompt> addpkg workdir
prompt> gmake workdir.setup
prompt> cd workdir

Make some plans for the evening:

prompt> Drink.pl
Drink in :
======
North Beach

Drink :
======
Long Island
Red Hook
Scotch Whiskey
Guinness
Bloody Mary
Red Hook
Bloody Mary
Newcastle Brown

Then you just run Kanga:

prompt> Kanga
You will see the ROOT logo and startup message.

First you make an object to read the data for you

root[0] KanEventSource* input = KanEventSource::micro();

Then you can start adding collections:

root[1] input->Add("/my/Favorite/Collection/of/BtoPiPiNu/events");
After this command you should get some messages about opening files and adding trees to chains. If you mistyped the name of the collection you will get a message about not being able to find the file and ROOT will abort. This behaviour will be modified to be less harsh sometime soon. If you need a collection to run over, go to this page. If you are too lazy to read that page and find yourself a collection, you can cut and paste this line:
input->Add("/store/PRskims/R14/14.4.2a/BSemiExcl/03/BSemiExcl_0391");

Then you can get access to the various components and browse the data structures. For example to see all the branches that make up the "aod" (aka "micro") component:

root[2] input->getComponent(KanCompMap::aod)->Print();
Which would generate a pretty normal looking printout of the TTree for the "aod" component. The mapping for the various components is Event Header (hdr)=0, User Data (usr)=1, Event Tag (tag)=2, Beta Candidates (cnd)=3, "Micro" (aod)=4, Monte Carlo Truth (tru)=5, "Mini" (esd)=6.

You can get a list of the components that are on in your collection:

root[3] input->listComponents();
hdr usr tag cnd aod

You can do some simple things with your input source. For example:

root[4] (UInt_t)input->nEvt()
(const unsigned int)14522
Note that you must leave off the trailing semicolon for ROOT to print out the return value of a function. Since KanEventSource is a kind of TTree object, you can do any of the functions that you are used to doing with TTree. Of course, some of them might not really make much sense.

You can make some nice plots:

root[5] input->getComponent(KanCompMap::aod)->Draw("Pid_DchPids__n");
root[6] input->getComponent(KanCompMap::aod)->Draw("Pid_DchPids.momentum()");
root[7] input->getComponent(KanCompMap::aod)->Draw("Pid_DchPids.dedx():Pid_DchPids.momentum()");
root[8] input->getComponent(KanCompMap::aod)->Draw("Pid_DchPids.dedx():Pid_DchPids.momentum()","Pid_DchPids.momentum()<3.0");

Or even project data into pre-made histograms:

root[9] TH2F hist("DeDxHist","A hist of DeDx v. P",100,0.,3.,100,0.,5000.);
root[10] input->getComponent(KanCompMap::aod)->Project("DeDxHist","Pid_DchPids.dedx():Pid_DchPids.momentum()");

Eric Charles
Last modified: Thu Jun 17 15:35:30 PDT 2004