TMVA ROC-Curve Extraction and Modification

ROOT Version 6.08/04
Platform Xubuntu 17.04
Compiler gcc6.3

Hello forum!

After a successful TMVA run the ROC-Curves are saved in my fdmTMVA.root file.
Each method gets a folder:

fdmTMVA.root -> TDirectoryFile::dataset -> TDirectoryFile::Method_KNN -> TDirectoryFile::KNN ->
TH1D::MVA_KNN_effBvsS (ROC-curve)

  • My question is, how do I extract the TH1D ROC-curve? I.e. how do I traverse TDirectoryFile folders?

  • Secondly, how do I modify it using the TSyle and THistPainter Classes?

Attempt:

// Open .root file
TFile *f1 = TFile::Open("fdmTMVA.root");

// Set pointer to directory containing ROC-curve
TDirectory* dir = gFile->GetDirectory("/dataset/Method_KNN/KNN");

TString objectName( "MVA_KNN_effBvsS" );
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");

delete c;
delete f1;

This doesn’t work as it gives the following warning:

  • Warning: null passed to a callee that requires a non-null argument [-Wnonnull] dir->GetObject(objectName,h);

Many thanks in advance!

Edit: This now works by replacing GetDirectory(“Method_KNN/KNN”) with GetDirectory("/dataset/Method_KNN/KNN")

Update: I’m now manually extracting the ROC-Curve via TBrowser, saving it in a .root file. Which allows me to interact with it in other macros.

Surely I am missing something benign here, can’t I do this same operation in my macro out of the original .root file?

Thanks again.

@moneta @kialbert can one of you help?

Hi,

You need to specify correctly the directory. I think you missing the top-level directory (this is normally the Name of the DataLoader class). You can do f1->ls() to see the name

Lorenzo

1 Like

Thanks for the reply. That’s a good point, I’ve changed it to

TDirectory* dir = gFile->GetDirectory("./dataset/Method_KNN/KNN");

Unfortunately, this does not fix the error.

Should it help, this is the .root file:
fdmTMVA.root (1.2 MB)

I also cannot get to the directory via the root commandline. Am I using the wrong commands?

Thanks.

gFile->GetDirectory("/dataset/Method_KNN/KNN")->ls();
gFile->GetDirectory("dataset/Method_KNN/KNN")->ls();
1 Like

Works! I was supplying it with the wrong directory then.

I’ve edited the original code in the first post to reflect this.

Thanks people.