Nullptr return when read RooDataSet by FindObject("<name>")

Hi, I tried save RooDataSet and read later by follow the tutorial 402
https://root.cern.ch/root/html/tutorials/roofit/rf402_datahandling.C.html

it says we use FindObject to retrieve RooDataset, like this:
RooDataSet* d = (RooDataSet*)f.FindObject(“RooDsData_pt6to8”),
however it return nullptr, instead I tried
RooDataSet* d = (RooDataSet*)f.Get(“RooDsData_pt6to8”) ;
it seems work, at least I can do d->Print(“v”).

does anyone know why the FindObject doesn’t work, and does the Get work properly? (My root version is 6.10) Thanks.

@moneta can you help?

Hi,

To retrieve object from a file you MUST use the Get function.
FindObject can be used only to retrieve object existing in the current directory, i.e. when are in memory. So, after having used Get you can use FIndObject

Lorenzo

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