13 void TMVA::correlationscatters(TString dataset, TString fin , TString var,
14 TString dirName_, TString ,
19 TMVAGlob::Initialize( useTMVAStyle );
21 TString extension = dirName_;
22 extension.ReplaceAll(
"InputVariables",
"" );
23 extension.ReplaceAll(
" ",
"" );
24 if (extension ==
"") extension =
"_Id";
26 var.ReplaceAll( extension,
"" );
27 cout <<
"Called macro \"correlationscatters\" for variable: \"" << var
28 <<
"\", transformation type \"" << dirName_
29 <<
"\" (extension: \"" << extension <<
"\")" << endl;
32 TFile* file = TMVAGlob::OpenFile( fin );
34 TString dirName = dirName_ +
"/CorrelationPlots";
37 TDirectory* vardir = (TDirectory*)file->GetDirectory(dataset.Data())->Get(
"InputVariables_Id");
39 cout <<
"ERROR: no such directory: \"InputVariables\"" << endl;
42 Int_t noVars = TMVAGlob::GetNumberOfInputVariables( vardir );
44 TDirectory* dir = (TDirectory*)file->GetDirectory(dataset.Data())->Get( dirName );
46 cout <<
"No information about " << extension <<
" available in " << fin << endl;
51 TListIter keyIt(dir->GetListOfKeys());
52 Int_t noPlots = noVars - 1;
54 cout <<
"noPlots: " << noPlots <<
" --> noVars: " << noVars << endl;
55 if (noVars != Int_t(noVars)) {
56 cout <<
"*** Warning: problem in inferred number of variables ... not an integer *** " << endl;
67 xPad = 1; yPad = 1; width = 400; height = width;
break;
69 xPad = 2; yPad = 1; width = 700; height = 0.55*width;
break;
71 xPad = 3; yPad = 1; width = 800; height = 0.4*width;
break;
73 xPad = 2; yPad = 2; width = 600; height = width;
break;
75 xPad = 3; yPad = 2; width = 800; height = 0.55*width;
break;
77 Int_t noPadPerCanv = xPad * yPad ;
80 Int_t countCanvas = 0;
83 TString thename[2] = {
"_Signal",
"_Background" };
84 if (isRegression) thename[0] =
"_Regression";
85 for (UInt_t itype = 0; itype < 2; itype++) {
87 TIter next(gDirectory->GetListOfKeys());
93 while ( (key = (TKey*)next()) ) {
95 if (key->GetCycle() != 1)
continue;
98 TClass *cl = gROOT->GetClass(key->GetClassName());
99 if (!cl->InheritsFrom(
"TH1"))
continue;
100 TH1 *scat = (TH1*)key->ReadObj();
101 TString hname = scat->GetName();
104 if (! (hname.EndsWith( thename[itype] + extension ) &&
105 hname.Contains( TString(
"_") + var +
"_" ) && hname.BeginsWith(
"scat_")) ) {
113 if (countPad%noPadPerCanv==0) {
115 TString ext = extension; ext.Remove( 0, 1 );
116 canv =
new TCanvas( Form(
"canvas%d", countCanvas),
117 Form(
"Correlation profiles for '%s'-transformed %s variables",
118 ext.Data(), (isRegression ?
"" : (itype==0) ?
"signal" :
"background")),
119 countCanvas*50+200, countCanvas*20, width, height );
120 canv->Divide(xPad,yPad);
125 canv->cd(countPad++%noPadPerCanv+1);
128 TString bgname = hname;
129 bgname.ReplaceAll(
"scat_",
"prof_");
130 TH1 *prof = (TH1*)gDirectory->Get(bgname);
132 cout <<
"ERROR!!! couldn't find background histo for" << hname << endl;
137 TMVAGlob::SetSignalAndBackgroundStyle( scat, prof );
140 TMVAGlob::SetFrameStyle( scat, 1.2 );
143 scat->Scale( 1.0/scat->GetSumOfWeights() );
146 scat->SetMarkerColor( 4);
148 prof->SetMarkerColor( gConfig().fVariablePlotting.fUsePaperStyle ? 1 : 2 );
149 prof->SetMarkerSize( 0.2 );
150 prof->SetLineColor( gConfig().fVariablePlotting.fUsePaperStyle ? 1 : 2 );
151 prof->SetLineWidth( gConfig().fVariablePlotting.fUsePaperStyle ? 2 : 1 );
152 prof->SetFillStyle( 3002 );
153 prof->SetFillColor( 46 );
154 prof->Draw(
"samee1");
156 scat->Draw(
"sameaxis");
159 if (countPad%noPadPerCanv==0) {
162 TString fname = Form(
"%s/plots/correlationscatter_%s_%s_c%i",dataset.Data(),var.Data(), extension.Data(), countCanvas );
163 TMVAGlob::plot_logo();
164 TMVAGlob::imgconv( canv, fname );
167 if (countPad%noPadPerCanv!=0) {
170 TString fname = Form(
"%s/plots/correlationscatter_%s_%s_c%i",dataset.Data(),var.Data(), extension.Data(), countCanvas );
171 TMVAGlob::plot_logo();
172 TMVAGlob::imgconv( canv, fname );