# Storing TTreeReaderValue\<Float\_t\> into a tree branch

**URL:** <https://root-forum.cern.ch/t/storing-ttreereadervalue-float-t-into-a-tree-branch/26561>\
**Category:** ROOT\
**Created:** [October 12, 2017, 2:57pm UTC](https://root-forum.cern.ch/t/storing-ttreereadervalue-float-t-into-a-tree-branch/26561 "2017-10-12T14:57:26Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [October 17, 2017, 6:42pm UTC](https://root-forum.cern.ch/t/storing-ttreereadervalue-float-t-into-a-tree-branch/26561/5 "2017-10-17T18:42:40Z")

</div>

FYI on posting Code snippets:

> [@Getting the same histograms after cuts](https://root-forum.cern.ch/t/getting-the-same-histograms-after-cuts/24719/2):
>
> Remark on the way to post code snippets: When you post pieces of code on the forum enclose it with ``` . That makes your post much more readable (I systematically edit your posts that way) . So do: ``` // this is a C++ piece of code. ``` And it will display as: // this is a C++ piece of code.

Here are some comments:

```auto
TString fname;
TFile *input[n];
for (Int_t i=0; i<n; i++){
   //The following block is old code that should be removed, 
   // left to indicate what the issues were.

   //This line will not incorporate the index i
   //fname = “.filename[i]”; 
   //This line will try to open a file called "fname".
   // The pointer input will be overwritten on every loop and input will only
   // point to the last file open, while all the others will still be open.
   //input = TFile::Open(“fname”);

   //This will create a filename that is appended with index i.
   fname = Form("filename_%d", i);
   std::cout << "Opening filename: '" << fname << "'\n";
   //This will open a file with the name stored in the variable fname.
   //This will store each pointer to the files separately.
   input[n] = TFile.Open(fname);
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/storing-ttreereadervalue-float-t-into-a-tree-branch/26561)._
