# Data handling using rDataFrame for Tree branches of Char\_t type data

**URL:** <https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983>\
**Category:** Newbie\
**Created:** [August 6, 2025, 7:23am UTC](https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983 "2025-08-06T07:23:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hohshita](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/5f9b8f/32.png) [@hohshita](https://root-forum.cern.ch/u/hohshita)\
**Post date:** [August 6, 2025, 7:23am UTC](https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983/1 "2025-08-06T07:23:25Z")

</div>

Dear ROOT experts,

We are using the Geant4 to evaluate neutron detector performance.  
We analyze the data from each step of the Geant4 and store the results in the ROOT Tree at the end of the event.  
The stored data includes energy deposit, flight length, coordinates of neutron reaction points in the active area, and so on.  
Additionally, reaction-generated particles such as proton, triton, and so on and reaction names are saved as strings of type Char\_t.  
Now, we could display the data stored in the ROOT Tree with conventional methods, but when using rDataFrame for faster data handling, we encountered the following error.  
This error occurred when executing the sample code ‘test\_RDF’.  
Please advise on a solution.

> Error in TTreeReaderValueBase::GetBranchDataType(): Must use TTreeReaderArray to read branch particle\_name: it contains an array or a collection.  
> Error in TTreeReaderValueBase::CreateProxy(): The branch particle\_name contains data of type {UNDETERMINED TYPE}, which does not have a dictionary.  
> Error in TRint::HandleTermInput(): std::runtime\_error caught: An error was encountered while processing the data. TTreeReader status code is: 6

A simple code is attached. The usage is as follows.

> $ root -l  
> root [0] .L test.C  
> root [1] test(“B4.root”)  
> → Display using the conventional method  
> root [2] test\_RDF(“B4.root”)  
> → Method using rDataFrame, but an error occurs

B4.root contains data obtained by injecting thermal neutrons into a 3-helium detector.  
To display the data stored in B4.root, plese use the following commands:

> root [3] showElement(“B4.root”)  
> → Display using the conventional method  
> root [4] showElement\_RDF(“B4.root”)  
> → If only numerical data are to be displayed, we can use rDataFrame.

[B4.root](https://root-forum.cern.ch/uploads/short-url/wiVeLUIVZuPEPCygY3zFjYI1JbC.root) (1.9 MB)  
[test.C](https://root-forum.cern.ch/uploads/short-url/lfokFKixveSt4N2o2lIKAYTxiGq.C) (12.1 KB)

\_ROOT Version: 6.36.00  
\_Platform: AlmaLinux 9.6  
\_Compiler: g++ (GCC) 11.5.0

Best regards,  
Hide

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [August 6, 2025, 8:16am UTC](https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983/2 "2025-08-06T08:16:07Z")

</div>

I guess @vpadulan or @mczurylo can help you with RDF questions.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 6, 2025, 12:00pm UTC](https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983/3 "2025-08-06T12:00:56Z")

</div>

Maybe Enrico’s solution [here](https://root-forum.cern.ch/t/rdataframe-built-from-string-branches/49132) will help. Basically, redefine the (currently `RVec<char>`) column (or define a new one) as string; something like

```auto
  auto df_with_parsed_branch = rdf.Define("parsed_particle_name", "std::string(particle_name.data(), particle_name.size())");

```

and use the strings as needed.

---

<div class="post-metadata">

**Author:** ![hohshita](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/5f9b8f/32.png) [@hohshita](https://root-forum.cern.ch/u/hohshita)\
**Post date:** [August 7, 2025, 4:51am UTC](https://root-forum.cern.ch/t/data-handling-using-rdataframe-for-tree-branches-of-char-t-type-data/63983/4 "2025-08-07T04:51:33Z")

</div>

Dear dastudillo,

Thank you for your prompt reply.

Following your advice, our simple code worked.

We have attached the revised code.  
[test.C](https://root-forum.cern.ch/uploads/short-url/sFAu08rIGqngbBZVqr3jwCoUHIn.C) (14.0 KB)

The usage is the same as previous mentioned.  
And we have confirmed that the display-outputs of the test and test\_RDF functions, as well as the showElement and showElement\_RDF functions, are the same.

Best regards,  
Hide
