FAQ - Kanga Interactive Access
This FAQ has been updated for release 16.0.2 and later. An earlier FAQ is here.
How do I run Kanga interactively?
From any release after 16.0.2 you just type Kanga for workdir
srtpath <ret> <ret>
cd workdir
Kanga
You will see the ROOT splash logo, and they should be left at the ROOT prompt.
How do I open a collection?
Once you started Kanga you simple do:
root[0] KanEventSource* input = KanEventSource::micro();
root[1] input->Add("/my/collection/name");
The first command builds an object which can read collections and behaves just like a TTree.
That is to say, you can call all the same functions for a KanEventSource as you could for TTree.
At this point you will see some messages about opening your collection.
How do I find out how many events are present in a collection?
root[3] input->nEvt()
(const unsigned int)14332
Note that you have to leave off the trailing semicolon otherwise ROOT doesn't print out the return value.
How do I find out what components are present in a collection?
root[4] input->listComponents();
hdr tag cnd aod
So in this case the header (hdr), event tag (tag), Beta Candidate (cnd), and Micro (aod) components are present.
How do I get access to a particular component of my collection?
KanEventSource has some functions to do exactly that. For example:
root[5] input->getHdr()->nEvt()
(const unsigned int)14332
How do I figure out data that are present in a certain component?
You can get a special printout of the structure of each component that tells you the list of branches and the types
of object on each branch by giving the following command:
root[6] input->getHdr()->print();
*******************************************************
KanHeaderTree @ 0. hdr -+- BaBar ROOT tree.
-------------------------------------------------------
hdr__Comps R@ 0:1 W +XXX+
KanClonesVector_I<KanEvtHeaderEntryI>[KanEvtHeaderEntryK]
-------------------------------------------------------
hdr_ R@ 0:2 W +XXX+
KanEvtHeaderK
-------------------------------------------------------
hdr__Eid R@ 0:3 W +XXX+
KanEvtIDK
-------------------------------------------------------
CdbStateId R@ 0:4 W +XXX+
KanClonesVector_I<CdbKanStateIdI>[CdbKanStateIdK]
*******************************************************
The syntax of this printout is:
*******************************************************
<TreeType> @ <TID>. <TreeName> -+- <TreeTitle>
-------------------------------------------------------
<BranchName> R <ReadBranch> W +XXX+
<BranchClassName>
-------------------------------------------------------
...Next Branch...
*******************************************************
<TreeType> is: "KanHeaderTree" (since this is the header component)
<TID> is the Tree ID (ie 0=hdr)
<TreeName> is the component name ("hdr" in this case)
<TreeTitle> is "BaBar ROOT tree"
<BranchName> is the Name of the Branch the data are located on. For example "hdr__Eid" is the branch with the Event ID on it.
<ReadBranch> is "<TID:BID>" Where <TID> is the Tree ID (0=hdr) and <BID> is the branch ID (0,1,2...)
W +XXX+ means that this branch is not configured for output. This is normal since you are reading the tree in, not wrtring it out.
<BranchClassName> is:
"XxxClassK" for single objects
"KanClonesVector_I<XxxClassI>[XxxClassK]" for vectors
XxxClassI is the interface of the objects on the vector and
XxxClassK is the actual persistent type.
Also, this page has a table of all the data available in Kanga collections.
Once I know the component and branch that something is on, how do I plot it?
Well, you don't draw data objects, you draw functions of data objects. For example:
root [7] input->getAod()->Draw("Pid_DchPids");
Warning in : Not implemented for TClonesArray
Because you tried to plot a bunch of DchPidInfo objects.
On the other hand:
root [8] input->getAod()->Draw("Pid_DchPids.dedx()");
Works nicely.
Interestingly enough, you can call/plot any function of the data objects. Specifically:
root [9] input->getAod()->Draw("Pid_DchPids.Print()");
Will give you a plot with lots of entries at zero, but will call "Print()" on every single DchPidInfo object in the
collection. This might be useful for certain tasks.
Can I have more than one input source?
Certainly, every time you call KanEventSource::micro() you get a new input source
root [10] KanEventSource* inputData = KanEventSource::micro();
root [11] KanEventSource* inputMC = KanEventSource::microMC();
root [12] KanEventSource::list();
------------------------------------------------------------
Name # Events Components
------------------------------------------------------------
_micro0 0 hdr usr tag cnd aod
_micro1 0 hdr usr tag cnd aod
_microMC0 14332 hdr usr tag cnd aod tru
Can I use the TBrowser to browse the data?
I have no idea. Probably not.
How can I find out what functions are available for a particular class of data object?
There are several ways, but the two easiest are:
- Look in the html reference.
- Use tab completion from the ROOT prompt by typing (for example) DchPidInfoI::<tab>
How do I plot a Tag bit (or int or float)?
You have to use the "\" to protect the quotes inside the Draw function.
root [11] input->getTag()->Draw("Tag.floatVal(\"eTotal\")");
Can I write macros to do more complicated operations and loops?
Yes. In fact some example macros are being collected here.
I found some bug, what should I do?
It would be nice if Kanga did my analysis for me, can you add a function to do that?
Post stuff like this to the relevent hypernews.
Eric Charles
Last modified: Thu Jun 17 15:35:30 PDT 2004