30 TDirectory *tempdir = 0;
31 while ((key = (TKey *)keys_dir())) {
33 if (
name.BeginsWith(
"InputVariables_")) {
44 const Int_t width = 600;
50 Int_t countCanvas = 0;
55 while ((key = (TKey*)next())) {
57 if (!TString(key->
GetName()).BeginsWith(
"Method_"))
continue;
63 TDirectory* mDir = (TDirectory*)key->
ReadObj();
67 while ((titkey = (TKey*)keyIt())) {
69 if (!
gROOT->GetClass(titkey->
GetClassName())->InheritsFrom(
"TDirectory"))
continue;
71 TDirectory *titDir = (TDirectory *)titkey->
ReadObj();
75 cout <<
"--- Found directory for method: " << methodName <<
"::" << methodTitle << endl;
76 TString hname =
"MVA_" + methodTitle;
77 for(
UInt_t icls = 0; icls < classnames.size(); ++icls){
80 std::vector<TString>::iterator classiter = classnames.begin();
81 for(; classiter!=classnames.end(); ++classiter){
82 TString
name(hname+
"_Test_"+ classnames.at(icls)
83 +
"_prob_for_" + *classiter);
84 TH1 *hist = (TH1*)titDir->
Get(
name);
86 cout <<
":\t mva distribution not available (this is normal for Cut classifier)" << endl;
98 TString ctitle = ((htype ==
kMVAType) ?
99 TString::Format(
"TMVA response for class %s %s", classnames.at(icls).Data(),methodTitle.
Data()) :
100 TString::
Format(
"TMVA comparison for class %s %s", classnames.at(icls).Data(),methodTitle.Data())) ;
103 countCanvas*50+200, countCanvas*20, width, (
Int_t)width*0.78 );
113 if(((TH1*)hists[i])->GetMaximum() > histmax)
114 histmax = ((TH1*)hists[i])->GetMaximum();
125 TString hFrameName(
TString::Format(
"frame_class%d_",icls) + methodTitle);
126 TObject *o =
gROOT->FindObject(hFrameName);
128 TH1F* frame =
new TH1F( hFrameName, ((TH1*)hists.
First())->GetTitle(),
132 frame->
GetXaxis()->
SetTitle(methodTitle +
" response for " + classnames.at(icls));
139 c->GetPad(0)->SetLeftMargin( 0.105 );
143 TLegend *legend=
new TLegend(
c->GetLeftMargin(), 1 -
c->GetTopMargin() - 0.12,
144 c->GetLeftMargin() + (htype == kCompareType ? 0.40 : 0.3), 1 -
c->GetTopMargin() );
146 classiter = classnames.begin();
149 legend->
AddEntry(((TH1*)hists[i]),*classiter,
"F");
154 legend->
Draw(
"same");
159 ((TH1*)hists[i])->Draw(
"histsame");
160 TString ytit = TString(
"(1/N) ") + ((TH1*)hists[i])->GetYaxis()->GetTitle();
161 ((TH1*)hists[i])->GetYaxis()->SetTitle( ytit );
166 if (htype == kCompareType) {
170 classiter = classnames.begin();
171 for(; classiter!=classnames.end(); ++classiter){
172 TString
name(hname+
"_Train_"+ classnames.at(icls)
173 +
"_prob_for_" + *classiter);
174 TH1 *hist = (TH1*)titDir->
Get(
name);
176 cout <<
":\t comparison histogram for overtraining check not available!" << endl;
182 TLegend *legend2=
new TLegend( 1 -
c->GetRightMargin() - 0.42, 1 -
c->GetTopMargin() - 0.12,
183 1 -
c->GetRightMargin(), 1 -
c->GetTopMargin() );
187 classiter = classnames.begin();
189 legend2->
AddEntry(((TH1*)othists[i]),*classiter+
" (training sample)",
"P");
192 legend2->
Draw(
"same");
197 if(((TH1*)othists[i])->GetMaximum() > histmax)
198 histmax = ((TH1*)othists[i])->GetMaximum();
203 Int_t col = ((TH1*)hists[i])->GetLineColor();
204 ((TH1*)othists[i])->SetMarkerSize( 0.7 );
205 ((TH1*)othists[i])->SetMarkerStyle( 20 );
206 ((TH1*)othists[i])->SetMarkerColor( col );
207 ((TH1*)othists[i])->SetLineWidth( 1 );
208 ((TH1*)othists[i])->Draw(
"e1same");
211 ymax = histmax*maxMult;
217 ((TH1*)hists[i])->SetLineWidth( 1 );
223 cout <<
"--- Perform Kolmogorov-Smirnov tests" << endl;
224 cout <<
"--- Goodness of consistency for class " << classnames.at(icls)<< endl;
227 Float_t kol = ((TH1*)hists[j])->KolmogorovTest(((TH1*)othists[j]),
"X");
228 cout << classnames.at(j) <<
": " << kol << endl;
241 frame->
Draw(
"sameaxis");
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).
float Float_t
Float 4 bytes (float).
static char * Format(const char *format, va_list ap)
Format a string in a circular formatting buffer (using a printf style format descriptor).
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory") override
Find a directory using apath.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual TList * GetListOfKeys() const
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 const char * GetClassName() const
virtual TObject * ReadObj()
To read a TObject* from the file.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
void Draw(Option_t *option="") override
Draw this box with its current attributes.
void SetMargin(Float_t margin)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
Int_t GetEntriesFast() const
TObject * First() const override
Return the object in the first slot.
void Add(TObject *obj) override
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Initialize(Bool_t useTMVAStyle=kTRUE)
void GetMethodTitle(TString &name, TKey *ikey)
void plot_logo(Float_t v_scale=1.0, Float_t skew=1.0)
TFile * OpenFile(const TString &fin)
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
void GetMethodName(TString &name, TKey *mkey)
void SetMultiClassStyle(TObjArray *hists)
void NormalizeHist(TH1 *h)
std::vector< TString > GetClassNames(TDirectory *dir)
void imgconv(TCanvas *c, const TString &fname)
void mvasMulticlass(TString dataset, TString fin="TMVAMulticlass.root", HistType htype=kMVAType, Bool_t useTMVAStyle=kTRUE)