89class EfficiencyPlotWrapper {
114 TLegend *newEfficiencyLegend();
142 std::cout <<
"Could not locate directory '" << dataset <<
"/InputVariables_Id' in file: " << fin << std::endl;
160 cout <<
"ups .. no methods found in to plot ROC curve for ... give up" << endl;
164 TIter next(&methods);
168 while ((key = (
TKey *)next())) {
174 TIter nextTitle(&titles);
193 TString classname = hname(index + 1, hname.
Length() - (index + 1));
195 rocCurves.push_back(std::make_tuple(methodTitle, classname,
h));
217 for (
auto &item : rocCurves) {
219 TString methodTitle = std::get<0>(item);
220 TString classname = std::get<1>(item);
224 EfficiencyPlotWrapper *plotWrapper = classCanvasMap.at(classname);
225 plotWrapper->addGraph(
h);
226 plotWrapper->addLegendEntry(methodTitle,
h);
227 }
catch (
const std::out_of_range &oor) {
228 cout <<
Form(
"ERROR: Class %s discovered among plots but was not found by TMVAMulticlassGui. Skipping.",
261 if (plotType != EEfficiencyPlotType::kRejBvsEffS) {
262 std::cout <<
"For multiclass, only rejB vs effS is currently implemented.";
268 if (
file ==
nullptr) {
269 std::cout <<
"ERROR: filename \"" << filename_input <<
"\" is not found.";
272 auto binDir =
file->GetDirectory(dataset.
Data());
277 TString graphNameRef =
"_rejBvsS_";
280 for (
auto &classname : classnames) {
283 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(
name, title, dataset, iPlot++);
284 classCanvasMap.emplace(classname.
Data(), plotWrapper);
290 for (
auto const &item : classCanvasMap) {
291 auto plotWrapper = item.second;
304 std::cout <<
"--- Running Roc1v1Gui for input file: " << fin << std::endl;
309 TString title =
"1v1 ROC curve comparison";
316 for (
auto &classname : classnames) {
318 Form(
"TMVA::plotEfficienciesMulticlass1vs1(\"%s\", \"%s\", \"%s\")", dataset.
Data(), fin.
Data(),
326 gROOT->SaveContext();
354 TString graphNameRef =
Form(
"_1v1rejBvsS_%s_vs_", baseClassname.
Data());
357 if (
file ==
nullptr) {
358 std::cout <<
"ERROR: filename \"" << fin <<
"\" is not found.";
361 auto binDir =
file->GetDirectory(dataset.
Data());
364 for (
auto &classname : classnames) {
366 if (classname == baseClassname) {
371 TString title =
Form(
"ROC Curve %s (Sig) vs %s (Bkg)", baseClassname.
Data(), classname.
Data());
372 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(
name, title, dataset, iPlot++);
373 classCanvasMap.emplace(classname.
Data(), plotWrapper);
379 for (
auto const &item : classCanvasMap) {
380 auto plotWrapper = item.second;
401 fy0H = 1 - fy0H + fdyH + 0.07;
408 fCanvas = newEfficiencyCanvas(
name, title, i);
409 fLegend = newEfficiencyLegend();
419 graph->SetLineWidth(3);
420 graph->SetLineColor(fColor);
422 if (fColor == 5 || fColor == 10 || fColor == 11) {
427 graph->DrawClone(
"");
443 fLegend->AddEntry(
graph, methodTitle,
"l");
446 fLegend->SetY2(fy0H + dyH_local);
468 TString xtit =
"Signal Efficiency";
469 TString ytit =
"Background Rejection (1 - eff)";
487TLegend *EfficiencyPlotWrapper::newEfficiencyLegend()
489 TLegend *legend =
new TLegend(fx0L, fy0H - fdyH, fx0L + fdxL, fy0H);
502void EfficiencyPlotWrapper::save()
504 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 Graph is a graphics object made of two arrays X and Y with npoints each.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
2-D histogram with a float per channel (see TH1 documentation)}
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.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
const char * Data() const
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
std::vector< std::tuple< TString, TString, TGraph * > > roccurvelist_t
std::map< TString, EfficiencyPlotWrapper * > classcanvasmap_t
static constexpr double nm
UInt_t GetListOfTitles(TDirectory *rfdir, TList &titles)
void Initialize(Bool_t useTMVAStyle=kTRUE)
TKey * NextKey(TIter &keyIter, TString className)
void GetMethodTitle(TString &name, TKey *ikey)
TFile * OpenFile(const TString &fin)
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=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)