46 TString pname =
"purS_" + 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);
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();
99 if ( ( pos > 0 && !
TString(
f[pos-1]).IsAlpha() ) ||
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;
235 if (
info->canvas==0 ) {
239 TIter next(fInfoList);
241 info->canvas->Update();
242 info->rightAxis->SetWmax(1.1*
info->maxSignificance);
244 info->canvas->Update();
245 info->canvas->Paint();
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;
264 for (
Int_t i=1; i<=
info->origSigE->GetNbinsX(); i++) {
267 Float_t B =
info->origBgdE->GetBinContent( i ) * fNBackground;
268 info->purS->SetBinContent( i, (S+B==0)?0:S/(S+B) );
273 if (GetFormulaString() ==
"S/sqrt(B)") {
274 maxSigErr = sig * sqrt( 1./S + 1./(2.*B));
277 info->sSig->SetBinContent( i, sig );
278 info->effpurS->SetBinContent( i,
eS*
info->purS->GetBinContent( i ) );
281 info->maxSignificance =
info->sSig->GetMaximum();
283 info->sSig->Scale(1/
info->maxSignificance);
286 PrintResults(
info );
288 cout <<
"--- " << setfill(
'-') << setw(str.Length()) <<
"" << setfill(
' ') << endl << endl;
294 TIter next(fInfoList);
302 fInfoList =
new TList;
307 while( (key = (
TKey*)next()) ) {
310 if( !
gROOT->GetClass(key->
GetClassName())->InheritsFrom(
"TDirectory") )
continue;
312 cout <<
"--- Found directory: " << ((
TDirectory*)key->
ReadObj())->GetName() << endl;
319 if( !
gROOT->GetClass(
titkey->GetClassName())->InheritsFrom(
"TDirectory") )
continue;
326 if (
info->methodTitle.Length() > maxLenTitle) maxLenTitle =
info->methodTitle.Length();
329 cout <<
"--- Classifier: " <<
info->methodTitle << endl;
335 if (
info->origSigE==0 ||
info->origBgdE==0) {
delete info;
continue; }
337 info->SetResultHists();
338 fInfoList->Add(
info);
353 TIter next(fInfoList);
369 TMVAStyle->SetLineStyleString( 5,
"[32 22]" );
370 TMVAStyle->SetLineStyleString( 6,
"[12 22]" );
375 info->effpurS->SetTitle(
"Cut efficiencies and optimal cut value");
376 if (
info->methodTitle.Contains(
"Cuts")) {
377 info->effpurS->GetXaxis()->SetTitle(
"Signal Efficiency" );
380 info->effpurS->GetXaxis()->SetTitle(
TString(
"Cut value applied on ") +
info->methodTitle +
" output" );
382 info->effpurS->GetYaxis()->SetTitle(
"Efficiency (Purity)" );
386 c->SetRightMargin ( 2.0 );
388 info->effpurS->SetMaximum(1.1);
389 info->effpurS->Draw(
"histl");
391 info->purS->Draw(
"samehistl");
394 info->sigE->Draw(
"samehistl");
395 info->bgdE->Draw(
"samehistl");
398 info->sSig->Draw(
"samehistl");
401 info->effpurS->Draw(
"sameaxis" );
405 c->GetLeftMargin() + 0.4, 1 -
c->GetTopMargin() + 0.12 );
407 legend1->AddEntry(
info->sigE,
"Signal efficiency",
"L");
408 legend1->AddEntry(
info->bgdE,
"Background efficiency",
"L");
414 1 -
c->GetRightMargin(), 1 -
c->GetTopMargin() + 0.12 );
417 legend2->AddEntry(
info->effpurS,
"Signal efficiency*purity",
"L");
418 legend2->AddEntry(
info->sSig,GetLatexFormula().Data(),
"L");
432 tl.SetTextSize( 0.033 );
434 info->line1 =
tl.DrawLatex( 0.15, 0.23,
TString::Format(
"For %1.0f signal and %1.0f background", fNSignal, fNBackground));
435 tl.DrawLatex( 0.15, 0.19,
"events the maximum "+GetLatexFormula()+
" is");
437 if (
info->maxSignificanceErr > 0) {
439 info->maxSignificance,
440 info->maxSignificanceErr,
441 info->sSig->GetXaxis()->GetBinCenter(
maxbin)) );
445 info->maxSignificance,
446 info->sSig->GetXaxis()->GetBinCenter(
maxbin)) );
450 if (
info->methodTitle.Contains(
"Cuts")){
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.");
458 info->rightAxis =
new TGaxis(
c->GetUxmax(),
c->GetUymin(),
459 c->GetUxmax(),
c->GetUymax(),0,1.1*
info->maxSignificance,510,
"+L");
464 info->rightAxis->SetTitleSize(
info->sSig->GetXaxis()->GetTitleSize() );
465 info->rightAxis->SetTitle(
"Significance" );
466 info->rightAxis->Draw();
483 if (
info->line1 !=0 )
484 info->line1->SetText( 0.15, 0.23,
TString::Format(
"For %1.0f signal and %1.0f background", fNSignal, fNBackground));
486 if (
info->line2 !=0 ) {
487 if (
info->maxSignificanceErr > 0) {
489 info->maxSignificance,
490 info->maxSignificanceErr,
491 info->sSig->GetXaxis()->GetBinCenter(
maxbin)) );
495 info->sSig->GetXaxis()->GetBinCenter(
maxbin)) );
500 if (
info->maxSignificanceErr <= 0) {
505 info->methodTitle.Data(), fNSignal, fNBackground,
506 info->sSig->GetXaxis()->GetBinCenter(
maxbin ),
507 info->maxSignificance,
508 info->origSigE->GetBinContent(
maxbin )*fNSignal,
509 info->origBgdE->GetBinContent(
maxbin )*fNBackground,
515 TString opt =
TString::Format(
"%%%is: (%%9.8g,%%9.8g) %%9.4f (%%8.3g +-%%6.3g) %%8.7g %%8.7g %%8.4g %%8.4g",
519 info->methodTitle.Data(), fNSignal, fNBackground,
520 info->sSig->GetXaxis()->GetBinCenter(
maxbin ),
521 info->maxSignificance,
522 info->maxSignificanceErr,
523 info->origSigE->GetBinContent(
maxbin )*fNSignal,
524 info->origBgdE->GetBinContent(
maxbin )*fNBackground,
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,
553 gGui->ReadHistograms(file);
554 gGui->SetFormula(formula);
555 gGui->UpdateSignificanceHists();
556 gGui->DrawHistograms();
557 if (!
gROOT->IsBatch())
gGui->RaiseDialog();
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory") override
Find a directory named "apath".
Describe directory structure in memory.
virtual TList * GetListOfKeys() const
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
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.
This class displays a legend box (TPaveText) containing several legend entries.
Use the TLine constructor to create a simple line.
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
const char * GetName() const override
Returns name of object.
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.
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.
TStyle objects may be created to define special styles.
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)")