TTree::Draw and selection


ROOT Version: 6.14.00
Platform: Ubuntu18
Compiler: Not Provided


Hello,

I’m trying to use the TTree Class for making a selection; I have an ascii file that has six columns, i’m trying to plot the third column as a function of the first just if i have something different from zero in fourth and sixth columns. I intend to do this for each row in the file.

TTree_test.C (572 Bytes)

When I run de code I get an empty Canvas, literally displays “Empty”
What is the error?
Thnks

T->Draw("a3:a1", "a4 != 0 && a6 != 0");

I still get this:

This probably means that your condition was not met for any entry.
Try: T->Scan("a1:a3:a4:a6");

Your macro access a txt file. Can you post it ?

I’m having problems uploading the file, It’s too heavy, but essentialy my text file is something like this:

1 1 0 0 0 0
2 2 0 1 0 1
3 3 1 1 1 1
4 4 0 1 0 0
. .
. .
. .
1800000 1800000 2 1 0 1

the first two columns are time counters, and the last four are channels, so i intend to make a graph of the third as function of the first only when columns fourth and sixth are different from zero, like a coincidence selection criteria…

Ok. So we cannot run your example. As @Wile_E_Coyote said, your election criteria are such that they probably exclude all the events in the tree. To make sure your tree is fine you may try to draw some variables without any selection… But I am sure you already tried that ?

That’s right, i tried and the canvas displays something different from empty, it seems that your conclusion it’s correct.
Thank you.

Looking at the example lines, I can clearly see three cases which pass your selection so, the plot should not be empty:

2 2 0 1 0 1
3 3 1 1 1 1
1800000 1800000 2 1 0 1

And it is not:

void TTree_test()

{
   TTree *T = new TTree("ntuple","data from ascii file");
   Long64_t nlines = T->ReadFile("TTree_test.txt","a1/I:a2/I:a3/I:a4/I:a5/I:a6/I");

   T->Draw("a3"," a4 && a6 && a3");
   T->Scan("a1:a2:a3:a4:a5:a6");
}
root [0] 
Processing TTree_test.C...
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
************************************************************************************
*    Row   *        a1 *        a2 *        a3 *        a4 *        a5 *        a6 *
************************************************************************************
*        0 *         2 *         2 *         0 *         1 *         0 *         1 *
*        1 *         3 *         3 *         1 *         1 *         1 *         1 *
*        2 *   1800000 *   1800000 *         2 *         1 *         0 *         1 *
************************************************************************************
root [1] 

The values in the columns i wrote before were example values, just to show the structure of my txt file.

Thnks

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