# Filter option in RDataFrame

Hello everyone, im here trying to learn about RDataFrame. i don’t quite understand the filter process for example if i define this:
df_Mass3 = ROOT.RDataFrame(“DecayTree”,str(path)+“/”+“SG_Bc2HNplusleptons_Mass3_tree.root”)

# Filter apllied

df_muon1_Mass3_PTcut = df_Mass3.Filter(“mu2_PT > 5”, “Muons1 Events for Mass3 with Pt > 5 GeV”)
df_muon2_Mass3_PTcut = df_Mass3.Filter(“mu1_PT > 5”, “Muons2 Events for Mass3 with Pt > 5 GeV”)

# Filter report

report1 = df_muon1_Mass3_PTcut.Report()
report2 = df_muon2_Mass3_PTcut.Report()
i get:
Muons1 Events for Mass3 with Pt > 5 GeV: pass=130 all=3530 – eff=3.68 % cumulative eff=3.68 %
Muons2 Events for Mass3 with Pt > 5 GeV: pass=589 all=3530 – eff=16.69 % cumulative eff=16.69 %
Thing i corroborate it passing the RDataframe to a csv file. But if i use the filter condition like this:

df_mu1_Mass3_PTcut = df_Mass3.Filter(“mu2_PT > 5”, “Muons2 Events for Mass3 with Pt > 5 GeV”)
df_mu2_Mass3_PTcut = df_mu1_Mass3_PTcut.Filter(“mu1_PT > 5”, “Muons1 Events for Mass3 with Pt > 5 GeV”)

# Solicitar el informe de flujo de corte

report = df_mu2_Mass3_PTcut.Report()

# Imprimir el informe de flujo de corte

report.Print()
i get: Muons2 Events for Mass3 with Pt > 5 GeV: pass=130 all=3530 – eff=3.68 % cumulative eff=3.68 %
Muons1 Events for Mass3 with Pt > 5 GeV: pass=43 all=130 – eff=33.08 % cumulative eff=1.22 %
Wish is different from the first one. Even though mu1_PT and mu2_PT are two different branches with the same entries 3533, but the second filer applied to the first give me all=130 . That are the mu1_PT that pass the first condition. And i do not understand that.
Thank you very much before hand. I hope its not an to basic of a question.
Sorry to bother.

ROOT Version: 6.30/04

Hi Christian,

Welcome to the ROOT community!
The argument of Filter, when one uses a string to select entries, it’s the cut. Therefore, if you have a column called “mu2_PT” and “mu1_PT”, your filters would simply look like:

``````df_muon1_Mass3_PTcut = df_Mass3.Filter(“mu2_PT > 5”)
df_muon2_Mass3_PTcut = df_Mass3.Filter(“mu1_PT > 5”)
``````

I hope this helps!

Cheers,
D