10 void TMVA::variables(TString dataset, TString fin, TString dirName , TString title ,
11 Bool_t isRegression, Bool_t useTMVAStyle )
13 TString outfname = dirName;
14 outfname.ToLower(); outfname.ReplaceAll(
"input",
"" );
17 TMVAGlob::Initialize( useTMVAStyle );
20 TString htitle = title;
21 htitle.ReplaceAll(
"variables ",
"variable");
22 htitle.ReplaceAll(
"and target(s)",
"");
23 htitle.ReplaceAll(
"(training sample)",
"");
26 TFile* file = TMVAGlob::OpenFile( fin );
28 TDirectory* dir = (TDirectory*)file->GetDirectory(dataset.Data())->Get(dirName );
30 cout <<
"No information about " << title <<
" available in directory " << dirName <<
" of file " << fin << endl;
36 Int_t noPlots = TMVAGlob::GetNumberOfInputVariables( dir ) +
37 TMVAGlob::GetNumberOfTargets( dir );
47 xPad = 1; yPad = 1; width = 550; height = 0.90*width;
break;
49 xPad = 2; yPad = 1; width = 600; height = 0.50*width;
break;
51 xPad = 3; yPad = 1; width = 900; height = 0.4*width;
break;
53 xPad = 2; yPad = 2; width = 600; height = width;
break;
55 xPad = 3; yPad = 2; width = 800; height = 0.55*width;
break;
58 Int_t noPadPerCanv = xPad * yPad ;
61 Int_t countCanvas = 0;
67 Bool_t createNewFig = kFALSE;
68 TIter next(dir->GetListOfKeys());
69 while ((key = (TKey*)next())) {
70 if (key->GetCycle() != 1)
continue;
72 if (!TString(key->GetName()).Contains(
"__Signal") &&
73 !(isRegression && TString(key->GetName()).Contains(
"__Regression")))
continue;
76 TClass *cl = gROOT->GetClass(key->GetClassName());
77 if (!cl->InheritsFrom(
"TH1"))
continue;
78 TH1 *sig = (TH1*)key->ReadObj();
79 TString hname(sig->GetName());
82 if (countPad%noPadPerCanv==0) {
84 canv =
new TCanvas( Form(
"canvas%d", countCanvas), title,
85 countCanvas*50+50, countCanvas*20, width, height );
86 canv->Divide(xPad,yPad);
90 TPad* cPad = (TPad*)canv->cd(countPad++%noPadPerCanv+1);
93 TString bgname = hname;
94 bgname.ReplaceAll(
"__Signal",
"__Background");
95 TH1 *bgd = (TH1*)dir->Get(bgname);
97 cout <<
"ERROR!!! couldn't find background histo for" << hname << endl;
102 TMVAGlob::SetSignalAndBackgroundStyle( sig, (isRegression ? 0 : bgd) );
104 sig->SetTitle( TString( htitle ) +
": " + sig->GetTitle() );
105 TMVAGlob::SetFrameStyle( sig, 1.2 );
108 if (!isRegression) TMVAGlob::NormalizeHists( sig, bgd );
111 TString nme = sig->GetName();
112 if (nme.Contains(
"_target" )) {
113 TString tit = sig->GetTitle();
114 sig->SetTitle( tit.ReplaceAll(
"Input variable",
"Regression target" ) );
120 if (countPad == 1) sc = 1.3;
121 sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
123 cPad->SetLeftMargin( 0.17 );
125 sig->GetYaxis()->SetTitleOffset( 1.70 );
127 bgd->Draw(
"histsame");
128 TString ytit = TString(
"(1/N) ") + sig->GetYaxis()->GetTitle();
129 sig->GetYaxis()->SetTitle( ytit );
133 if (countPad == 1 && !isRegression) {
134 TLegend *legend=
new TLegend( cPad->GetLeftMargin(),
135 1-cPad->GetTopMargin()-.15,
136 cPad->GetLeftMargin()+.4,
137 1-cPad->GetTopMargin() );
138 legend->SetFillStyle(1);
139 legend->AddEntry(sig,
"Signal",
"F");
140 legend->AddEntry(bgd,
"Background",
"F");
141 legend->SetBorderSize(1);
142 legend->SetMargin( 0.3 );
143 legend->Draw(
"same");
147 sig->Draw(
"sameaxis");
150 Int_t nbin = sig->GetNbinsX();
151 Double_t dxu = sig->GetBinWidth(0);
152 Double_t dxo = sig->GetBinWidth(nbin+1);
155 uoflow = Form(
"U/O-flow: %.1f%% / %.1f%%",
156 sig->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100 );
159 uoflow = Form(
"U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%",
160 sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100,
161 sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 );
164 TText* t =
new TText( 0.98, 0.14, uoflow );
166 t->SetTextSize( 0.040 );
167 t->SetTextAngle( 90 );
171 if (countPad%noPadPerCanv==0) {
172 TString fname = Form(
"%s/plots/%s_c%i",dataset.Data(), outfname.Data(), countCanvas );
173 TMVAGlob::plot_logo();
174 TMVAGlob::imgconv( canv, fname );
175 createNewFig = kFALSE;
178 createNewFig = kTRUE;
183 TString fname = Form(
"%s/plots/%s_c%i",dataset.Data(), outfname.Data(), countCanvas );
184 TMVAGlob::plot_logo();
185 TMVAGlob::imgconv( canv, fname );
186 createNewFig = kFALSE;