Hello all,
I want to filter my root files based on some cuts applied to the variables existed in the files. I have found some discussions about it, In RDataFrame using Filter() we can do it. I tried but I couldn’t able to do it. For example, I have a variable ‘mass’ in the root file, I want the root file where all the variables will be applied a filter of ‘mass>5’. Is it possible here ? Please let me know how I will use the branch variables to Filter().
There are other methods also like to write a code and run over it which is lengthy. I was curious if I could do it with less line of code using RDataFrame.
If mass is an array, and you want to select array elements of other variables that correspond to elements for which mass[i] > 5, then you have to write something like this:
Then you would be in case number 2 there, you define a “mask” of good indexes and then index each vector variable to select the elements that correspond to the good indexes.
There are also several tutorials that show how to work with collections in RDF.
The user guide has a section about working with collections that should help, and it points to the documentation of RVec which is the special vector-like type that defines those “fancy indexing” operations that we are using (RDF reads all collections as RVecs by default).
If the limitation of having to Define the filtered collections with a different name is too strong, you can get a ROOT build with the Redefine feature from our nightly releases.