Get filename attached to a specific event in RDataFrame

Dear ROOT-experts,

I’m wondering if there is a way to get the name of the file for which a specific entry in an RDF belongs to. If I create an RDF adding several files together I want to be able to get the filename of this event. E.g. to be used with the DefinePerSample(), where I want to use different numbers depending on the file I process.

Thanks for any help on this!


Hi @Eirik_Gramstad,

nice to see you on the forum and thank you for the question.

Yes, there is a way to do it using RSampleInfo (ROOT: ROOT::RDF::RSampleInfo Class Reference). There is a tutorial both in c++ and python showcasing some use of DefinePerSample including retrieving some of the information stored in the corresponding specification json file:

c++ version:

python version:

and the corresponding json file:

Please let me know if you need further information regarding any of these.


1 Like

Hi Marta

Thanks a lot! That is exactly what I’m looking for.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.