Draw TBranch distributions from TTree


ROOT Version: 6.18/04
Platform: Ubuntu 18.04
Compiler: gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)


Dear co-rooters,

Assume the following structure in a root file that contains one TTree.

root [1] tree->Print()

******************************************************************************
*Tree    :tree     : A test TTree                                *
*Entries : 42133355 : Total =      2704131861 bytes  File  Size = 1351930491 *
*        :          : Tree compression factor =   2.00                       *
******************************************************************************
*Br    1 :detn : Detector number/I                                    *
*Entries : 42133355 : Total  Size=  337984481 bytes  File Size  =  168950540 *
*Baskets :     5280 : Basket Size=      32000 bytes  Compression=   2.00     *
*............................................................................*
*Br    3 :area_fast : Area for the fast component/s                   *
*Entries : 42133355 : Total  Size=  169021752 bytes  File Size  =   84488554 *
*Baskets :     2641 : Basket Size=      32000 bytes  Compression=   2.00     *
*............................................................................*

What I would like to do is draw the 2D distribution area_fast for detn==2 VS area_fast for detn==3. I know that I can use the following syntax to draw distributions directly from a TTree

tree->Draw("area_fast", "detn==2", "histo")

or for a 2D distribution

tree->Draw("TBranch_1:TBranch_2", "TBranch_3 == x", "colz")

but how can I draw what I asked? The following command makes no sense apparently, but I’m stuck.

tree->Draw("area_fast:area_fast", "detn== 2 && detn==3", "colz").

I’m afraid that what I’m asking is not doable, that’s why I though of asking!

Thanks in advance!

Hi,
to plot a 2D distribution you would need, for each event, an x value and a y value. But for each event you have either detn==2, detn==3 or maybe neither.

Given an event, with given detn and area_fast values, what two values do you want to fill a 2D histogram with exactly?

Cheers,
Enrico

Hey Enrico,

You are right. For each event I do have either detn==2 or detn==3. Assume the first 10 entries

************************************
*    Row   * detn      * area_fast *
************************************
*        0 *         3 *      2147 *
*        1 *         3 *       945 *
*        2 *         3 *      3782 *
*        3 *         2 *       920 *
*        4 *         2 *      2099 *
*        5 *         3 *       698 *
*        6 *         2 *       531 *
*        7 *         2 *       593 *
*        8 *         2 *       603 *
*        9 *         2 *      1018 *

What I’m trying to see is how the area_fast is different for each detn. So the x-axis will be area_fast for detn==2 and the y-axis will be area_fast for detn==3 and in this way I will be able to see their correlation/coincidence or anything.

I’m afraid that it’s not technically possible… :confused:

Uhm I am afraid that does not make a lot of sense (to me, at least). To check the correlation between two variables, for each x value there must be a corresponding y value. In this case, given an x value (e.g. 920) there is no corresponding y value (which of the area_fast values with detn==3 would it be?), and vice versa.

With the way the data is stored, the best is likely to draw 2 histograms:

tree->Draw("area_fast", "detn==2", "");
tree->Draw("area_fast", "detn==3", "", "SAME");

Cheers,
Philippe.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.