# Error in \<TTreeReaderValueBase::CreateProxy()\>

**URL:** <https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510>\
**Category:** Newbie\
**Tags:** rdataframe, root\
**Created:** [September 9, 2022, 11:19am UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510 "2022-09-09T11:19:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![beg1nner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@beg1nner](https://root-forum.cern.ch/u/beg1nner)\
**Post date:** [September 9, 2022, 11:19am UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510/1 "2022-09-09T11:19:01Z")

</div>

Hello,

I am trying to create histogram which will have only positively charged hadronic taus in it using RDataFrame and I get following error :

```nohighlight
Error in <TTreeReaderValueBase::CreateProxy()>: The branch GenVisTau_charge contains data of type {UNDETERMINED TYPE}, which does not have a dictionary.
terminate called after throwing an instance of 'std::runtime_error'
  what(): An error was encountered while processing the data. TTreeReader status code is: 6

```

The main script which is supposed to return tau pt for only + charge is following:

```auto
auto genVisTau_pt_plus = df.Define("GenVisTau_pt_plus", [] (
			const uint& nGenVisTau,
			const int& charge,
			const rvec<float>& genVisTau_pt){
				rvec<float> gentau_pt;
				for(uint i = 0 ; i < nGenVisTau ; i++){
						if( charge == 1){
							gentau_pt.push_back(genVisTau_pt[i]);
						}	
				}
				return gentau_pt;
			} , {"nGenVisTau", "GenVisTau_charge", "GenVisTau_pt"});

```

What I normally would have tried is instead of  
`if ( charge == 1 )`  
`if ( charge[i] == 1 ) ` , but it does not seem to work. With the later one I get `invalid types 'int[int]' for array subscript` error, after which I googled and tried this `if ( charge[i][0] == 1 )` , but it also does not work.  
As it seems I have a caveat in understanding how this works in RDataFrame. I would appreciate any help, thanks!

---

<div class="post-metadata">

**Author:** ![beg1nner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@beg1nner](https://root-forum.cern.ch/u/beg1nner)\
**Post date:** [September 9, 2022, 11:45am UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510/2 "2022-09-09T11:45:33Z")

</div>

Worked like this, maybe can be useful for someone else 🙂

```auto
			const uint& nGenVisTau,
			const rvec<int>& charge,
			const rvec<float>& genVisTau_pt){
				rvec<float> gentau_pt;
				for(uint i = 0 ; i < nGenVisTau ; i++){
					
						if( charge[i] == 1 && charge[i] != -1){
							gentau_pt.push_back(genVisTau_pt[i]);
						}
				}
				return gentau_pt;
			} , {"nGenVisTau", "GenVisTau_charge", "GenVisTau_pt"});

```

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 9, 2022, 12:38pm UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510/3 "2022-09-09T12:38:02Z")

</div>

Hi @beg1nner ,

sorry for the trouble! If `GenVisTau_charge` is an array of integers, then the right type to use to read it is `ROOT::RVec<int>` (or, with the latest ROOT, `ROOT::RVecI`). You can check what type the column is with `df.GetColumnType("GenVisTau_charge")`.

Now, you should not get that error message if you use the wrong type for a column. RDF should print a message that’s a bit friendlier and tells you about the type mismatch issue.  
What ROOT version are you using?

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![beg1nner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/b/d26b3c/32.png) [@beg1nner](https://root-forum.cern.ch/u/beg1nner)\
**Post date:** [September 9, 2022, 12:54pm UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510/4 "2022-09-09T12:54:55Z")

</div>

Hi @eguiraud ,

Thank you for your response. I have posted the solution to my question shortly before your answer. Indeed, using ` RVec` solved the issue.  
I’m using ROOT 6.24/00 with g++ (GCC) 10.1.0 . As you said, it would be nicer to see a friendlier error, because with this one I did not immediately get that it has problems with type.

Cheers

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [September 9, 2022, 1:18pm UTC](https://root-forum.cern.ch/t/error-in-ttreereadervaluebase-createproxy/51510/5 "2022-09-09T13:18:33Z")

</div>

> it would be nicer to see a friendlier error, because with this one I did not immediately get that it has problems with type

I totally agree – the weird thing is, you _should_ have gotten a friendlier error 😃 If you can share a minimal reproducer with me (including data) I could check what the behavior is with the latest ROOT version.

For example the following code:

```cpp
#include <ROOT/RDataFrame.hxx>

int main()
{
   // write an array of ints
   ROOT::RDataFrame(10).Define("arr", "ROOT::RVec<int>{1,2,3}").Snapshot("t", "test.root");
   // read it back as int instead of RVec<int>
   ROOT::RDataFrame("t", "test.root").Define("x", [](int a) { return a; }, {"arr"}).Count().GetValue();
}

```

produces:

```auto
Error in <TTreeReaderValueBase::CreateProxy()>: The branch arr contains data of type ROOT::VecOps::RVec<int>. It cannot be accessed by a TTreeReaderValue<int>
terminate called after throwing an instance of 'std::runtime_error'
  what(): An error was encountered while processing the data. TTreeReader status code is: 6
fish: Job 1, './foo' terminated by signal SIGABRT (Abort)

```

Cheers,  
Enrico
