# Bad values from GetV1()

**URL:** <https://root-forum.cern.ch/t/bad-values-from-getv1/40326>\
**Category:** ROOT\
**Created:** [July 9, 2020, 7:02am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326 "2020-07-09T07:02:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [July 9, 2020, 7:02am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326/1 "2020-07-09T07:02:35Z")

</div>

Dear ROOTers,

I wonder why GetV1() stored vector stores different values depending on the number of entries read:

```auto
root [1] tevent->Draw("photon_count_data", "Entry$<=2000", "goff")
(long long) 4610304
root [2] auto v = tevent->GetV1()
(double *) @0x7fff15fd1068
root [3] v[0]
(double) 5.0000000
root [4] tevent->Draw("photon_count_data", "Entry$<=10", "goff")
(long long) 25344
root [5] v[0]
(double) 1.0000000

```

where

```auto
photon_count_data : photon_count_data[1][1][48][48]/F 

```

In general when I draw the array, I can see that the data is not rubbish, but it is somehow shifted. I’ve tried SetEstimate(-1), but it caused even more problems…

* * *

_ROOT Version:_ 6.20.06  
_Platform:_ Fedora 31  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 9, 2020, 7:11am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326/2 "2020-07-09T07:11:07Z")

</div>

Maybe @pcanal has an explanation

---

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [July 9, 2020, 7:37am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326/3 "2020-07-09T07:37:20Z")

</div>

OK, I’ve solved the problem. TTree::SetEstimate(-1) does not work for arrays. For srrays it should be SetEstimate(GetEntries()\*size\_of\_array), kind of logical. It would be nice if you could update SetEstimate(-1), although I am not sure how (-1 meaning the nuber of cells in the biggest array in the tree times the number of entries?), but if it is impossible, perhaps just the docs?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 9, 2020, 10:46am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326/4 "2020-07-09T10:46:23Z")

</div>

Problem description (more than 5 years old):

> [@TTree::Draw GetW, GetV1, GetV2, GetV3, GetV4, GetVal](https://root-forum.cern.ch/t/ttree-draw-getw-getv1-getv2-getv3-getv4-getval/19013):
>
> In the [TTree::Draw](https://root.cern.ch/root/html534/TTree.html#TTree:Draw@2) method description, I find: “The content will be the last GetSelectedRows() % GetEstimate() values calculated.” Shouldn’t it be something like: “The content will be the last min(GetSelectedRows(), GetEstimate()) values calculated.”?

Possible solutions:

> [@The fastest way to read all tree branch data?](https://root-forum.cern.ch/t/the-fastest-way-to-read-all-tree-branch-data/38263/3):
>
> { TFile \*f = TFile::Open("some\_file.root"); TTree \*t; f-\>GetObject("some\_tree", t); t-\>SetEstimate(-1); // keep all results (assumes one result per entry) Long64\_t n = t-\>Draw("some\_leaf", "", "goff"); #if 1 /\* 0 or 1 \*/ if (n \> t-\>GetEstimate()) // just a precaution { t-\>SetEstimate(n); t-\>Draw("some\_leaf", "", "goff"); } #endif /\* 0 or 1 \*/ for (Long64\_t i = 0; i \< n; i++) std::cout \<\< t-\>GetV1()[i] \<\< std::endl; }

> [@How to push data to vector from branch tree](https://root-forum.cern.ch/t/how-to-push-data-to-vector-from-branch-tree/32616/2):
>
> #include "TTree.h" #include "TGraph.h" #include "TString.h" #include "TPad.h" #include "TMath.h" #include \<iostream\> TGraph \*DrawGraph(const char \*xname, const char \*yname, TTree \*tree, const char \*selection = "", const char \*gname = "MyGraph") { TGraph \*g = ((TGraph\*)0); if (!(xname && xname[0] && yname && yname[0] && tree)) return g; if (!selection) selection = ""; if (!(gname && gname[0])) gname = "MyGraph"; tree-\>SetEstimate(-1); // keep all results (assumes one r…

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 23, 2020, 10:46am UTC](https://root-forum.cern.ch/t/bad-values-from-getv1/40326/5 "2020-07-23T10:46:23Z")

</div>

Closed on July 23, 2020, 10:46am UTC

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