Division in RDataframe


_ROOT Version: Ubu-18
Platform: Not Provided
Compiler: Not Provided


Hi
I am working with RDataFrame. I created two 2-dim histograms out of this Dataframe. I want to make a ratio of both using the following trick-

auto Chi2TPC_ITSMean_vs_phiMean_data = df_data.Histo2D({hisnameData, hisnameData, 64u, 0,6.3 , 32u, 0., 90.}, "phiMean", "Chi2TPC_ITSMean");
Chi2TPC_ITSMean_vs_phiMean_data->Write();
auto Chi2TPC_ITSMean_vs_phiMean_mc = df_mc.Histo2D({hisnameMc,hisnameMc, 64u, 0,6.3 , 32u, 0., 90.}, "phiMean", "Chi2TPC_ITSMean");
Chi2TPC_ITSMean_vs_phiMean_mc->Write();
TH2F *ratio = new TH2F("data_mc_ratio_chi2","data_mc_ratio_chi2",200,0,6.5,100,0,100);
ratio = (TH2F*)Chi2TPC_ITSMean_vs_phiMean_data->Clone();
ratio->Divide(Chi2TPC_ITSMean_vs_phiMean_mc);

But I am getting an error

branch2hist.C:22:8: error: no matching member function for call to 'Divide'
ratio->Divide(Chi2TPC_ITSMean_vs_phiMean_mc);

Could you please help me to get out of this error? Is there any way for division of histograms?

Thanks!

Hi @hym!
The most interesting part of the error message is actually what comes after “no matching member function…”: it should tell you exactly what is the type mismatch you are encountering.

In this case the exact issue is most probably that Chi2TPC_ITSMean_vs_phiMean_mc is a RResultPtr<TH1D> (RResultPtr is RDataFrame’s smart pointer type) while Divide expects a TH1* (a raw pointer) as argument. So this should work:

ratio->Divide(Chi2TPC_ITSMean_vs_phiMean_mc.GetPtr());

See also RResultPtr's documentation here.

Hope this helps,
Enrico

1 Like

Thanks a Lot Enrico!!!
You made the day :smile:

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