Extracting ROC curve from a file and plotting it on a graph in root

Hi,
I’m trying to draw multiple ROC curves on one canvas in root. To be able to do that, first I need to extract ROC curves from the files. So far I tried the following code which I found:

// Open .root file
TFile *f1 = TFile::Open(“TMVA_2022.root”);

// Set pointer to directory containing ROC-curve
TDirectory* dir = gFile->GetDirectory(“/dataset/plots”);

TString objectName( “rejBvsS” );
TH1D* h;

// Extract ROC-curve
dir->GetObject(objectName,h);

// Set Canvas
TCanvas *c = new TCanvas(“c”);
gPad->SetGrid();
// more style options etc…

// Draw and save
h->Draw();
c->SaveAs(objectName + “.png”);

But I get following error:
Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
ROOT_prompt_4:1:1: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
dir->GetObject(objectName,h);

It would be great if anyone has the solution to this problem. One person, as I saw, had the exact problem and the problem was that the top level directory wasn’t included, but that doesn’t seem to be the problem in my case. Thanks in advance for any help!

ROOT Version: 6.22.08
_Ubuntu Version: 20.04.4 LTS
_WSL

Maybe the “/dataset/plots” directory does not exist in the “TMVA_2022.root” file.
Try: TDirectory *dir = gFile->GetDirectory("/dataset/plots", kTRUE);

Yes, you’re right it doesn’t exist. Can you direct me how to see the directories that are in the file?

Try to execute: rootls -1l "TMVA_2022.root:*"

Everything works fine now, thanks for all the help!