46 TString pname =
"purS_" + methodTitle;
47 TString epname =
"effpurS_" + methodTitle;
48 TString ssigname =
"significance_" + methodTitle;
50 sigE = (
TH1*)origSigE->
Clone(
"sigEffi");
51 bgdE = (
TH1*)origBgdE->Clone(
"bgdEffi");
53 Int_t nbins = sigE->GetNbinsX();
54 Double_t low = sigE->GetBinLowEdge(1);
55 Double_t high = sigE->GetBinLowEdge(nbins+1);
56 purS =
new TH1F(pname, pname, nbins, low, high);
57 sSig =
new TH1F(ssigname, ssigname, nbins, low, high);
58 effpurS =
new TH1F(epname, epname, nbins, low, high);
61 sigE->SetTitle(
TString::Format(
"Cut efficiencies for %s classifier", methodTitle.Data()) );
67 sigE->SetFillStyle( 0 );
68 bgdE->SetFillStyle( 0 );
69 sSig->SetFillStyle( 0 );
70 sigE->SetLineWidth( 3 );
71 bgdE->SetLineWidth( 3 );
72 sSig->SetLineWidth( 3 );
75 purS->SetFillStyle( 0 );
76 purS->SetLineWidth( 2 );
77 purS->SetLineStyle( 5 );
78 effpurS->SetFillStyle( 0 );
79 effpurS->SetLineWidth( 2 );
80 effpurS->SetLineStyle( 6 );
85 fNSignal = fSigInput->GetNumber();
90 fNBackground = fBkgInput->GetNumber();
96 auto replace_vars = [](
TString &
f,
char oldLetter,
char newLetter ) {
97 auto pos =
f.
First(oldLetter);
99 if ( ( pos > 0 && !
TString(
f[pos-1]).IsAlpha() ) ||
105 pos =
f.Index(oldLetter,pos2);
110 replace_vars(formula,
'S',
'x');
111 replace_vars(formula,
'B',
'y');
131 UpdateSignificanceHists();
143 TIter next(fInfoList);
155 fSigInput->Disconnect();
156 fBkgInput->Disconnect();
157 fDrawButton->Disconnect();
158 fCloseButton->Disconnect();
160 fMain->CloseWindow();
219 fSigInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogMVAEffs",
this,
"SetNSignal()");
220 fBkgInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogMVAEffs",
this,
"SetNBackground()");
232 if (fInfoList==0)
return;
233 if (fInfoList->First()==0)
return;
239 TIter next(fInfoList);
252 TIter next(fInfoList);
255 if (
cname.Length() > maxLenTitle) maxLenTitle =
cname.Length();
257 maxLenTitle,
cname.Data(), GetFormulaString().Data() );
258 cout <<
"--- " << setfill(
'=') << setw(str.
Length()) <<
"" << setfill(
' ') << endl;
259 cout <<
"--- " << str << endl;
260 cout <<
"--- " << setfill(
'-') << setw(str.
Length()) <<
"" << setfill(
' ') << endl;
273 if (GetFormulaString() ==
"S/sqrt(B)") {
274 maxSigErr = sig * sqrt( 1./S + 1./(2.*B));
286 PrintResults( info );
288 cout <<
"--- " << setfill(
'-') << setw(str.
Length()) <<
"" << setfill(
' ') << endl << endl;
294 TIter next(fInfoList);
302 fInfoList =
new TList;
305 TIter next(
file->GetDirectory(dataset.Data())->GetListOfKeys());
307 while( (key = (
TKey*)next()) ) {
310 if( !
gROOT->GetClass(key->
GetClassName())->InheritsFrom(
"TDirectory") )
continue;
312 cout <<
"--- Found directory: " << ((
TDirectory*)key->
ReadObj())->GetName() << endl;
318 while((titkey = (
TKey*)keyIt())) {
319 if( !
gROOT->GetClass(titkey->
GetClassName())->InheritsFrom(
"TDirectory") )
continue;
329 cout <<
"--- Classifier: " << info->
methodTitle << endl;
331 info->
sig =
dynamic_cast<TH1*
>(titDir->
Get( hname +
"_S" ));
332 info->
bgd =
dynamic_cast<TH1*
>(titDir->
Get( hname +
"_B" ));
333 info->
origSigE =
dynamic_cast<TH1*
>(titDir->
Get( hname +
"_effS" ));
334 info->
origBgdE =
dynamic_cast<TH1*
>(titDir->
Get( hname +
"_effB" ));
338 fInfoList->Add(info);
347 Int_t countCanvas = 0;
353 TIter next(fInfoList);
386 c->SetRightMargin ( 2.0 );
405 c->GetLeftMargin() + 0.4, 1 -
c->GetTopMargin() + 0.12 );
408 legend1->
AddEntry(info->
bgdE,
"Background efficiency",
"L");
409 legend1->
Draw(
"same");
413 TLegend *legend2=
new TLegend(
c->GetLeftMargin() + 0.4, 1 -
c->GetTopMargin(),
414 1 -
c->GetRightMargin(), 1 -
c->GetTopMargin() + 0.12 );
418 legend2->
AddEntry(info->
sSig,GetLatexFormula().Data(),
"L");
419 legend2->
Draw(
"same");
435 tl.
DrawLatex( 0.15, 0.19,
"events the maximum "+GetLatexFormula()+
" is");
451 tl.
DrawLatex( 0.13, 0.77,
"Method Cuts provides a bundle of cut selections, each tuned to a");
452 tl.
DrawLatex(0.13, 0.74,
"different signal efficiency. Shown is the purity for each cut selection.");
483 if (info->
line1 !=0 )
486 if (info->
line2 !=0 ) {
515 TString opt =
TString::Format(
"%%%is: (%%9.8g,%%9.8g) %%9.4f (%%8.3g +-%%6.3g) %%8.7g %%8.7g %%8.4g %%8.4g",
537 if (graphicsClient ==
nullptr && !
gROOT->IsBatch()) {
540 Info(
"mvaeffs",
"GUI is not initialized, because TApplication is not started. Running as in batch mode");
543 Error(
"mvaeffs",
"TApplication is present but TGCLient instance is a nullptr");
548 StatDialogMVAEffs* gGui =
new StatDialogMVAEffs(dataset,
549 (graphicsClient) ? graphicsClient->
GetRoot() : nullptr, nsignal, nbackground);
553 gGui->ReadHistograms(
file);
554 gGui->SetFormula(formula);
555 gGui->UpdateSignificanceHists();
556 gGui->DrawHistograms();
557 if (!
gROOT->IsBatch()) gGui->RaiseDialog();
R__EXTERN TApplication * gApplication
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual Float_t GetTitleSize() const
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
void Paint(Option_t *option="") override
Paint canvas.
void Update() override
Update canvas pad buffers.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Describe directory structure in memory.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual TList * GetListOfKeys() const
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
const TGWindow * GetRoot() const
Returns current root (i.e.
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
void MapWindow() override
map window
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
TGNumberEntry is a number entry input widget with up/down buttons.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
void SetTitleSize(Float_t titlesize)
virtual void SetTitle(const char *title="")
Change the title of the axis.
void SetWmax(Double_t wmax)
void SetLabelColor(Int_t labelcolor)
void SetTitleColor(Int_t titlecolor)
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
void SetTitle(const char *title) override
Change/set the title.
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual const char * GetClassName() const
virtual TObject * ReadObj()
To read a TObject* from the file.
To draw Mathematical Formula.
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
This class displays a legend box (TPaveText) containing several legend entries.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
void Draw(Option_t *option="") override
Draw this legend with its current attributes.
void SetMargin(Float_t margin)
Use the TLine constructor to create a simple line.
Double_t maxSignificanceErr
void UpdateSignificanceHists()
TGTextButton * fCloseButton
void ReadHistograms(TFile *file)
virtual ~StatDialogMVAEffs()
void PrintResults(const MethodInfo *info)
TGHorizontalFrame * fButtons
StatDialogMVAEffs(TString ds, const TGWindow *p, Float_t ns, Float_t nb)
TGNumberEntry * fSigInput
TGTextButton * fDrawButton
TString GetLatexFormula()
TGNumberEntry * fBkgInput
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
void Modified(Bool_t flag=1) override
virtual void SetBorderSize(Int_t bordersize=4)
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
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.
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TStyle objects may be created to define special styles.
void SetLineStyleString(Int_t i, const char *text)
Set line style string using the PostScript convention.
virtual void SetText(Double_t x, Double_t y, const char *text)
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
void Initialize(Bool_t useTMVAStyle=kTRUE)
void GetMethodTitle(TString &name, TKey *ikey)
void SetSignalAndBackgroundStyle(TH1 *sig, TH1 *bkg, TH1 *all=nullptr)
TFile * OpenFile(const TString &fin)
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
void GetMethodName(TString &name, TKey *mkey)
void imgconv(TCanvas *c, const TString &fname)
void mvaeffs(TString dataset, TString fin="TMVA.root", Float_t nSignal=1000, Float_t nBackground=1000, Bool_t useTMVAStyle=kTRUE, TString formula="S/sqrt(S+B)")