# How to get the data for only one branch

**URL:** <https://root-forum.cern.ch/t/how-to-get-the-data-for-only-one-branch/59240>\
**Category:** Newbie\
**Created:** [May 6, 2024, 2:43pm UTC](https://root-forum.cern.ch/t/how-to-get-the-data-for-only-one-branch/59240 "2024-05-06T14:43:48Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![KillianUB](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/46a35a/32.png) [@KillianUB](https://root-forum.cern.ch/u/KillianUB)\
**Post date:** [May 7, 2024, 9:23am UTC](https://root-forum.cern.ch/t/how-to-get-the-data-for-only-one-branch/59240/5 "2024-05-07T09:23:36Z")

</div>

```auto
std::unique_ptr<TFile> myFile(TFile::Open("RAW148OS_treeFF01.root", "READ"));
auto tree = myFile->Get<TTree>("Analysis_All");   

int variable;
tree->SetBranchAddress("Fragment_Velocity", &variable);

for (int iEntry = 0; tree->LoadTree(iEntry) >= 0; ++iEntry) {
   // Load the data for the given tree entry
   tree->GetEntry(iEntry);

   // Now, `variable` is set to the value of the branch
   // "branchName" in tree entry `iEntry`
   std::cout << variable << std::endl;
}

```

Is it better now ?

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-get-the-data-for-only-one-branch/59240)._
