LeWhoo
July 9, 2020, 7:02am
#1
Dear ROOTers,

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

```
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

```
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

Maybe @pcanal has an explanation

LeWhoo
July 9, 2020, 7:37am
#3
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?

Problem description (more than 5 years old):

In the TTree::Draw 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:

{
TFile *f = TFile::Open("some_file.root");
TTree *t; f->GetObject("some_tree", t);
t->SetEstimate(-1);
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;
}
#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…

system
closed
July 23, 2020, 10:46am
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.