17 #include "TDirectory.h" 38 static Int_t
c_Canvas = TColor::GetColor(
"#e9e6da" );
54 Int_t FillStyle__S = 1001;
56 Int_t LineWidth__S = 2;
61 Int_t FillStyle__B = 3554;
63 Int_t LineWidth__B = 2;
66 sig->SetLineColor( LineColor__S );
67 sig->SetLineWidth( LineWidth__S );
68 sig->SetFillStyle( FillStyle__S );
69 sig->SetFillColor( FillColor__S );
73 bkg->SetLineColor( LineColor__B );
74 bkg->SetLineWidth( LineWidth__B );
75 bkg->SetFillStyle( FillStyle__B );
76 bkg->SetFillColor( FillColor__B );
80 all->SetLineColor( LineColor__S );
81 all->SetLineWidth( LineWidth__S );
82 all->SetFillStyle( FillStyle__S );
83 all->SetFillColor( FillColor__S );
90 frame->SetLabelOffset( 0.012,
"X" );
91 frame->SetLabelOffset( 0.012,
"Y" );
92 frame->GetXaxis()->SetTitleOffset( 1.25 );
93 frame->GetYaxis()->SetTitleOffset( 1.22 );
94 frame->GetXaxis()->SetTitleSize( 0.045*
scale );
95 frame->GetYaxis()->SetTitleSize( 0.045*
scale );
96 Float_t labelSize = 0.04*
scale;
97 frame->GetXaxis()->SetLabelSize( labelSize );
98 frame->GetYaxis()->SetLabelSize( labelSize );
102 gPad->SetLeftMargin ( 0.108*
scale );
103 gPad->SetRightMargin ( 0.050*
scale );
104 gPad->SetBottomMargin( 0.120*
scale );
109 TStyle *TMVAStyle = gROOT->GetStyle(
"TMVA");
111 gROOT->SetStyle(
"TMVA");
115 TMVAStyle =
new TStyle(*gROOT->GetStyle(
"Plain"));
116 TMVAStyle->SetName(
"TMVA");
117 TMVAStyle->SetTitle(
"TMVA style based on \"Plain\" with modifications defined in tmvaglob.C");
118 gROOT->GetListOfStyles()->Add(TMVAStyle);
119 gROOT->SetStyle(
"TMVA");
121 TMVAStyle->SetLineStyleString( 5,
"[52 12]" );
122 TMVAStyle->SetLineStyleString( 6,
"[22 12]" );
123 TMVAStyle->SetLineStyleString( 7,
"[22 10 7 10]" );
126 TMVAStyle->SetPalette((UsePaperStyle ? 18 : 1),0);
129 TMVAStyle->SetFrameBorderMode(0);
130 TMVAStyle->SetCanvasBorderMode(0);
131 TMVAStyle->SetPadBorderMode(0);
132 TMVAStyle->SetPadColor(0);
133 TMVAStyle->SetFillStyle(0);
135 TMVAStyle->SetLegendBorderSize(0);
142 TMVAStyle->SetTitleFillColor( c_TitleBox );
143 if (!UsePaperStyle) {
144 TMVAStyle->SetFrameFillColor( c_FrameFill );
145 TMVAStyle->SetCanvasColor( c_Canvas );
149 TMVAStyle->SetPaperSize(20,26);
150 TMVAStyle->SetPadTopMargin(0.10);
151 TMVAStyle->SetPadRightMargin(0.05);
152 TMVAStyle->SetPadBottomMargin(0.11);
153 TMVAStyle->SetPadLeftMargin(0.12);
156 TMVAStyle->SetMarkerStyle(21);
157 TMVAStyle->SetMarkerSize(0.3);
158 TMVAStyle->SetHistLineWidth(2);
159 TMVAStyle->SetLineStyleString(2,
"[12 12]");
162 TMVAStyle->SetOptTitle(1);
163 TMVAStyle->SetTitleH(0.052);
165 TMVAStyle->SetOptStat(0);
166 TMVAStyle->SetOptFit(0);
169 TMVAStyle->SetPadTickX(1);
170 TMVAStyle->SetPadTickY(1);
177 TList*
loc = (TList*)gROOT->GetListOfCanvases();
180 while ((o = itc()))
delete o;
191 gROOT->SetStyle(
"Plain");
192 gStyle->SetOptStat(0);
202 TFile*
file = gDirectory->GetFile();
203 if (file==0 || fin != file->GetName()) {
208 cout <<
"--- Opening root file " << fin <<
" in read mode" <<
endl;
209 file = TFile::Open( fin,
"READ" );
212 file = gDirectory->GetFile();
224 cout <<
"*** Error in TMVAGlob::imgconv: canvas is NULL" <<
endl;
229 TString
dir = f.Remove( f.Last(
'/' ), f.Length() - f.Last(
'/' ) );
230 gSystem->mkdir( dir );
232 TString pngName = fname +
".png";
233 TString gifName = fname +
".gif";
234 TString epsName = fname +
".eps";
242 cout <<
"--- --------------------------------------------------------------------" <<
endl;
243 cout <<
"--- If you want to save the image as eps, gif or png, please comment out " <<
endl;
244 cout <<
"--- the corresponding lines (line no. 239-241) in tmvaglob.C" <<
endl;
245 cout <<
"--- --------------------------------------------------------------------" <<
endl;
256 TString macroPath(gROOT->GetMacroPath());
260 Ssiz_t pathStart = curIndex;
261 curIndex = macroPath.Index(
":",curIndex);
262 Ssiz_t pathEnd = (curIndex==-1)?macroPath.Length():curIndex;
263 TString
path(macroPath(pathStart,pathEnd-pathStart));
265 gSystem->ExpandPathName(path);
266 const char* fullName = Form(
"%s/%s", path.Data(), imageName);
268 Bool_t fileFound = ! gSystem->AccessPathName(fullName);
271 img = TImage::Open(fullName);
274 if(curIndex==-1)
break;
280 void plot_logo( Float_t v_scale = 1.0, Float_t skew = 1.0 )
285 cout <<
"+++ Could not open image tmva_logo.gif" <<
endl;
289 img->SetConstRatio(kFALSE);
290 UInt_t h_ = img->GetHeight();
291 UInt_t w_ = img->GetWidth();
295 Float_t
rpad = Double_t(gPad->VtoAbsPixel(0) - gPad->VtoAbsPixel(1))/(gPad->UtoAbsPixel(1) - gPad->UtoAbsPixel(0));
300 Float_t x1R = 1 - gStyle->GetPadRightMargin();
301 Float_t y1B = 1 - gStyle->GetPadTopMargin()+.01;
303 Float_t x1L = x1R - d*r/skew;
304 Float_t y1T = y1B + d*v_scale*skew;
305 if (y1T>0.99) y1T = 0.99;
307 TPad *
p1 =
new TPad(
"imgpad",
"imgpad", x1L, y1B, x1R, y1T );
308 p1->SetRightMargin(0);
309 p1->SetBottomMargin(0);
310 p1->SetLeftMargin(0);
314 Int_t xSizeInPixel = p1->UtoAbsPixel(1) - p1->UtoAbsPixel(0);
315 Int_t ySizeInPixel = p1->VtoAbsPixel(0) - p1->VtoAbsPixel(1);
316 if (xSizeInPixel<=25 || ySizeInPixel<=25) {
328 if (h->GetSumw2N() == 0) h->Sumw2();
329 if(h->GetSumOfWeights()!=0) {
330 Float_t
dx = (h->GetXaxis()->GetXmax() - h->GetXaxis()->GetXmin())/h->GetNbinsX();
331 h->Scale( 1.0/h->GetSumOfWeights()/
dx );
336 if (sig->GetSumw2N() == 0) sig->Sumw2();
337 if (
bkg &&
bkg->GetSumw2N() == 0)
bkg->Sumw2();
339 if(sig->GetSumOfWeights()!=0) {
340 Float_t
dx = (sig->GetXaxis()->GetXmax() - sig->GetXaxis()->GetXmin())/sig->GetNbinsX();
341 sig->Scale( 1.0/sig->GetSumOfWeights()/
dx );
343 if (
bkg != 0 &&
bkg->GetSumOfWeights()!=0) {
344 Float_t
dx = (
bkg->GetXaxis()->GetXmax() -
bkg->GetXaxis()->GetXmin())/
bkg->GetNbinsX();
345 bkg->Scale( 1.0/
bkg->GetSumOfWeights()/
dx );
354 name = mkey->GetName();
355 name.ReplaceAll(
"Method_",
"");
360 name = ikey->GetName();
365 name = mdir->GetName();
366 name.ReplaceAll(
"Method_",
"");
371 name = idir->GetName();
374 TKey *
NextKey( TIter & keyIter, TString className) {
375 TKey *
key=(TKey *)keyIter.Next();
377 Bool_t loop=(key!=0);
380 TClass *cl = gROOT->GetClass(key->GetClassName());
381 if (cl->InheritsFrom(className.Data())) {
385 key = (TKey *)keyIter.Next();
386 if (key==0) loop = kFALSE;
396 if (
dir==0)
dir = gDirectory;
397 TIter mnext(
dir->GetListOfKeys());
400 keys.SetOwner(kFALSE);
402 while ((mkey = (TKey*)mnext())) {
404 TClass *cl = gROOT->GetClass(mkey->GetClassName());
405 if (cl->InheritsFrom(inherits)) {
415 TIter
next(dir->GetListOfKeys());
419 while ((key = (TKey*)
next())) {
420 if (key->GetCycle() != 1)
continue;
421 if (TString(key->GetName()).Contains(
"__Regression_target")) noTrgts++;
428 TIter
next(dir->GetListOfKeys());
432 while ((key = (TKey*)
next())) {
433 if (key->GetCycle() != 1)
continue;
436 if (TString(key->GetName()).Contains(
"__Signal") || (TString(key->GetName()).Contains(
"__Regression") && !(TString(key->GetName()).Contains(
"__Regression_target")))) noVars++;
445 if (
dir==0)
dir = gDirectory;
446 TIter mnext(
dir->GetListOfKeys());
451 mkey = (TKey*)mnext();
456 TString clname = mkey->GetClassName();
457 TClass *cl = gROOT->GetClass(clname);
458 if (cl->InheritsFrom(
"TDirectory")) {
459 TString mname = mkey->GetName();
474 if (
dir==0)
dir = gDirectory;
475 TIter mnext(
dir->GetListOfKeys());
479 mkey = (TKey*)mnext();
484 TString clname = mkey->GetClassName();
485 TString keyname = mkey->GetName();
486 TClass *cl = gROOT->GetClass(clname);
487 if (keyname.Contains(
"Method") && cl->InheritsFrom(
"TDirectory")) {
489 TDirectory* d_ = (TDirectory*)
dir->Get( keyname );
491 cout <<
"HUUUGE TROUBLES IN TMVAGlob::ExistMethodName() --> contact authors" <<
endl;
495 TIter mnext_(d_->GetListOfKeys());
497 while ((mkey_ = (TKey*)mnext_())) {
498 TString clname_ = mkey_->GetClassName();
499 TClass *cl_ = gROOT->GetClass(clname_);
500 if (cl_->InheritsFrom(
"TDirectory")) {
501 TString mname = mkey_->GetName();
517 if (
dir==0)
dir = gDirectory;
518 TIter mnext(
dir->GetListOfKeys());
521 methods.SetOwner(kFALSE);
523 while ((mkey = (TKey*)mnext())) {
525 TString
name = mkey->GetClassName();
526 TClass *cl = gROOT->GetClass(name);
527 if (cl->InheritsFrom(
"TDirectory")) {
528 if (TString(mkey->GetName()).BeginsWith(
"Method_")) {
534 cout <<
"--- Found " << ni <<
" classifier types" <<
endl;
542 TIter
next(file->GetListOfKeys());
544 while ((key = (TKey*)
next())) {
546 if (TString(key->GetName()).BeginsWith(
"Method_")) {
547 if (gROOT->GetClass(key->GetClassName())->InheritsFrom(
"TDirectory")) {
549 TDirectory* mDir = (TDirectory*)key->ReadObj();
551 TIter keyIt(mDir->GetListOfKeys());
553 while ((jobkey = (TKey*)keyIt())) {
554 if (!gROOT->GetClass(jobkey->GetClassName())->InheritsFrom(
"TDirectory"))
continue;
556 TDirectory *jobDir = (TDirectory *)jobkey->ReadObj();
557 cout <<
"jobdir name " << jobDir->GetName() <<
endl;
563 return jobdirs.GetSize();
570 if (rfdir==0)
return 0;
571 TList *
keys = rfdir->GetListOfKeys();
573 cout <<
"+++ Directory '" << rfdir->GetName() <<
"' contains no keys" <<
endl;
577 TIter rfnext(rfdir->GetListOfKeys());
580 titles.SetOwner(kFALSE);
581 while ((rfkey = (TKey*)rfnext())) {
583 TClass *cl = gROOT->GetClass(rfkey->GetClassName());
584 if (cl->InheritsFrom(
"TDirectory")) {
589 cout <<
"--- Found " << ni <<
" instance(s) of the method " << rfdir->GetName() <<
endl;
599 if (
dir==0)
dir = gDirectory;
600 TDirectory* rfdir = (TDirectory*)
dir->Get( methodName );
602 cout <<
"+++ Could not locate directory '" << methodName <<
endl;
608 TList *
keys = rfdir->GetListOfKeys();
610 cout <<
"+++ Directory '" << methodName <<
"' contains no keys" <<
endl;
614 TIter rfnext(rfdir->GetListOfKeys());
617 titles.SetOwner(kFALSE);
618 while ((rfkey = (TKey*)rfnext())) {
620 TClass *cl = gROOT->GetClass(rfkey->GetClassName());
621 if (cl->InheritsFrom(
"TDirectory")) {
626 cout <<
"--- Found " << ni <<
" instance(s) of the method " << methodName <<
endl;
634 "InputVariables_Deco",
635 "InputVariables_PCA",
636 "InputVariables_Gauss_Deco" };
637 if (
dir==0)
dir = gDirectory;
640 dir = (TDirectory*)gDirectory->Get( directories[type] );
642 cout <<
"+++ Could not locate input variable directory '" << directories[
type] <<
endl;
652 if (
dir==0)
return 0;
654 TDirectory* corrdir = (TDirectory*)
dir->Get(
"CorrelationPlots" );
656 cout <<
"+++ Could not find CorrelationPlots directory 'CorrelationPlots'" <<
endl;
void GetMethodTitle(TString &name, TKey *ikey)
TImage * findImage(const char *imageName)
void NormalizeHist(TH1 *h)
void plot_logo(Float_t v_scale=1.0, Float_t skew=1.0)
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=0)
std::string rpad(std::string const &pad_me, std::string::size_type wanted_size, char char_to_pad_with= ' ')
void imgconv(TCanvas *c, const TString &fname)
void Initialize(Bool_t useTMVAStyle=kTRUE)
static Int_t c_SignalLine
Bool_t ExistMethodName(TString name, TDirectory *dir=0)
TDirectory * GetInputVariablesDir(TMVAGlob::TypeOfPlot type, TDirectory *dir=0)
TDirectory * GetCorrelationPlotsDir(TMVAGlob::TypeOfPlot type, TDirectory *dir=0)
static Int_t c_BackgroundLine
UInt_t GetListOfJobs(TFile *file, TList &jobdirs)
Int_t GetNumberOfInputVariables(TDirectory *dir)
static Int_t c_SignalFill
Int_t GetNumberOfTargets(TDirectory *dir)
static Int_t c_BackgroundFill
void GetMethodName(TString &name, TKey *mkey)
TFile * OpenFile(const TString &fin)
void SetSignalAndBackgroundStyle(TH1 *sig, TH1 *bkg, TH1 *all=0)
TKey * FindMethod(TString name, TDirectory *dir=0)
static Bool_t UsePaperStyle
TKey * NextKey(TIter &keyIter, TString className)
void NormalizeHists(TH1 *sig, TH1 *bkg=0)
UInt_t GetListOfKeys(TList &keys, TString inherits, TDirectory *dir=0)
UInt_t GetListOfTitles(TDirectory *rfdir, TList &titles)