FAQ - Kanga Interactive Access
How do I run Kanga interactively?
From any release after 14.5.1 you just type Kanga for workdir
srtpath
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 message about opening files and adding trees to chains.
If you got the collection name wrong and the collection doesn't exist, ROOT will abort. This behavior will be improved soon to be more forgiving.
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 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[4] input->getComponent(KanCompMap::hdr)->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.
Once I know the component and branch that something is on, how do I plot it?
Well, you don't draw data object, you draw functions of data objects. For example:
root [7] input->getComponent(KanCompMap::aod)->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->getComponent(KanCompMap::aod)->Draw("Pid_DchPids.dedx()");
Works nicely.
Interestingly enough, you can call/plot any function of the data objects. Specifically:
root [9] input->getComponent(KanCompMap::aod)->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, just make sure to call them by different names, as the event sources are keyed by name.
root [9] KanEventSource* inputData = KanEventSource::micro("Data");
root [10] KanEventSource* inputMC = KanEventSource::micro("MC");
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->getComponent(KanCompMap::tag)->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