# Different plots with the manipulation of variable size array

Hello, is there any reason that I get a different plot when I do

and

?

A and B are attached to the TTree like that

```t->Branch("B",&B,"B/I"); t->Branch("A",A,"A[B]/I");```
Previously A is declared as “int A[24] = { 0 };” where 24 is the maximum value of B.

Currently, I have much less events when I draw my data with the “first” Draw method (t->Draw(“Y:X”,“A[1]==2”,“col”)) compared to the second one (t->Draw(“Y:X”,“A[B]==2 && B==1”,“col”)) (a bit less than 100 times less).
Sorry if it is a stupid question but I do not understand what happen.

To illustrate my purpose, you can get the run that I attached in [url=https://root-forum.cern.ch/t/different-plot-with-exactly-the-same-command/16557/1 post[/url].
If I type

```t->Draw("DE1>>h1","iRing_DE1[ringtouche_DE1]==4 && ringtouche_DE1==1","") t->Draw("DE1>>h2","iRing_DE1[1]==4","")```
I get two different plots

Note that if I type

``t->Draw("DE1>>h3","ringtouche_DE1==1 && iRing_DE1[ringtouche_DE1]==4","")``

I get an empty histo (which is not the case of h1)

According to me and what I know about my data, I think that the good plot (or the least bad) in h1.

As you see, I am a bit confused. Do you have any explanation?

Hi,

You array is defined as

so the valid range is [0,ringtouche_DE1[.

When you use iRing_DE1[1], you get entries whenever ringtouche_DE1>1, while the first command should have returned no values (i.e. it is a bug it returns anything).

I think what you meant may have been:`t->Draw("DE1>>h1","iRing_DE1[ringtouche_DE1-1]==4 && ringtouche_DE1==1","")`or`t->Draw("DE1>>h1","iRing_DE1[ringtouche_DE1-1]==4 && ringtouche_DE1==2","")`

Cheers,
Philippe.

Hi,

So it turned out to be the same problem you encountered in [url=https://root-forum.cern.ch/t/different-plot-with-exactly-the-same-command/16557/1 post[/url]. i.e. some more bound checks in TTree::Draw were missing making it draw random data if the value of the index was exactly the size of the array. This has been fixed in the trunk.

Cheers,
Philippe.

Thank you for the answer. I forgot to close that post. It was indeed the same problem I described in the post you mention.