Data handling using rDataFrame for Tree branches of Char_t type data

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 (1.9 MB)
test.C (12.1 KB)

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

Best regards,
Hide


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

Maybe Enrico’s solution here will help. Basically, redefine the (currently RVec<char>) column (or define a new one) as string; something like

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

and use the strings as needed.

1 Like

Dear dastudillo,

Thank you for your prompt reply.

Following your advice, our simple code worked.

We have attached the revised code.
test.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

2 Likes