Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
CorrGuiMultiClass.cxx
Go to the documentation of this file.
2 ///////////
3 //New Gui for easier plotting of scatter corelations
4 // L. Ancu 04/04/07
5 ////////////
6 #include <iostream>
7 
8 #include "TControlBar.h"
9 
10 
11 //static TControlBar* CorrGuiMultiClass_Global__cbar = 0;
12 
13 void TMVA::CorrGuiMultiClass(TString dataset, TString fin , TString dirName , TString title ,
14  Bool_t isRegression )
15 {
16  // Use this script in order to run the various individual macros
17  // that plot the output of TMVA (e.g. running TMVAnalysis.C),
18  // stored in the file "TMVA.root"
19  // for further documentation, look in the individual macros
20 
21  cout << "--- Open CorrGui for input file: " << fin << " and type: " << dirName << endl;
22 
23  // destroy all open cavases
24  TMVAGlob::DestroyCanvases();
25 
26  TString extension = dirName;
27  extension.ReplaceAll( "InputVariables", "" );
28 
29  // create the control bar
30  TControlBar* cbar = new TControlBar( "vertical", title, 50, 50 );
31  // CorrGuiMultiClass_Global__cbar = cbar;
32 
33  const char* buttonType = "button";
34 
35  // configure buttons
36  // checks if file with name "fin" is already open, and if not opens one
37  TFile* file = TMVAGlob::OpenFile( fin );
38 
39  TDirectory* dir = (TDirectory*)file->GetDirectory(dataset.Data())->Get( dirName );
40  if (!dir) {
41  cout << "Could not locate directory '" << dirName << "' in file: " << fin << endl;
42  return;
43  }
44  dir->cd();
45 
46  // how many variables are in the directory?
47  std::vector<TString> names(TMVAGlob::GetInputVariableNames(dir));
48  cout << "found number of variables='" << names.end() - names.begin() << endl;
49 
50  std::vector<TString>::const_iterator iter = names.begin();
51  for (; iter != names.end(); ++iter) {
52  cbar->AddButton( Form( " Variable: %s ", (*iter).Data()),
53  Form( "TMVA::correlationscattersMultiClass(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%i)",
54  dataset.Data(), fin.Data(), (*iter).Data(), dirName.Data(), title.Data(), (Int_t)isRegression ),
55  buttonType );
56  }
57 
58  // set the style
59  cbar->SetTextColor("blue");
60 
61  // there seems to be a bug in ROOT: font jumps back to default after pressing on >2 different buttons
62  // cbar->SetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
63 
64  // draw
65  cbar->Show();
66 
67  gROOT->SaveContext();
68 
69 }
70 
71 void TMVA::CorrGuiMultiClass_DeleteTBar()
72 {
73  TMVAGlob::DestroyCanvases();
74 
75  // delete CorrGuiMultiClass_Global__cbar;
76  // CorrGuiMultiClass_Global__cbar = 0;
77 }
78