88class EfficiencyPlotWrapper {
113 TLegend *newEfficiencyLegend();
141 std::cout <<
"Could not locate directory '" << dataset <<
"/InputVariables_Id' in file: " << fin << std::endl;
157 UInt_t nm = TMVAGlob::GetListOfMethods(methods, binDir);
159 cout <<
"ups .. no methods found in to plot ROC curve for ... give up" << endl;
163 TIter next(&methods);
167 while ((key = (
TKey *)next())) {
170 TMVAGlob::GetListOfTitles(mDir, titles);
173 TIter nextTitle(&titles);
176 while ((titkey = TMVAGlob::NextKey(nextTitle,
"TDirectory"))) {
179 TMVAGlob::GetMethodTitle(methodTitle, titDir);
184 while ((hkey2 = TMVAGlob::NextKey(nextKey,
"TGraph"))) {
197 rocCurves.push_back(std::make_tuple(methodTitle, classname,
h));
219 for (
auto &item : rocCurves) {
221 TString methodTitle = std::get<0>(item);
222 TString classname = std::get<1>(item);
226 EfficiencyPlotWrapper *plotWrapper = classCanvasMap.at(classname);
227 plotWrapper->addGraph(
h);
228 plotWrapper->addLegendEntry(methodTitle,
h);
229 }
catch (
const std::out_of_range &) {
230 cout <<
Form(
"ERROR: Class %s discovered among plots but was not found by TMVAMulticlassGui. Skipping.",
248 TMVAGlob::Initialize(useTMVAStyle);
263 if (plotType != EEfficiencyPlotType::kRejBvsEffS) {
264 std::cout <<
"For multiclass, only rejB vs effS is currently implemented.";
269 TFile *
file = TMVAGlob::OpenFile(filename_input);
270 if (
file ==
nullptr) {
271 std::cout <<
"ERROR: filename \"" << filename_input <<
"\" is not found.";
274 auto binDir =
file->GetDirectory(dataset.
Data());
279 TString graphNameRef =
"_rejBvsS_";
282 for (
auto &classname : classnames) {
285 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(
name, title, dataset, iPlot++);
286 classCanvasMap.emplace(classname.
Data(), plotWrapper);
292 for (
auto const &item : classCanvasMap) {
293 auto plotWrapper = item.second;
306 std::cout <<
"--- Running Roc1v1Gui for input file: " << fin << std::endl;
308 TMVAGlob::Initialize();
311 TString title =
"1v1 ROC curve comparison";
318 for (
auto &classname : classnames) {
320 Form(
"TMVA::plotEfficienciesMulticlass1vs1(\"%s\", \"%s\", \"%s\")", dataset.
Data(), fin.
Data(),
328 gROOT->SaveContext();
350 TMVAGlob::Initialize();
356 TString graphNameRef =
Form(
"_1v1rejBvsS_%s_vs_", baseClassname.
Data());
359 if (
file ==
nullptr) {
360 std::cout <<
"ERROR: filename \"" << fin <<
"\" is not found.";
363 auto binDir =
file->GetDirectory(dataset.
Data());
366 for (
auto &classname : classnames) {
368 if (classname == baseClassname) {
373 TString title =
Form(
"ROC Curve %s (Sig) vs %s (Bkg)", baseClassname.
Data(), classname.
Data());
374 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(
name, title, dataset, iPlot++);
375 classCanvasMap.emplace(classname.
Data(), plotWrapper);
381 for (
auto const &item : classCanvasMap) {
382 auto plotWrapper = item.second;
403 fy0H = 1 - fy0H + fdyH + 0.07;
410 fCanvas = newEfficiencyCanvas(
name, title, i);
411 fLegend = newEfficiencyLegend();
421 graph->SetLineWidth(3);
422 graph->SetLineColor(fColor);
424 if (fColor == 5 || fColor == 10 || fColor == 11) {
445 fLegend->AddEntry(
graph, methodTitle,
"l");
448 fLegend->SetY2(fy0H + dyH_local);
470 TString xtit =
"Signal Efficiency";
471 TString ytit =
"Background Rejection (1 - eff)";
492TLegend *EfficiencyPlotWrapper::newEfficiencyLegend()
494 TLegend *legend =
new TLegend(fx0L, fy0H - fdyH, fx0L + fdxL, fy0H);
507void EfficiencyPlotWrapper::save()
509 TString fname = fDataset +
"/plots/" + fCanvas->GetName();
static const double x2[5]
static const double x1[5]
char * Form(const char *fmt,...)
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
void Show()
Show control bar.
void AddButton(TControlBarButton *button)
Add button.
void SetTextColor(const char *colorName)
Sets text color for control bar buttons, e.g.:
Describe directory structure in memory.
virtual TList * GetListOfKeys() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a float per channel (see TH1 documentation)}
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual TObject * ReadObj()
To read a TObject* from the file.
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetHeader(const char *header="", Option_t *option="")
Sets the header, which is the "title" that appears at the top of the legend.
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
void SetMargin(Float_t margin)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
std::vector< std::tuple< TString, TString, TGraph * > > roccurvelist_t
std::map< TString, EfficiencyPlotWrapper * > classcanvasmap_t
TFile * OpenFile(const TString &fin)
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
std::vector< TString > GetClassNames(TDirectory *dir)
void imgconv(TCanvas *c, const TString &fname)
create variable transformations
roccurvelist_t getRocCurves(TDirectory *binDir, TString methodPrefix, TString graphNameRef)
void efficienciesMulticlass1vs1(TString dataset, TString fin)
std::vector< TString > getclassnames(TString dataset, TString fin)
void plotEfficienciesMulticlass1vs1(TString dataset, TString fin, TString baseClassname)
void plotEfficienciesMulticlass1vsRest(TString dataset, EEfficiencyPlotType plotType=EEfficiencyPlotType::kRejBvsEffS, TString filename_input="TMVAMulticlass.root")
void plotEfficienciesMulticlass(roccurvelist_t rocCurves, classcanvasmap_t classCanvasMap)
void efficienciesMulticlass1vsRest(TString dataset, TString filename_input="TMVAMulticlass.root", EEfficiencyPlotType plotType=EEfficiencyPlotType::kRejBvsEffS, Bool_t useTMVAStyle=kTRUE)
Short_t Min(Short_t a, Short_t b)