I created two graphs from data read with the RDataFrame. The final step in my visualization of the data is the legend. Sadly this fails with the message:
buildroot/include/TLegend.h:36:20: note: candidate function not viable: no known conversion from ‘ROOT::RDF::RResultPtr’ to 'const TObject ’ for 1st argument
TLegendEntry AddEntry(const TObject obj, const char label = “”, Option_t* option = “lpf” );
^
buildroot/include/TLegend.h:37:20: note: candidate function not viable: no known conversion from ‘ROOT::RDF::RResultPtr’ to ‘const char *’ for 1st argument
TLegendEntry AddEntry(const char name, const char label = “”, Option_t option = “lpf” );
I think this is expected.
The return value of the RDF actions is always wrapped in a RResultPtr. You should get out of the smartpointer the pointer to the histogram with the Get method:
unfortunately this does not solve the problem. Changing g2 to g2.Get() returns the error: ‘Get’ is a private member of ‘ROOT::RDF::RResultPtr’
and changing it to g2->Get() returns the error: no member named ‘Get’ in ‘TGraph’. The Later makes sense since I am addressing the member functions of TGraph.
Why is TLegend not taking the information of the underlying graph when I am giving him a smartpointer which points to the object?
my bad. I meant RResultPtr<T>::GetPtr().
The compiler is not happy because this is the behaviour of C++. It sometimes may seem frustrating but I believe it’s a big advantage for correctness