# The fastest way to read all tree branch data?

**URL:** <https://root-forum.cern.ch/t/the-fastest-way-to-read-all-tree-branch-data/38263>\
**Category:** ROOT\
**Tags:** tree\
**Created:** [March 4, 2020, 10:47pm UTC](https://root-forum.cern.ch/t/the-fastest-way-to-read-all-tree-branch-data/38263 "2020-03-04T22:47:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [March 5, 2020, 10:47am UTC](https://root-forum.cern.ch/t/the-fastest-way-to-read-all-tree-branch-data/38263/3 "2020-03-05T10:47:57Z")

</div>

```cpp
{
  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;
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/the-fastest-way-to-read-all-tree-branch-data/38263)._
