141 std::cout <<
"Could not locate directory '" << dataset <<
"/InputVariables_Id' in file: " << fin << std::endl;
159 cout <<
"ups .. no methods found in to plot ROC curve for ... give up" << endl;
163 TIter next(&methods);
167 while ((key = (TKey *)next())) {
168 TDirectory *mDir = (TDirectory *)key->
ReadObj();
173 TIter nextTitle(&titles);
177 titDir = (TDirectory *)titkey->
ReadObj();
186 TGraph *
h = (TGraph *)hkey2->
ReadObj();
193 TString classname = hname(index, hname.
Length() - index);
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);
223 TGraph *
h = std::get<2>(item);
226 EfficiencyPlotWrapper *plotWrapper = classCanvasMap.at(classname);
229 }
catch (
const std::out_of_range &) {
230 cout <<
TString::Format(
"ERROR: Class %s discovered among plots but was not found by TMVAMulticlassGui. Skipping.",
263 if (plotType != EEfficiencyPlotType::kRejBvsEffS) {
264 std::cout <<
"For multiclass, only rejB vs effS is currently implemented.";
270 if (file ==
nullptr) {
271 std::cout <<
"ERROR: filename \"" << filename_input <<
"\" is not found.";
278 TString methodPrefix =
"MVA_";
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;
311 TString title =
"1v1 ROC curve comparison";
312 TControlBar *cbar =
new TControlBar(
"vertical", title, 50, 50);
318 for (
auto &classname : classnames) {
328 gROOT->SaveContext();
355 TString methodPrefix =
"MVA_";
359 if (file ==
nullptr) {
360 std::cout <<
"ERROR: filename \"" << fin <<
"\" is not found.";
366 for (
auto &classname : classnames) {
368 if (classname == baseClassname) {
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;
445 fLegend->AddEntry(graph, methodTitle,
"l");
470 TString xtit =
"Signal Efficiency";
471 TString ytit =
"Background Rejection (1 - eff)";
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
EfficiencyPlotWrapper(TString name, TString title, TString dataset, size_t i)
Private class EfficiencyPlotWrapper - Implementation.
void addLegendEntry(TString methodTitle, TGraph *graph)
WARNING: Uses the current color, thus the correct call ordering is: plotWrapper->addGraph(....
TCanvas * newEfficiencyCanvas(TString name, TString title, size_t i)
Helper to create new Canvas.
TLegend * newEfficiencyLegend()
Helper to create new legend.
Int_t addGraph(TGraph *graph)
Adds a new graph to the plot.
void save()
Saves the current state of the plot to disk.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
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.:
TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory") override
Find a directory using apath.
Describe directory structure in memory.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual TList * GetListOfKeys() const
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
1-D histogram with a float per channel (see TH1 documentation)
virtual void SetMaximum(Double_t maximum=-1111)
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetMinimum(Double_t minimum=-1111)
virtual TObject * ReadObj()
To read a TObject* from the file.
void Draw(Option_t *option="") override
Draw this box with its current attributes.
virtual void SetHeader(const char *header="", Option_t *option="")
void SetMargin(Float_t margin)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
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::map< TString, EfficiencyPlotWrapper * > classcanvasmap_t
std::vector< std::tuple< TString, TString, TGraph * > > roccurvelist_t
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=nullptr)
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)