From 83432d5aea9317bd59d2f076f36d417851c07218 Mon Sep 17 00:00:00 2001
From: Joerg Stelzer <joerg.stelzer@cern.ch>
Date: Fri, 2 Jul 2010 11:32:29 +0000
Subject: [PATCH] fix printf warnings

git-svn-id: http://root.cern.ch/svn/root/trunk@34301 27541ba8-7e3a-0410-8455-c3a389f83636
---
 tmva/doc/v528/index.html    |  6 ++---
 tmva/inc/Option.h           | 14 +++++-----
 tmva/src/Factory.cxx        |  8 +++---
 tmva/src/MethodCategory.cxx |  4 +--
 tmva/src/Option.cxx         |  6 +++--
 tmva/test/BDT.C             |  3 +++
 tmva/test/TMVAGui.C         |  8 +++++-
 tmva/test/network.C         | 51 +++++++++++++++++++++----------------
 8 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/tmva/doc/v528/index.html b/tmva/doc/v528/index.html
index 0a6730feadc..2975f3a33a0 100644
--- a/tmva/doc/v528/index.html
+++ b/tmva/doc/v528/index.html
@@ -1,5 +1,5 @@
-<br/> 
-<hr/> 
+<br> 
+<hr> 
 <a name="tmva"></a> 
 <h3>TMVA</h3>
 
@@ -13,7 +13,7 @@
       all classes and the mixing of those samples to one training and
       one test sample has been rewritten completely. The new code is
       more performant and has a clearer structure. This should fix
-      several bugs which have been reported</li>
+      several bugs which have been reported by
 
     </ul>
 
diff --git a/tmva/inc/Option.h b/tmva/inc/Option.h
index ba46e47436a..25b7c18e2c9 100644
--- a/tmva/inc/Option.h
+++ b/tmva/inc/Option.h
@@ -93,7 +93,7 @@ namespace TMVA {
 
    protected:
 
-      mutable MsgLogger fLogger;  // message logger
+      static MsgLogger* fgLogger;  // message logger
 
    };
       
@@ -249,16 +249,16 @@ namespace TMVA {
    inline void TMVA::Option<Bool_t>::AddPreDefVal( const Bool_t& ) 
    {
       // template specialization for Bool_t 
-      fLogger << kFATAL << "<AddPreDefVal> predefined values for Option<Bool_t> don't make sense" 
-              << Endl;
+      *fgLogger << kFATAL << "<AddPreDefVal> predefined values for Option<Bool_t> don't make sense" 
+                << Endl;
    }
 
    template<>
    inline void TMVA::Option<Float_t>::AddPreDefVal( const Float_t& ) 
    {
       // template specialization for Float_t 
-      fLogger << kFATAL << "<AddPreDefVal> predefined values for Option<Float_t> don't make sense" 
-              << Endl;
+      *fgLogger << kFATAL << "<AddPreDefVal> predefined values for Option<Float_t> don't make sense" 
+                << Endl;
    }
 
    template<class T>
@@ -358,8 +358,8 @@ namespace TMVA {
          this->Value() = false;
       }
       else {
-         fLogger << kFATAL << "<SetValueLocal> value \'" << val 
-                 << "\' can not be interpreted as boolean" << Endl;
+         *fgLogger << kFATAL << "<SetValueLocal> value \'" << val 
+                   << "\' can not be interpreted as boolean" << Endl;
       }
    }
 }
diff --git a/tmva/src/Factory.cxx b/tmva/src/Factory.cxx
index 22ab70ff322..4390c26b808 100644
--- a/tmva/src/Factory.cxx
+++ b/tmva/src/Factory.cxx
@@ -707,9 +707,9 @@ TMVA::MethodBase* TMVA::Factory::BookMethod( TString theMethodName, TString meth
                                                  DefaultDataSetInfo(),
                                                  theOption );
       MethodBoost* methBoost = dynamic_cast<MethodBoost*>(im); // DSMTEST divided into two lines
-      methBoost->SetBoostedMethodName( theMethodName ); // DSMTEST divided into two lines
       if( !methBoost ) // DSMTEST
-         Log() << kERROR << "Method with type kBoost cannot be casted to MethodCategory. /Factory" << Endl; // DSMTEST
+         Log() << kFATAL << "Method with type kBoost cannot be casted to MethodCategory. /Factory" << Endl; // DSMTEST
+      methBoost->SetBoostedMethodName( theMethodName ); // DSMTEST divided into two lines
       methBoost->fDataSetManager = fDataSetManager; // DSMTEST
 
    }
