00001 #include <iostream>
00002 #include <vector>
00003
00004 #include "TList.h"
00005 #include "TROOT.h"
00006 #include "TKey.h"
00007 #include "TString.h"
00008 #include "TControlBar.h"
00009 #include "TObjString.h"
00010
00011 #include "tmvaglob.C"
00012
00013
00014 static TList* TMVAGui_keyContent;
00015 static std::vector<TString> TMVAGui_inactiveButtons;
00016
00017 TList* GetKeyList( const TString& pattern )
00018 {
00019 TList* list = new TList();
00020
00021 TIter next( TMVAGui_keyContent );
00022 TKey* key(0);
00023 while ((key = (TKey*)next())) {
00024 if (TString(key->GetName()).Contains( pattern )) { list->Add( new TObjString( key->GetName() ) ); }
00025 }
00026 return list;
00027 }
00028
00029
00030 void ActionButton( TControlBar* cbar,
00031 const TString& title, const TString& macro, const TString& comment,
00032 const TString& buttonType, TString requiredKey = "")
00033 {
00034 cbar->AddButton( title, macro, comment, buttonType );
00035
00036
00037 if (requiredKey != "") {
00038 Bool_t found = kFALSE;
00039 TIter next( TMVAGui_keyContent );
00040 TKey* key(0);
00041 while ((key = (TKey*)next())) {
00042 if (TString(key->GetName()).Contains( requiredKey )) { found = kTRUE; break; }
00043 }
00044 if (!found) TMVAGui_inactiveButtons.push_back( title );
00045 }
00046 }
00047
00048
00049 void TMVAGui( const char* fName = "TMVA.root" )
00050 {
00051
00052
00053
00054
00055 TString curMacroPath(gROOT->GetMacroPath());
00056
00057 gROOT->SetMacroPath(curMacroPath+":./:$ROOTSYS/tmva/test/:");
00058
00059
00060
00061
00062
00063
00064 TString curIncludePath=gSystem->GetIncludePath();
00065 TString newIncludePath=TString("-I../ ")+curIncludePath;
00066 gSystem->SetIncludePath(newIncludePath);
00067
00068 cout << "--- Launch TMVA GUI to view input file: " << fName << endl;
00069
00070
00071 TMVAGui_inactiveButtons.clear();
00072
00073
00074 TFile* file = TFile::Open( fName );
00075 if (!file) {
00076 cout << "==> Abort TMVAGui, please verify filename" << endl;
00077 return;
00078 }
00079
00080 TMVAGui_keyContent = (TList*)file->GetListOfKeys()->Clone();
00081
00082
00083 file->Close();
00084
00085 TString defaultRequiredClassifier = "";
00086
00087
00088
00089
00090
00091 TControlBar* cbar = new TControlBar( "vertical", "TMVA Plotting Macros for Classification", 0, 0 );
00092
00093 const TString buttonType( "button" );
00094
00095
00096 Int_t ic = 1;
00097
00098
00099 TList* keylist = GetKeyList( "InputVariables" );
00100 TListIter it( keylist );
00101 TObjString* str = 0;
00102 char ch = 'a';
00103 while ((str = (TObjString*)it())) {
00104 TString tmp = str->GetString();
00105 TString title = Form( "Input variables '%s'-transformed (training sample)",
00106 tmp.ReplaceAll("InputVariables_","").Data() );
00107 if (tmp.Contains( "Id" )) title = "Input variables (training sample)";
00108 ActionButton( cbar,
00109 Form( "(%i%c) %s", ic, ch++, title.Data() ),
00110 Form( ".x variables.C(\"%s\",\"%s\",\"%s\")", fName, str->GetString().Data(), title.Data() ),
00111 Form( "Plots all '%s'-transformed input variables (macro variables.C(...))", str->GetString().Data() ),
00112 buttonType, str->GetString() );
00113 }
00114 ic++;
00115
00116
00117 it.Reset(); ch = 'a';
00118 while ((str = (TObjString*)it())) {
00119 TString tmp = str->GetString();
00120 TString title = Form( "Input variable correlations '%s'-transformed (scatter profiles)",
00121 tmp.ReplaceAll("InputVariables_","").Data() );
00122 if (tmp.Contains( "Id" )) title = "Input variable correlations (scatter profiles)";
00123 ActionButton( cbar,
00124 Form( "(%i%c) %s", ic, ch++, title.Data() ),
00125 Form( ".x CorrGui.C(\"%s\",\"%s\",\"%s\")", fName, str->GetString().Data(), title.Data() ),
00126 Form( "Plots all correlation profiles between '%s'-transformed input variables (macro CorrGui.C(...))",
00127 str->GetString().Data() ),
00128 buttonType, str->GetString() );
00129 }
00130
00131 TString title;
00132
00133 title =Form( "(%i) Input Variable Linear Correlation Coefficients", ++ic );
00134 ActionButton( cbar,
00135 title,
00136 Form( ".x correlations.C(\"%s\")", fName ),
00137 "Plots signal and background correlation summaries for all input variables (macro correlations.C)",
00138 buttonType );
00139
00140 title =Form( "(%ia) Classifier Output Distributions (test sample)", ++ic );
00141 ActionButton( cbar,
00142 title,
00143 Form( ".x mvas.C(\"%s\",0)", fName ),
00144 "Plots the output of each classifier for the test data (macro mvas.C(...,0))",
00145 buttonType, defaultRequiredClassifier );
00146
00147 title =Form( "(%ib) Classifier Output Distributions (test and training samples superimposed)", ic );
00148 ActionButton( cbar,
00149 title,
00150 Form( ".x mvas.C(\"%s\",3)", fName ),
00151 "Plots the output of each classifier for the test (histograms) and training (dots) data (macro mvas.C(...,3))",
00152 buttonType, defaultRequiredClassifier );
00153
00154 title = Form( "(%ic) Classifier Probability Distributions (test sample)", ic );
00155 ActionButton( cbar,
00156 title,
00157 Form( ".x mvas.C(\"%s\",1)", fName ),
00158 "Plots the probability of each classifier for the test data (macro mvas.C(...,1))",
00159 buttonType, defaultRequiredClassifier );
00160
00161 title =Form( "(%id) Classifier Rarity Distributions (test sample)", ic );
00162 ActionButton( cbar,
00163 title,
00164 Form( ".x mvas.C(\"%s\",2)", fName ),
00165 "Plots the Rarity of each classifier for the test data (macro mvas.C(...,2)) - background distribution should be uniform",
00166 buttonType, defaultRequiredClassifier );
00167
00168 title =Form( "(%ia) Classifier Cut Efficiencies", ++ic );
00169 ActionButton( cbar,
00170 title,
00171 Form( ".x mvaeffs.C+(\"%s\")", fName ),
00172 "Plots signal and background efficiencies versus cut on classifier output (macro mvaeffs.C)",
00173 buttonType, defaultRequiredClassifier );
00174
00175 title = Form( "(%ib) Classifier Background Rejection vs Signal Efficiency (ROC curve)", ic );
00176 ActionButton( cbar,
00177 title,
00178 Form( ".x efficiencies.C(\"%s\")", fName ),
00179 "Plots background rejection vs signal efficiencies (macro efficiencies.C) [\"ROC\" stands for \"Receiver Operation Characteristics\"]",
00180 buttonType, defaultRequiredClassifier );
00181
00182 title = Form( "(%i) Parallel Coordinates (requires ROOT-version >= 5.17)", ++ic );
00183 ActionButton( cbar,
00184 title,
00185 Form( ".x paracoor.C(\"%s\")", fName ),
00186 "Plots parallel coordinates for classifiers and input variables (macro paracoor.C, requires ROOT >= 5.17)",
00187 buttonType, defaultRequiredClassifier );
00188
00189
00190 #if ROOT_VERSION_CODE < ROOT_VERSION(5,17,0)
00191 TMVAGui_inactiveButtons.push_back( title );
00192 #endif
00193
00194 title =Form( "(%i) PDFs of Classifiers (requires \"CreateMVAPdfs\" option set)", ++ic );
00195 ActionButton( cbar,
00196 title,
00197 Form( ".x probas.C(\"%s\")", fName ),
00198 "Plots the PDFs of the classifier output distributions for signal and background - if requested (macro probas.C)",
00199 buttonType, defaultRequiredClassifier );
00200
00201 title = Form( "(%i) Likelihood Reference Distributiuons", ++ic);
00202 ActionButton( cbar,
00203 title,
00204 Form( ".x likelihoodrefs.C(\"%s\")", fName ),
00205 "Plots to verify the likelihood reference distributions (macro likelihoodrefs.C)",
00206 buttonType, "Likelihood" );
00207
00208 title = Form( "(%ia) Network Architecture (MLP)", ++ic );
00209 TString call = Form( ".x network.C+g(\"%s\")", fName );
00210 ActionButton( cbar,
00211 title,
00212 call,
00213 "Plots the MLP weights (macro network.C)",
00214 buttonType, "MLP" );
00215
00216 title = Form( "(%ib) Network Convergence Test (MLP)", ic );
00217 ActionButton( cbar,
00218 title,
00219 Form( ".x annconvergencetest.C(\"%s\")", fName ),
00220 "Plots error estimator versus training epoch for training and test samples (macro annconvergencetest.C)",
00221 buttonType, "MLP" );
00222
00223 title = Form( "(%i) Decision Trees (BDT)", ++ic );
00224 ActionButton( cbar,
00225 title,
00226 Form( ".x BDT.C+(\"%s\")", fName ),
00227 "Plots the Decision Trees trained by BDT algorithms (macro BDT.C(itree,...))",
00228 buttonType, "BDT" );
00229
00230 title = Form( "(%i) Decision Tree Control Plots (BDT)", ++ic );
00231 ActionButton( cbar,
00232 title,
00233 Form( ".x BDTControlPlots.C(\"%s\")", fName ),
00234 "Plots to monitor boosting and pruning of decision trees (macro BDTControlPlots.C)",
00235 buttonType, "BDT" );
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 title = Form( "(%i) Plot Foams (PDEFoam)", ++ic );
00250 ActionButton( cbar,
00251 title,
00252 ".x PlotFoams.C",
00253 "Plot Foams (macro PlotFoams.C)",
00254 buttonType, "PDEFoam" );
00255
00256 title = Form( "(%i) General Boost Control Plots", ++ic );
00257 ActionButton( cbar,
00258 title,
00259 Form( ".x BoostControlPlots.C(\"%s\")", fName ),
00260 "Plots to monitor boosting of general classifiers (macro BoostControlPlots.C)",
00261 buttonType, "Boost" );
00262
00263 cbar->AddSeparator();
00264
00265 cbar->AddButton( Form( "(%i) Quit", ++ic ), ".q", "Quit", buttonType );
00266
00267
00268 cbar->SetTextColor("black");
00269
00270
00271
00272
00273
00274 cbar->Show();
00275
00276
00277 for (UInt_t i=0; i<TMVAGui_inactiveButtons.size(); i++) cbar->SetButtonState(TMVAGui_inactiveButtons[i], 3 );
00278 if (TMVAGui_inactiveButtons.size() > 0) {
00279 cout << "=== Note: inactive buttons indicate classifiers that were not trained, ===" << endl;
00280 cout << "=== or functionalities that were not invoked during the training ===" << endl;
00281 }
00282
00283 gROOT->SaveContext();
00284 }