Creating multiple histograms from columnar dataset with different conditions

Hello everyone! I have basic knowledge of how to use ROOT but I can’t come up with a good idea to create a set of histograms, each containing cross-sections for a specific range of angles using a set of data we gathered. For example, I would like to fill a histogram with cross-sections in bins of energy that were measured between cosine angles of -1 to -0.9. The columns are lower bound cosine angle, upper bound cosine angle, lower bound energy, upper bound energy, and then the cross section. I would upload a text file containing the data but unfortunately I am a new user

I was contemplating if using the TDataFrame class would help in this case or creating some sort of loop to help sort it out, but I’m not exactly sure how to do this either. I’ll continue to look into this as well.

ROOT Version: 6.26/06
Platform: Ubuntu 22.04.1
Compiler: Gpp-compiler for Atom

Hi @PKimPhysics ,

and welcome to the ROOT forum.

See e.g. this post for a C++ example of something similar done with RDataFrame.

RDataFrame’s user guide is here and there are a number of C++ and Python tutorials available here.

Basically you want to create a list/vector of RDataFrame results that you fill, in a loop, with several result histograms.

I hope this helps.

Hi Enrico! Thanks for the advice. I will try this out and report back.

This might be a silly question (just wanting to make sure) but does this work with text files as long as I replace the .root with .txt?

RDataFrame can read CSV files as long as the column types are one of the supported ones: ROOT: ROOT::RDF::RCsvDS Class Reference , tutorial here: ROOT: tutorials/dataframe/df014_CSVDataSource.C File Reference

Thank you! I’ll see if I run into any problems.