@@ -1555,7 +1555,7 @@ void TMVA::Factory::EvaluateAllMethods( void )
             if (k == 1) mname[k][i].ReplaceAll( "Variable_", "" );
             if (sep[k][i] < 0 || sig[k][i] < 0) {
                // cannot compute separation/significance -> no MVA (usually for Cuts)
-               Log() << kINFO << Form("%-15s: %#1.3f(%#02i)  %#1.3f(%#02i)  %#1.3f(%#02i)    %#1.3f    | --       --",
+               Log() << kINFO << Form("%-15s: %#1.3f(%02i)  %#1.3f(%02i)  %#1.3f(%02i)    %#1.3f    | --       --",
                                       (const char*)mname[k][i], 
                                       eff01[k][i], Int_t(1000*eff01err[k][i]), 
                                       eff10[k][i], Int_t(1000*eff10err[k][i]), 
@@ -1563,7 +1563,7 @@ void TMVA::Factory::EvaluateAllMethods( void )
                                       effArea[k][i]) << Endl;
             }
             else {
-               Log() << kINFO << Form("%-15s: %#1.3f(%#02i)  %#1.3f(%#02i)  %#1.3f(%#02i)    %#1.3f    | %#1.3f    %#1.3f",
+               Log() << kINFO << Form("%-15s: %#1.3f(%02i)  %#1.3f(%02i)  %#1.3f(%02i)    %#1.3f    | %#1.3f    %#1.3f",
                                       (const char*)mname[k][i], 
                                       eff01[k][i], Int_t(1000*eff01err[k][i]), 
                                       eff10[k][i], Int_t(1000*eff10err[k][i]), 
diff --git a/tmva/src/MethodCategory.cxx b/tmva/src/MethodCategory.cxx
index 374267b7c83..343812e4677 100644
--- a/tmva/src/MethodCategory.cxx
+++ b/tmva/src/MethodCategory.cxx
@@ -165,7 +165,7 @@ TMVA::IMethod* TMVA::MethodCategory::AddMethod( const TCut& theCut,
    UInt_t newSpectatorIndex = primaryDSI.GetSpectatorInfos().size();
    fCategorySpecIdx.push_back(newSpectatorIndex);
    
-   primaryDSI.AddSpectator( Form("%s_cat%i:=%s", GetName(),fMethods.size(),theCut.GetTitle()),
+   primaryDSI.AddSpectator( Form("%s_cat%i:=%s", GetName(),(int)fMethods.size(),theCut.GetTitle()),
                             Form("%s:%s",GetName(),method->GetName()),
                             "pass", 0, 0, 'C' );
 
@@ -474,7 +474,7 @@ void TMVA::MethodCategory::ReadWeightsFromXML( void* wghtnode )
       // find the spectator index
       std::vector<VariableInfo>& spectators=primaryDSI.GetSpectatorInfos();
       std::vector<VariableInfo>::iterator itrVarInfo;
-      TString specName= Form("%s_cat%i", GetName(),fCategorySpecIdx.size()+1);
+      TString specName= Form("%s_cat%i", GetName(),(int)fCategorySpecIdx.size()+1);
 
       for (itrVarInfo = spectators.begin(); itrVarInfo != spectators.end(); ++itrVarInfo, ++counter) {
          if((specName==itrVarInfo->GetLabel()) || (specName==itrVarInfo->GetExpression())) {
diff --git a/tmva/src/Option.cxx b/tmva/src/Option.cxx
index b164055588b..b56c920e516 100644
--- a/tmva/src/Option.cxx
+++ b/tmva/src/Option.cxx
@@ -28,16 +28,18 @@
 
 #include "TMVA/Option.h"
 
+TMVA::MsgLogger* TMVA::OptionBase::fgLogger = 0;
+
 //______________________________________________________________________
 TMVA::OptionBase::OptionBase( const TString& name, const TString& desc ) 
    : TObject(), 
      fName        ( name ), 
      fNameAllLower( name ), 
      fDescription ( desc ), 
-     fIsSet       ( kFALSE ), 
-     fLogger      ("OptionBase") 
+     fIsSet       ( kFALSE )
 {
    // constructor
+   if (!fgLogger) fgLogger = new MsgLogger("Option",kDEBUG);
    fNameAllLower.ToLower();
 }
 
diff --git a/tmva/test/BDT.C b/tmva/test/BDT.C
index 1e226bdc39d..d4b8041e74e 100644
--- a/tmva/test/BDT.C
+++ b/tmva/test/BDT.C
@@ -52,6 +52,7 @@ class StatDialogBDT {
    StatDialogBDT( const TGWindow* p, TString wfile = "weights/TMVAClassification_BDT.weights.txt", 
                   TString methName = "BDT", Int_t itree = 0 );
    virtual ~StatDialogBDT() {
+      TMVA::DecisionTreeNode::fgIsTraining=false;
       fThis = 0;
       fMain->CloseWindow();
       fMain->Cleanup();
@@ -138,6 +139,8 @@ StatDialogBDT::StatDialogBDT( const TGWindow* p, TString wfile, TString methName
 
    fThis = this;
 
+   TMVA::DecisionTreeNode::fgIsTraining=true;
+
    // read number of decision trees from weight file
    GetNtrees();
 
diff --git a/tmva/test/TMVAGui.C b/tmva/test/TMVAGui.C
index 81baea8ecb1..ca2d97fba84 100644
--- a/tmva/test/TMVAGui.C
+++ b/tmva/test/TMVAGui.C
@@ -60,7 +60,13 @@ void TMVAGui( const char* fName = "TMVA.root" )
    // macro path is a mistake, especially if "./" was not part of path
    // add ../macros to the path (comment out next line for the ROOT version of TMVA)
    // gROOT->SetMacroPath(curMacroPath+":../macros:");
-   
+
+   TString curIncludePath=gSystem->GetIncludePath();
+   //std::cout <<"inc path="<<curIncludePath<<std::endl;
+   TString newIncludePath=TString("-I../ ")+curIncludePath;
+   gSystem->SetIncludePath(newIncludePath);
+   std::cout <<"new include path="<<gSystem->GetIncludePath()<<std::endl;
+  
    cout << "--- Launch TMVA GUI to view input file: " << fName << endl;
 
    // init
diff --git a/tmva/test/network.C b/tmva/test/network.C
index 57516bc00c9..bbd56f0e697 100644
--- a/tmva/test/network.C
+++ b/tmva/test/network.C
@@ -45,7 +45,7 @@ void draw_network( TFile* f, TDirectory* d, const TString& hName = "weights_hist
    if (MovieMode) ixc = iyc = 0;
    TCanvas* c = new TCanvas( Form( "c%i", icanvas ), Form("Neural Network Layout for: %s", d->GetName()), 
                              ixc, 0 + (icanvas+1)*20, 1000, 650  );
-
+   icanvas++;
    TIter next = d->GetListOfKeys();
    TKey *key( 0 );
    Int_t numHists = 0;
@@ -80,7 +80,7 @@ void draw_network( TFile* f, TDirectory* d, const TString& hName = "weights_hist
    }
    if (numHists == 0) {
       cout << "Error: could not find histograms" << endl;
-      exit(1);
+      //exit(1);
    }
 
    // draw network
@@ -398,26 +398,33 @@ void network( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
 
    // checks if file with name "fin" is already open, and if not opens one
    TFile* file = TMVAGlob::OpenFile( fin );  
-
-   TKey* mkey = TMVAGlob::FindMethod("MLP"); 
-   if (mkey==0) {
-      cout << "Could not locate directory MLP in file " << fin << endl;
-      return;
-   }
-   TDirectory *dir = (TDirectory *)mkey->ReadObj();
-   dir->cd();  
-   TList titles;
-   UInt_t ni = TMVAGlob::GetListOfTitles( dir, titles );
-   if (ni==0) {
-      cout << "No titles found for Method_MLP" << endl;
-      return;
-   }
-   TIter nextTitle(&titles);
-   TKey *titkey;
-   TDirectory *titDir;
-   while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
-      titDir = (TDirectory *)titkey->ReadObj();
-      draw_network( file, titDir );
+   TIter next(file->GetListOfKeys());
+   TKey *key(0);
+   while( (key = (TKey*)next()) ) {      
+      if (!TString(key->GetName()).BeginsWith("Method_MLP")) continue;
+      if( ! gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory") ) continue;
+
+      cout << "--- Found directory: " << ((TDirectory*)key->ReadObj())->GetName() << endl;
+
+      TDirectory* mDir = (TDirectory*)key->ReadObj();
+
+      TIter keyIt(mDir->GetListOfKeys());
+      TKey *titkey;
+      while((titkey = (TKey*)keyIt())) {
+        if( ! gROOT->GetClass(titkey->GetClassName())->InheritsFrom("TDirectory") ) continue;
+
+        TDirectory* dir = (TDirectory *)titkey->ReadObj();
+        dir->cd();  
+        TList titles;
+        UInt_t ni = TMVAGlob::GetListOfTitles( dir, titles );
+        if (ni==0) {
+           cout << "No titles found for Method_MLP" << endl;
+           return;
+        }
+        draw_network( file, dir );
+      }
    }
+
+   return;
 }
 
-- 
GitLab