ROOT logo
// @(#)root/tmva $Id: MethodBoost.cxx 40028 2011-06-27 17:15:12Z stelzer $
// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss,Or Cohen, Jan Therhaag, Eckhard von Toerne

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : MethodCompositeBase                                                   *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      Virtual base class for all MVA method                                     *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Andreas Hoecker    <Andreas.Hocker@cern.ch>   - CERN, Switzerland         *
 *      Peter Speckmayer   <Peter.Speckmazer@cern.ch> - CERN, Switzerland         *
 *      Joerg Stelzer      <Joerg.Stelzer@cern.ch>    - CERN, Switzerland         *
 *      Helge Voss         <Helge.Voss@cern.ch>       - MPI-K Heidelberg, Germany *
 *      Jan Therhaag       <Jan.Therhaag@cern.ch>     - U of Bonn, Germany        *
 *      Eckhard v. Toerne  <evt@uni-bonn.de>          - U of Bonn, Germany        *
 *                                                                                *
 * Copyright (c) 2005-2011:                                                       *
 *      CERN, Switzerland                                                         *
 *      U. of Victoria, Canada                                                    *
 *      MPI-K Heidelberg, Germany                                                 *
 *      U. of Bonn, Germany                                                       *
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

//_______________________________________________________________________
//
// This class is meant to boost a single classifier. Boosting means    //
// training the classifier a few times. Everytime the wieghts of the   //
// events are modified according to how well the classifier performed  //
// on the test sample.                                                 //
//_______________________________________________________________________
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>

#include "Riostream.h"
#include "TRandom3.h"
#include "TMath.h"
#include "TObjString.h"
#include "TH1F.h"
#include "TGraph.h"
#include "TSpline.h"
#include "TDirectory.h"

#include "TMVA/MethodCompositeBase.h"
#include "TMVA/MethodBase.h"
#include "TMVA/MethodBoost.h"
#include "TMVA/MethodCategory.h"
#include "TMVA/Tools.h"
#include "TMVA/ClassifierFactory.h"
#include "TMVA/Timer.h"
#include "TMVA/Types.h"
#include "TMVA/PDF.h"
#include "TMVA/Results.h"
#include "TMVA/Config.h"

#include "TMVA/SeparationBase.h"
#include "TMVA/MisClassificationError.h"
#include "TMVA/GiniIndex.h"
#include "TMVA/CrossEntropy.h"
#include "TMVA/RegressionVariance.h"

REGISTER_METHOD(Boost)

ClassImp(TMVA::MethodBoost)

//_______________________________________________________________________
TMVA::MethodBoost::MethodBoost( const TString& jobName,
                                const TString& methodTitle,
                                DataSetInfo& theData,
                                const TString& theOption,
                                TDirectory* theTargetDir ) :
   TMVA::MethodCompositeBase( jobName, Types::kBoost, methodTitle, theData, theOption, theTargetDir )
   , fBoostNum(0)
   , fMethodError(0)
   , fOrigMethodError(0)
   , fBoostWeight(0)
   , fDetailedMonitoring(kFALSE)
   , fADABoostBeta(0)
   , fRandomSeed(0)
   , fBoostedMethodTitle(methodTitle)
   , fBoostedMethodOptions(theOption)
   , fMonitorHist(0)
   , fMonitorBoostedMethod(kFALSE)
   , fMonitorTree(0)
   , fBoostStage(Types::kBoostProcBegin)
   , fDefaultHistNum(0)
   , fRecalculateMVACut(kFALSE)
   , fROC_training(0.0)
   , fOverlap_integral(0.0)
   , fMVAvalues(0)
{
   fMVAvalues = new std::vector<Float_t>;
}

//_______________________________________________________________________
TMVA::MethodBoost::MethodBoost( DataSetInfo& dsi,
                                const TString& theWeightFile,
                                TDirectory* theTargetDir )
   : TMVA::MethodCompositeBase( Types::kBoost, dsi, theWeightFile, theTargetDir )
   , fBoostNum(0)
   , fMethodError(0)
   , fOrigMethodError(0)
   , fBoostWeight(0)
   , fDetailedMonitoring(kFALSE)
   , fADABoostBeta(0)
   , fRandomSeed(0)
   , fBoostedMethodTitle("")
   , fBoostedMethodOptions("")
   , fMonitorHist(0)
   , fMonitorBoostedMethod(kFALSE)
   , fMonitorTree(0)
   , fBoostStage(Types::kBoostProcBegin)
   , fDefaultHistNum(0)
   , fRecalculateMVACut(kFALSE)
   , fROC_training(0.0)
   , fOverlap_integral(0.0)
   , fMVAvalues(0)
{
   fMVAvalues = new std::vector<Float_t>;
}

//_______________________________________________________________________
TMVA::MethodBoost::~MethodBoost( void )
{
   // destructor
   fMethodWeight.clear();

   // the histogram themselves are deleted when the file is closed

   if (fMonitorHist) {
      for ( std::vector<TH1*>::iterator it = fMonitorHist->begin(); it != fMonitorHist->end(); ++it) delete *it;
      delete fMonitorHist;
   }
   fTrainSigMVAHist.clear();
   fTrainBgdMVAHist.clear();
   fBTrainSigMVAHist.clear();
   fBTrainBgdMVAHist.clear();
   fTestSigMVAHist.clear();
   fTestBgdMVAHist.clear();

   if (fMVAvalues) {
      delete fMVAvalues;
      fMVAvalues = 0;
   }
}


//_______________________________________________________________________
Bool_t TMVA::MethodBoost::HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/ )
{
   // Boost can handle classification with 2 classes and regression with one regression-target
   if (type == Types::kClassification && numberClasses == 2) return kTRUE;
   //   if (type == Types::kRegression && numberTargets == 1) return kTRUE;
   return kFALSE;
}


//_______________________________________________________________________
void TMVA::MethodBoost::DeclareOptions()
{
   DeclareOptionRef( fBoostNum = 1, "Boost_Num",
                     "Number of times the classifier is boosted" );

   DeclareOptionRef( fMonitorBoostedMethod = kTRUE, "Boost_MonitorMethod",
                     "Write monitoring histograms for each boosted classifier" );
   
   DeclareOptionRef( fDetailedMonitoring = kFALSE, "Boost_DetailedMonitoring",
                     "Produce histograms for detailed boost-wise monitoring" );

   DeclareOptionRef( fBoostType  = "AdaBoost", "Boost_Type", "Boosting type for the classifiers" );
   AddPreDefVal(TString("AdaBoost"));
   AddPreDefVal(TString("Bagging"));
   AddPreDefVal(TString("HighEdgeGauss"));
   AddPreDefVal(TString("HighEdgeCoPara"));

   DeclareOptionRef( fMethodWeightType = "ByError", "Boost_MethodWeightType",
                     "How to set the final weight of the boosted classifiers" );
   AddPreDefVal(TString("ByError"));
   AddPreDefVal(TString("Average"));
   AddPreDefVal(TString("ByROC"));
   AddPreDefVal(TString("ByOverlap"));
   AddPreDefVal(TString("LastMethod"));

   DeclareOptionRef( fRecalculateMVACut = kTRUE, "Boost_RecalculateMVACut",
                     "Recalculate the classifier MVA Signallike cut at every boost iteration" );

   DeclareOptionRef( fADABoostBeta = 1.0, "Boost_AdaBoostBeta",
                     "The ADA boost parameter that sets the effect of every boost step on the events' weights" );
   
   DeclareOptionRef( fTransformString = "step", "Boost_Transform",
                     "Type of transform applied to every boosted method linear, log, step" );
   AddPreDefVal(TString("step"));
   AddPreDefVal(TString("linear"));
   AddPreDefVal(TString("log"));
   AddPreDefVal(TString("gauss"));

   DeclareOptionRef( fRandomSeed = 0, "Boost_RandomSeed",
                     "Seed for random number generator used for bagging" );

   TMVA::MethodCompositeBase::fMethods.reserve(fBoostNum);
}

//_______________________________________________________________________
Bool_t TMVA::MethodBoost::BookMethod( Types::EMVA theMethod, TString methodTitle, TString theOption )
{
   // just registering the string from which the boosted classifier will be created
   fBoostedMethodName     = Types::Instance().GetMethodName( theMethod );
   fBoostedMethodTitle    = methodTitle;
   fBoostedMethodOptions  = theOption;
   TString opts=theOption;
   opts.ToLower();
//    if (opts.Contains("vartransform")) Log() << kFATAL << "It is not possible to use boost in conjunction with variable transform. Please remove either Boost_Num or VarTransform from the option string"<< methodTitle<<Endl;

   return kTRUE;
}

//_______________________________________________________________________
void TMVA::MethodBoost::Init()
{ 
}

//_______________________________________________________________________
void TMVA::MethodBoost::InitHistos()
{
   // initialisation routine
   if (fMonitorHist) {
      for ( std::vector<TH1*>::iterator it = fMonitorHist->begin(); it != fMonitorHist->end(); ++it) delete *it;
      delete fMonitorHist;
   }
   fMonitorHist = new std::vector<TH1*>();
   fMonitorHist->push_back(new TH1F("MethodWeight","Normalized Classifier Weight",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("BoostWeight","Boost Weight",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("ErrFraction","Error Fraction (by boosted event weights)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("OrigErrFraction","Error Fraction (by original event weights)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("ROCIntegral_test","ROC integral of single classifier (testing sample)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("ROCIntegralBoosted_test","ROC integral of boosted method (testing sample)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("ROCIntegral_train","ROC integral of single classifier (training sample)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("ROCIntegralBoosted_train","ROC integral of boosted method (training sample)",fBoostNum,0,fBoostNum));
   fMonitorHist->push_back(new TH1F("OverlapIntegal_train","Overlap integral (training sample)",fBoostNum,0,fBoostNum));
   for ( std::vector<TH1*>::iterator it = fMonitorHist->begin(); it != fMonitorHist->end(); ++it ) (*it)->SetDirectory(0);
   fDefaultHistNum = fMonitorHist->size();
   (*fMonitorHist)[0]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[0]->GetYaxis()->SetTitle("Classifier Weight");
   (*fMonitorHist)[1]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[1]->GetYaxis()->SetTitle("Boost Weight");
   (*fMonitorHist)[2]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[2]->GetYaxis()->SetTitle("Error Fraction");
   (*fMonitorHist)[3]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[3]->GetYaxis()->SetTitle("Error Fraction");
   (*fMonitorHist)[4]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[4]->GetYaxis()->SetTitle("ROC integral of single classifier");
   (*fMonitorHist)[5]->GetXaxis()->SetTitle("Number of boosts");
   (*fMonitorHist)[5]->GetYaxis()->SetTitle("ROC integral boosted");
   (*fMonitorHist)[6]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[6]->GetYaxis()->SetTitle("ROC integral of single classifier");
   (*fMonitorHist)[7]->GetXaxis()->SetTitle("Number of boosts");
   (*fMonitorHist)[7]->GetYaxis()->SetTitle("ROC integral boosted");
   (*fMonitorHist)[8]->GetXaxis()->SetTitle("Index of boosted classifier");
   (*fMonitorHist)[8]->GetYaxis()->SetTitle("Overlap integral");

   fMonitorTree= new TTree("MonitorBoost","Boost variables");
   fMonitorTree->Branch("iMethod",&fMethodIndex,"iMethod/I");
   fMonitorTree->Branch("boostWeight",&fBoostWeight,"boostWeight/D");
   fMonitorTree->Branch("errorFraction",&fMethodError,"errorFraction/D");
   fMonitorBoostedMethod = kTRUE;
}


//_______________________________________________________________________
void TMVA::MethodBoost::CheckSetup()
{
   Log() << kDEBUG << "CheckSetup: fBoostType="<<fBoostType<<" fMethodWeightType=" << fMethodWeightType << Endl;
   Log() << kDEBUG << "CheckSetup: fADABoostBeta="<<fADABoostBeta<<Endl;
   Log() << kDEBUG << "CheckSetup: fBoostWeight="<<fBoostWeight<<Endl;
   Log() << kDEBUG << "CheckSetup: fMethodError="<<fMethodError<<Endl;
   Log() << kDEBUG << "CheckSetup: fOrigMethodError="<<fOrigMethodError<<Endl;
   Log() << kDEBUG << "CheckSetup: fBoostNum="<<fBoostNum<< " fMonitorHist="<< fMonitorHist<< Endl;
   Log() << kDEBUG << "CheckSetup: fRandomSeed=" << fRandomSeed<< Endl;
   Log() << kDEBUG << "CheckSetup: fDefaultHistNum=" << fDefaultHistNum << " fRecalculateMVACut=" << (fRecalculateMVACut? "true" : "false") << Endl;
   Log() << kDEBUG << "CheckSetup: fTrainSigMVAHist.size()="<<fTrainSigMVAHist.size()<<Endl;
   Log() << kDEBUG << "CheckSetup: fTestSigMVAHist.size()="<<fTestSigMVAHist.size()<<Endl;
   Log() << kDEBUG << "CheckSetup: fMonitorBoostedMethod=" << (fMonitorBoostedMethod? "true" : "false") << Endl;
   Log() << kDEBUG << "CheckSetup: MName=" << fBoostedMethodName << " Title="<< fBoostedMethodTitle<< Endl;
   Log() << kDEBUG << "CheckSetup: MOptions="<< fBoostedMethodOptions << Endl;
   Log() << kDEBUG << "CheckSetup: fBoostStage=" << fBoostStage<<Endl;
   Log() << kDEBUG << "CheckSetup: fMonitorTree=" << fMonitorTree <<Endl;
   Log() << kDEBUG << "CheckSetup: fMethodIndex=" <<fMethodIndex << Endl;
   if (fMethods.size()>0) Log() << kDEBUG << "CheckSetup: fMethods[0]" <<fMethods[0]<<Endl;
   Log() << kDEBUG << "CheckSetup: fMethodWeight.size()" << fMethodWeight.size() << Endl;
   if (fMethodWeight.size()>0) Log() << kDEBUG << "CheckSetup: fMethodWeight[0]="<<fMethodWeight[0]<<Endl;
   Log() << kDEBUG << "CheckSetup: trying to repair things" << Endl;

   if (fMonitorHist == 0){
      InitHistos();
      CheckSetup();
   }
}
//_______________________________________________________________________
void TMVA::MethodBoost::Train()
{
   Double_t    AllMethodsWeight=0;
   TDirectory* methodDir( 0 );
   TString     dirName,dirTitle;
   Int_t       StopCounter=0;

   if (Data()->GetNTrainingEvents()==0) Log() << kFATAL << "<Train> Data() has zero events" << Endl;
   Data()->SetCurrentType(Types::kTraining);

   if (fMethods.size() > 0) fMethods.clear();
   fMVAvalues->resize(Data()->GetNTrainingEvents(), 0.0);

   Log() << kINFO << "Training "<< fBoostNum << " " << fBoostedMethodName << " with title " << fBoostedMethodTitle << " Classifiers ... patience please" << Endl;
   Timer timer( fBoostNum, GetName() );

   ResetBoostWeights();

   // clean boosted method options
   CleanBoostOptions();


   // remove transformations for individual boosting steps
   // the transformation of the main method will be rerouted to each of the boost steps
   Ssiz_t varTrafoStart=fBoostedMethodOptions.Index("~VarTransform=");
   if (varTrafoStart >0) {
      Ssiz_t varTrafoEnd  =fBoostedMethodOptions.Index(":",varTrafoStart);
      if (varTrafoEnd<varTrafoStart)
	 varTrafoEnd=fBoostedMethodOptions.Length();
      fBoostedMethodOptions.Remove(varTrafoStart,varTrafoEnd-varTrafoStart);
   }

   //
   // training and boosting the classifiers
   for (fMethodIndex=0;fMethodIndex<fBoostNum;fMethodIndex++) {
      // the first classifier shows the option string output, the rest not
      if (fMethodIndex>0) TMVA::MsgLogger::InhibitOutput();

      IMethod* method = ClassifierFactory::Instance().Create(std::string(fBoostedMethodName),
                                                             GetJobName(),
                                                             Form("%s_B%04i", fBoostedMethodTitle.Data(),fMethodIndex),
                                                             DataInfo(),
                                                             fBoostedMethodOptions);
      TMVA::MsgLogger::EnableOutput();

      // supressing the rest of the classifier output the right way
      MethodBase *meth = (dynamic_cast<MethodBase*>(method));

      if (meth==0) continue;

      // set fDataSetManager if MethodCategory (to enable Category to create datasetinfo objects) // DSMTEST
      if (meth->GetMethodType() == Types::kCategory) { // DSMTEST
         MethodCategory *methCat = (dynamic_cast<MethodCategory*>(meth)); // DSMTEST
         if (!methCat) // DSMTEST
            Log() << kFATAL << "Method with type kCategory cannot be casted to MethodCategory. /MethodBoost" << Endl; // DSMTEST
         methCat->fDataSetManager = fDataSetManager; // DSMTEST
      } // DSMTEST

      meth->SetMsgType(kWARNING);
      meth->SetupMethod();
      meth->ParseOptions();
      // put SetAnalysisType here for the needs of MLP
      meth->SetAnalysisType( GetAnalysisType() );
      meth->ProcessSetup();
      meth->CheckSetup();

      
      // reroute transformationhandler
      meth->RerouteTransformationHandler (&(this->GetTransformationHandler()));


      // creating the directory of the classifier
      if (fMonitorBoostedMethod) {
         methodDir=MethodBaseDir()->GetDirectory(dirName=Form("%s_B%04i",fBoostedMethodName.Data(),fMethodIndex));
         if (methodDir==0) {
            methodDir=BaseDir()->mkdir(dirName,dirTitle=Form("Directory Boosted %s #%04i", fBoostedMethodName.Data(),fMethodIndex));
         }
         MethodBase* m = dynamic_cast<MethodBase*>(method);
         if (m) {
            m->SetMethodDir(methodDir);
            m->BaseDir()->cd();
         }
      }

      // training
      TMVA::MethodCompositeBase::fMethods.push_back(method);
      timer.DrawProgressBar( fMethodIndex );
      if (fMethodIndex==0) method->MonitorBoost(SetStage(Types::kBoostProcBegin));
      method->MonitorBoost(SetStage(Types::kBeforeTraining));
      TMVA::MsgLogger::InhibitOutput(); //supressing Logger outside the method
      SingleTrain();
      TMVA::MsgLogger::EnableOutput();
      method->WriteMonitoringHistosToFile();
      
      // calculate MVA values of method on training sample
      CalcMVAValues();

      if (fMethodIndex==0 && fMonitorBoostedMethod) CreateMVAHistorgrams();
      
      // get ROC integral and overlap integral for single method on
      // training sample if fMethodWeightType == "ByROC" or the user
      // wants detailed monitoring
      if (fMethodWeightType == "ByROC" || fDetailedMonitoring)
         fROC_training = GetBoostROCIntegral(kTRUE, Types::kTraining, kTRUE);
	 
      // calculate method weight
      CalcMethodWeight();
      AllMethodsWeight += fMethodWeight.back();

      if (fDetailedMonitoring) {      
         (*fMonitorHist)[4]->SetBinContent(fMethodIndex+1, GetBoostROCIntegral(kTRUE,  Types::kTesting));
         (*fMonitorHist)[5]->SetBinContent(fMethodIndex+1, GetBoostROCIntegral(kFALSE, Types::kTesting));
         (*fMonitorHist)[6]->SetBinContent(fMethodIndex+1, fROC_training);
         (*fMonitorHist)[7]->SetBinContent(fMethodIndex+1, GetBoostROCIntegral(kFALSE, Types::kTraining));
         (*fMonitorHist)[8]->SetBinContent(fMethodIndex+1, fOverlap_integral);
      }

      // boosting (reweight training sample)
      method->MonitorBoost(SetStage(Types::kBeforeBoosting));
      SingleBoost();
      method->MonitorBoost(SetStage(Types::kAfterBoosting));
      (*fMonitorHist)[1]->SetBinContent(fMethodIndex+1,fBoostWeight);
      (*fMonitorHist)[2]->SetBinContent(fMethodIndex+1,fMethodError);
      (*fMonitorHist)[3]->SetBinContent(fMethodIndex+1,fOrigMethodError);

      fMonitorTree->Fill();

      // stop boosting if needed when error has reached 0.5
      // thought of counting a few steps, but it doesn't seem to be necessary
      Log() << kDEBUG << "AdaBoost (methodErr) err = " << fMethodError << Endl;
      if (fMethodError > 0.49999) StopCounter++; 
      if (StopCounter > 0 && fBoostType != "Bagging") {
         timer.DrawProgressBar( fBoostNum );
         fBoostNum = fMethodIndex+1; 
         Log() << kINFO << "Error rate has reached 0.5 ("<< fMethodError<<"), boosting process stopped at #" << fBoostNum << " classifier" << Endl;
         if (fBoostNum < 5)
            Log() << kINFO << "The classifier might be too strong to boost with Beta = " << fADABoostBeta << ", try reducing it." <<Endl;
         for (Int_t i=0;i<fDefaultHistNum;i++) (*fMonitorHist)[i]->SetBins(fBoostNum,0,fBoostNum);
         break;
      }
   }
   if (fMethodWeightType == "LastMethod") { fMethodWeight.back() = AllMethodsWeight = 1.0; }

   ResetBoostWeights();
   Timer* timer1=new Timer();
   // normalizing the weights of the classifiers
   for (fMethodIndex=0;fMethodIndex<fBoostNum;fMethodIndex++) {
      // pefroming post-boosting actions
      if (fMethods[fMethodIndex]->MonitorBoost(SetStage(Types::kBoostValidation))) {
         if (fMethodIndex==0) timer1 = new Timer( fBoostNum, GetName() );

         timer1->DrawProgressBar( fMethodIndex );

         if (fMethodIndex==fBoostNum) {
            Log() << kINFO << "Elapsed time: " << timer1->GetElapsedTime() 
                  << "                              " << Endl;
         }
      }

      if (AllMethodsWeight != 0.0)
         fMethodWeight[fMethodIndex] = fMethodWeight[fMethodIndex] / AllMethodsWeight;
      (*fMonitorHist)[0]->SetBinContent(fMethodIndex+1,fMethodWeight[fMethodIndex]);
   }

   // Ensure that in case of only 1 boost the method weight equals
   // 1.0.  This avoids unexpected behaviour in case of very bad
   // classifiers which have fBoostWeight=1 or fMethodError=0.5,
   // because their weight would be set to zero.  This behaviour is
   // not ok if one boosts just one time.
   if (fMethods.size()==1)  fMethodWeight[0] = 1.0;

   fMethods.back()->MonitorBoost(SetStage(Types::kBoostProcEnd));

   delete timer1;
}

//_______________________________________________________________________
void TMVA::MethodBoost::CleanBoostOptions()
{
   fBoostedMethodOptions=GetOptions(); 
}

//_______________________________________________________________________
void TMVA::MethodBoost::CreateMVAHistorgrams()
{
   if (fBoostNum <=0) Log() << kFATAL << "CreateHistorgrams called before fBoostNum is initialized" << Endl;
   // calculating histograms boundries and creating histograms..
   // nrms = number of rms around the average to use for outline (of the 0 classifier)
   Double_t meanS, meanB, rmsS, rmsB, xmin, xmax, nrms = 10;
   Int_t signalClass = 0;
   if (DataInfo().GetClassInfo("Signal") != 0) {
      signalClass = DataInfo().GetClassInfo("Signal")->GetNumber();
   }
   gTools().ComputeStat( GetEventCollection( Types::kMaxTreeType ), fMVAvalues,
                         meanS, meanB, rmsS, rmsB, xmin, xmax, signalClass );

   fNbins = gConfig().fVariablePlotting.fNbinsXOfROCCurve;
   xmin = TMath::Max( TMath::Min(meanS - nrms*rmsS, meanB - nrms*rmsB ), xmin );
   xmax = TMath::Min( TMath::Max(meanS + nrms*rmsS, meanB + nrms*rmsB ), xmax ) + 0.00001;

   // creating all the historgrams
   for (Int_t imtd=0; imtd<fBoostNum; imtd++) {
      fTrainSigMVAHist .push_back( new TH1F( Form("MVA_Train_S_%04i",imtd), "MVA_Train_S",        fNbins, xmin, xmax ) );
      fTrainBgdMVAHist .push_back( new TH1F( Form("MVA_Train_B%04i", imtd), "MVA_Train_B",        fNbins, xmin, xmax ) );
      fBTrainSigMVAHist.push_back( new TH1F( Form("MVA_BTrain_S%04i",imtd), "MVA_BoostedTrain_S", fNbins, xmin, xmax ) );
      fBTrainBgdMVAHist.push_back( new TH1F( Form("MVA_BTrain_B%04i",imtd), "MVA_BoostedTrain_B", fNbins, xmin, xmax ) );
      fTestSigMVAHist  .push_back( new TH1F( Form("MVA_Test_S%04i",  imtd), "MVA_Test_S",         fNbins, xmin, xmax ) );
      fTestBgdMVAHist  .push_back( new TH1F( Form("MVA_Test_B%04i",  imtd), "MVA_Test_B",         fNbins, xmin, xmax ) );
   }
}

//_______________________________________________________________________
void TMVA::MethodBoost::ResetBoostWeights()
{
   // resetting back the boosted weights of the events to 1
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
      Event *ev = Data()->GetEvent(ievt);
      ev->SetBoostWeight( 1.0 );
   }
}

//_______________________________________________________________________
void TMVA::MethodBoost::WriteMonitoringHistosToFile( void ) const
{
   TDirectory* dir=0;
   if (fMonitorBoostedMethod) {
      for (Int_t imtd=0;imtd<fBoostNum;imtd++) {

         //writing the histograms in the specific classifier's directory
         MethodBase* m = dynamic_cast<MethodBase*>(fMethods[imtd]);
         if (!m) continue;
         dir = m->BaseDir();
         dir->cd();
         fTrainSigMVAHist[imtd]->SetDirectory(dir);
         fTrainSigMVAHist[imtd]->Write();
         fTrainBgdMVAHist[imtd]->SetDirectory(dir);
         fTrainBgdMVAHist[imtd]->Write();
         fBTrainSigMVAHist[imtd]->SetDirectory(dir);
         fBTrainSigMVAHist[imtd]->Write();
         fBTrainBgdMVAHist[imtd]->SetDirectory(dir);
         fBTrainBgdMVAHist[imtd]->Write();
      }
   }

   // going back to the original folder
   BaseDir()->cd();
   for (UInt_t i=0;i<fMonitorHist->size();i++) {
      ((*fMonitorHist)[i])->Write(Form("Booster_%s",((*fMonitorHist)[i])->GetName()));
   }

   fMonitorTree->Write();
}

//_______________________________________________________________________
void TMVA::MethodBoost::TestClassification()
{
   MethodBase::TestClassification();
   if (fMonitorBoostedMethod) {
      UInt_t nloop = fTestSigMVAHist.size();
      if (fMethods.size()<nloop) nloop = fMethods.size();
      //running over all the events and populating the test MVA histograms
      Data()->SetCurrentType(Types::kTesting);
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         const Event* ev = GetEvent(ievt);
         Float_t w = ev->GetWeight();
         if (DataInfo().IsSignal(ev)) {
            for (UInt_t imtd=0; imtd<nloop; imtd++) {
               fTestSigMVAHist[imtd]->Fill(fMethods[imtd]->GetMvaValue(),w);
            }
         }
         else {
            for (UInt_t imtd=0; imtd<nloop; imtd++) {
               fTestBgdMVAHist[imtd]->Fill(fMethods[imtd]->GetMvaValue(),w);
            }
         }
      }
      Data()->SetCurrentType(Types::kTraining);
   }
}

//_______________________________________________________________________
void TMVA::MethodBoost::WriteEvaluationHistosToFile(Types::ETreeType treetype)
{
   MethodBase::WriteEvaluationHistosToFile(treetype);
   if (treetype==Types::kTraining) return;
   UInt_t nloop = fTestSigMVAHist.size();
   if (fMethods.size()<nloop) nloop = fMethods.size();
   if (fMonitorBoostedMethod) {
      TDirectory* dir=0;
      for (UInt_t imtd=0;imtd<nloop;imtd++) {
         //writing the histograms in the specific classifier's directory
         MethodBase* mva = dynamic_cast<MethodBase*>(fMethods[imtd]);
         if (!mva) continue;
         dir = mva->BaseDir();
         if (dir==0) continue;
         dir->cd();
         fTestSigMVAHist[imtd]->SetDirectory(dir);
         fTestSigMVAHist[imtd]->Write();
         fTestBgdMVAHist[imtd]->SetDirectory(dir);
         fTestBgdMVAHist[imtd]->Write();
      }
   }
}

//_______________________________________________________________________
void TMVA::MethodBoost::ProcessOptions()
{
   // process user options
}

//_______________________________________________________________________
void TMVA::MethodBoost::SingleTrain()
{
   // initialization
   Data()->SetCurrentType(Types::kTraining);
   MethodBase* meth = dynamic_cast<MethodBase*>(GetLastMethod());
   if (meth) meth->TrainMethod();
}

//_______________________________________________________________________
void TMVA::MethodBoost::FindMVACut()
{
   // find the CUT on the individual MVA that defines an event as 
   // correct or misclassified (to be used in the boosting process)

   MethodBase* lastMethod=dynamic_cast<MethodBase*>(fMethods.back());
   if (!lastMethod || lastMethod->GetMethodType() == Types::kDT ){ return;}

   if (!fRecalculateMVACut && fMethodIndex>0) {
      MethodBase* m = dynamic_cast<MethodBase*>(fMethods[0]);
      if (m) lastMethod->SetSignalReferenceCut(m->GetSignalReferenceCut());
   } 
   else {
      
      // creating a fine histograms containing the error rate
      const Int_t nBins=101;
      Double_t minMVA=150000;
      Double_t maxMVA=-150000;
      for (Long64_t ievt=0; ievt<Data()->GetNEvents(); ievt++) {
         GetEvent(ievt);
         Double_t val=lastMethod->GetMvaValue();
         if (val>maxMVA) maxMVA=val;
         if (val<minMVA) minMVA=val;
      }
      
      Double_t sum = 0.;
      
      TH1F *mvaS  = new TH1F("mvaS","",nBins,minMVA,maxMVA);
      TH1F *mvaB  = new TH1F("mvaB","",nBins,minMVA,maxMVA);
      TH1F *mvaSC = new TH1F("mvaSC","",nBins,minMVA,maxMVA);
      TH1F *mvaBC = new TH1F("mvaBC","",nBins,minMVA,maxMVA);
      
      for (Long64_t ievt=0; ievt<Data()->GetNEvents(); ievt++) {
        
         Double_t weight = GetEvent(ievt)->GetWeight();
         Double_t mvaVal=lastMethod->GetMvaValue();
         sum +=weight;
         if (DataInfo().IsSignal(GetEvent(ievt))){
            mvaS->Fill(mvaVal,weight);
         }else {
            mvaB->Fill(mvaVal,weight);
         }
      }
      SeparationBase *sepGain;
      //sepGain = new MisClassificationError();
      sepGain = new GiniIndex();
      //sepGain = new CrossEntropy();

      Double_t sTot = mvaS->GetSum();
      Double_t bTot = mvaB->GetSum();
      
      mvaSC->SetBinContent(1,mvaS->GetBinContent(1));
      mvaBC->SetBinContent(1,mvaB->GetBinContent(1));
      Double_t sSel=mvaSC->GetBinContent(1);
      Double_t bSel=mvaBC->GetBinContent(1);
      Double_t separationGain=sepGain->GetSeparationGain(sSel,bSel,sTot,bTot);
      Double_t mvaCut=mvaSC->GetBinLowEdge(1);
      //      cout << "minMVA =" << minMVA << " maxMVA = " << maxMVA << " width = " << mvaSC->GetBinWidth(1) <<  endl;

      //      for (Int_t ibin=1;ibin<=nBins;ibin++) cout << " cutvalues[" << ibin<<"]="<<mvaSC->GetBinLowEdge(ibin) << "  " << mvaSC->GetBinCenter(ibin) << endl;
      Double_t mvaCutOrientation=1; // 1 if mva > mvaCut --> Signal and -1 if mva < mvaCut (i.e. mva*-1 > mvaCut*-1) --> Signal
      Double_t SoBRight=1, SoBLeft=1;
      for (Int_t ibin=2;ibin<nBins;ibin++){ 
         mvaSC->SetBinContent(ibin,mvaS->GetBinContent(ibin)+mvaSC->GetBinContent(ibin-1));
         mvaBC->SetBinContent(ibin,mvaB->GetBinContent(ibin)+mvaBC->GetBinContent(ibin-1));
         
         sSel=mvaSC->GetBinContent(ibin);
         bSel=mvaBC->GetBinContent(ibin);
         
         if (separationGain < sepGain->GetSeparationGain(sSel,bSel,sTot,bTot) 
             //  &&           (mvaSC->GetBinCenter(ibin) >0 || (fMethodIndex+1)%2 )
             ){
            separationGain = sepGain->GetSeparationGain(sSel,bSel,sTot,bTot);
            mvaCut=mvaSC->GetBinCenter(ibin);
            mvaCut=mvaSC->GetBinLowEdge(ibin+1);
            if (sSel/bSel > (sTot-sSel)/(bTot-bSel)) mvaCutOrientation=-1;
            else                                     mvaCutOrientation=1;
            SoBRight=sSel/bSel;
            SoBLeft=(sTot-sSel)/(bTot-bSel);
         }
      }

      if (SoBRight<1 && SoBLeft<1) {
         if (mvaCutOrientation == -1) mvaCut = mvaSC->GetBinCenter(1)-mvaSC->GetBinWidth(1);
         if (mvaCutOrientation ==  1) mvaCut = mvaSC->GetBinCenter(nBins)+mvaSC->GetBinWidth(nBins);
      } else if (SoBRight>1 && SoBLeft>1) {
         if (mvaCutOrientation ==  1) mvaCut = mvaSC->GetBinCenter(1)-mvaSC->GetBinWidth(1);
         if (mvaCutOrientation == -1) mvaCut = mvaSC->GetBinCenter(nBins)+mvaSC->GetBinWidth(nBins);
      }
      
      
      // cout << "Min="<<minMVA << " Max=" << maxMVA 
      //      << " sTot=" << sTot
      //      << " bTot=" << bTot
      //      << " sepGain="<<separationGain
      //      << " cut=" << mvaCut 
      //      << " cutOrientation="<<mvaCutOrientation
      //      << endl;
      // cout << "S/B right="<<SoBRight << " left="<<SoBLeft<<endl;
      // if (fMethodIndex==0)mvaCut = -1.9616885110735893e-02;
      // if (fMethodIndex==1)mvaCut = -6.8812005221843719e-02;
      lastMethod->SetSignalReferenceCut(mvaCut);
      lastMethod->SetSignalReferenceCutOrientation(mvaCutOrientation);
      
      Log() << kDEBUG << "(old step) Setting method cut to " <<lastMethod->GetSignalReferenceCut()<< Endl;

      mvaS ->Delete();  
      mvaB ->Delete();
      mvaSC->Delete();
      mvaBC->Delete();
   }
   
}

//_______________________________________________________________________
void TMVA::MethodBoost::SingleBoost()
{
   MethodBase* method =  dynamic_cast<MethodBase*>(fMethods.back());
   if (!method) return;
   Float_t w,v,wo; Bool_t sig=kTRUE;
   Double_t sumAll=0, sumWrong=0, sumAllOrig=0, sumWrongOrig=0, sumAll1=0;
   Bool_t* WrongDetection=new Bool_t[GetNEvents()];
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) WrongDetection[ievt]=kTRUE;

   // finding the wrong events and calculating their total weights
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
      const Event* ev = GetEvent(ievt);
      sig=DataInfo().IsSignal(ev);
      v = fMVAvalues->at(ievt);
      w = ev->GetWeight();
      wo = ev->GetOriginalWeight();
      if (sig && fMonitorBoostedMethod) {
         fBTrainSigMVAHist[fMethodIndex]->Fill(v,w);
         fTrainSigMVAHist[fMethodIndex]->Fill(v,ev->GetOriginalWeight());
      }
      else if (fMonitorBoostedMethod) {
         fBTrainBgdMVAHist[fMethodIndex]->Fill(v,w);
         fTrainBgdMVAHist[fMethodIndex]->Fill(v,ev->GetOriginalWeight());
      }
      sumAll += w;
      sumAllOrig += wo;
      if (sig  == method->IsSignalLike(fMVAvalues->at(ievt))){   
         WrongDetection[ievt]=kFALSE;
      }else{
         WrongDetection[ievt]=kTRUE; 
         sumWrong+=w; 
	 sumWrongOrig+=wo;
      }
   }
   fMethodError=sumWrong/sumAll;
   fOrigMethodError = sumWrongOrig/sumAllOrig;
   Log() << kDEBUG << "AdaBoost err (MethodErr1)= " << fMethodError<<" = wrong/all: " << sumWrong << "/" << sumAll<< " cut="<<method->GetSignalReferenceCut()<< Endl;

   // calculating the fMethodError and the fBoostWeight out of it uses the formula 
   // w = ((1-err)/err)^beta
   if (fMethodError>0 && fADABoostBeta == 1.0) {
      fBoostWeight = (1.0-fMethodError)/fMethodError;
   }
   else if (fMethodError>0 && fADABoostBeta != 1.0) {
      fBoostWeight =  TMath::Power((1.0 - fMethodError)/fMethodError, fADABoostBeta);
   }
   else fBoostWeight = 1000;


   Double_t alphaWeight = ( fBoostWeight > 0.0 ? TMath::Log(fBoostWeight) : 0.0);
   if (alphaWeight>5.) alphaWeight = 5.;
   if (alphaWeight<0.){
      Log() << kWARNING << "alphaWeight is too small in AdaBoost (alpha = " << alphaWeight << ")" << Endl;
      alphaWeight = -alphaWeight;
   }
   if (fBoostType == "AdaBoost") {
      // ADA boosting, rescaling the weight of the wrong events according to the error level
      // over the entire test sample rescaling all the weights to have the same sum, but without
      // touching the original weights (changing only the boosted weight of all the events)
      // first reweight
      Double_t newSum=0., oldSum=0.;
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         Event* ev =  Data()->GetEvent(ievt);
         oldSum += ev->GetWeight();
         if (WrongDetection[ievt] && fBoostWeight != 0) {
            if (ev->GetWeight() > 0) ev->ScaleBoostWeight(fBoostWeight);
            else                     ev->ScaleBoostWeight(1./fBoostWeight);
         }
         newSum += ev->GetWeight();
      }

      Double_t normWeight = oldSum/newSum;
      // bla      std::cout << "Normalize weight by (Boost)" << normWeight <<  " = " << oldSum<<"/"<<newSum<< " eventBoostFactor="<<fBoostWeight<<std::endl;
      // next normalize the weights
      Double_t normSig=0, normBkg=0;
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         Event* ev = Data()->GetEvent(ievt);
	 ev->ScaleBoostWeight(normWeight);
         if (ev->GetClass()) normBkg+=ev->GetWeight();
         else                normSig+=ev->GetWeight();
      }      
   }
   else if (fBoostType == "Bagging") {
      // Bagging or Bootstrap boosting, gives new random weight for every event
      TRandom3*trandom   = new TRandom3(fRandomSeed+fMethods.size());
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         Event* ev = Data()->GetEvent(ievt);
         ev->SetBoostWeight(trandom->Rndm());
         sumAll1+=ev->GetWeight();
      }
      // rescaling all the weights to have the same sum, but without touching the original
      // weights (changing only the boosted weight of all the events)
      Double_t Factor=sumAll/sumAll1;
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         Event* ev = Data()->GetEvent(ievt);
         ev->ScaleBoostWeight(Factor);
      }
   }
   else if (fBoostType == "HighEdgeGauss" || 
	    fBoostType == "HighEdgeCoPara") {
      // Give events high boost weight, which are close of far away
      // from the MVA cut value
      Double_t MVACutValue = method->GetSignalReferenceCut();
      sumAll1 = 0;
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         Event* ev = Data()->GetEvent(ievt);
	 if (fBoostType == "HighEdgeGauss")
	    ev->SetBoostWeight( TMath::Exp( -std::pow(fMVAvalues->at(ievt)-MVACutValue,2)/(0.1*fADABoostBeta) ) );
	 else if (fBoostType == "HighEdgeCoPara")
	    ev->SetBoostWeight( DataInfo().IsSignal(ev) ? TMath::Power(1.0-fMVAvalues->at(ievt),fADABoostBeta) : TMath::Power(fMVAvalues->at(ievt),fADABoostBeta) );
	 else
	    Log() << kFATAL << "Unknown event weight type!" << Endl;

         sumAll1 += ev->GetWeight();
      }
      // rescaling all the weights to have the same sum, but without
      // touching the original weights (changing only the boosted
      // weight of all the events)
      Double_t Factor=sumAll/sumAll1;
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++)
         Data()->GetEvent(ievt)->ScaleBoostWeight(Factor);
   }
   delete[] WrongDetection;
}

//_______________________________________________________________________
void TMVA::MethodBoost::CalcMethodWeight()
{
   // Calculate weight of single method.
   // This is no longer done in SingleBoost();

   MethodBase* method =  dynamic_cast<MethodBase*>(fMethods.back());
   if (!method) {
      Log() << kFATAL << "Dynamic cast to MethodBase* failed" <<Endl;
      return;
   }

   Float_t w;
   Double_t sumAll=0, sumWrong=0;

   // finding the MVA cut value for IsSignalLike, stored in the method
   FindMVACut();

   // finding the wrong events and calculating their total weights
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
      const Event* ev = GetEvent(ievt);
      w       = ev->GetWeight();
      sumAll += w;
      if ( DataInfo().IsSignal(ev) != method->IsSignalLike(fMVAvalues->at(ievt))) {
	 sumWrong += w;
      }
      
      // if (ievt < 10)
      // cout << " TYpe=" << DataInfo().IsSignal(ev) 
      //      << " mvaValue="<<fMVAvalues->at(ievt)
      //      << " mvaCutVal="<<method->GetSignalReferenceCut()
      //      << " mvaCutValOrien="<<method->GetSignalReferenceCutOrientation()
      //      << " isSignallike="<<method->IsSignalLike(fMVAvalues->at(ievt))
      //      << endl;
   }

   //   cout << "sumWrong="<<sumWrong << " sumAll="<<sumAll<<endl;
   fMethodError=sumWrong/sumAll;

   // calculating the fMethodError and the fBoostWeight out of it uses
   // the formula
   // w = ((1-err)/err)^beta
   if (fMethodError>0 && fADABoostBeta == 1.0) {
      fBoostWeight = (1.0-fMethodError)/fMethodError;
   }
   else if (fMethodError>0 && fADABoostBeta != 1.0) {
      fBoostWeight =  TMath::Power((1.0 - fMethodError)/fMethodError, fADABoostBeta);
   }
   else fBoostWeight = 1000;

   // sanity check to avoid log() with negative argument
   if (fBoostWeight <= 0.0)  fBoostWeight = 1.0;
   
   // calculate method weight
   if      (fMethodWeightType == "ByError")   fMethodWeight.push_back(TMath::Log(fBoostWeight));
   else if (fMethodWeightType == "Average")   fMethodWeight.push_back(1.0);
   else if (fMethodWeightType == "ByROC")     fMethodWeight.push_back(fROC_training);
   else if (fMethodWeightType == "ByOverlap") fMethodWeight.push_back((fOverlap_integral > 0.0 ? 1.0/fOverlap_integral : 1000.0));
   else                                       fMethodWeight.push_back(0);
}

//_______________________________________________________________________
void TMVA::MethodBoost::GetHelpMessage() const
{
   // Get help message text
   //
   // typical length of text line:
   //         "|--------------------------------------------------------------|"
   Log() << Endl;
   Log() << gTools().Color("bold") << "--- Short description:" << gTools().Color("reset") << Endl;
   Log() << Endl;
   Log() << "This method combines several classifier of one species in a "<<Endl;
   Log() << "single multivariate quantity via the boost algorithm." << Endl;
   Log() << "the output is a weighted sum over all individual classifiers" <<Endl;
   Log() << "By default, the AdaBoost method is employed, which gives " << Endl;
   Log() << "events that were misclassified in the previous tree a larger " << Endl;
   Log() << "weight in the training of the following classifier."<<Endl;
   Log() << "Optionally, Bagged boosting can also be applied." << Endl;
   Log() << Endl;
   Log() << gTools().Color("bold") << "--- Performance tuning via configuration options:" << gTools().Color("reset") << Endl;
   Log() << Endl;
   Log() << "The most important parameter in the configuration is the "<<Endl;
   Log() << "number of boosts applied (Boost_Num) and the choice of boosting"<<Endl;
   Log() << "(Boost_Type), which can be set to either AdaBoost or Bagging." << Endl;
   Log() << "AdaBoosting: The most important parameters in this configuration" <<Endl;
   Log() << "is the beta parameter (Boost_AdaBoostBeta)  " << Endl;
   Log() << "When boosting a linear classifier, it is sometimes advantageous"<<Endl; 
   Log() << "to transform the MVA output non-linearly. The following options" <<Endl;
   Log() << "are available: step, log, and minmax, the default is no transform."<<Endl;
   Log() <<Endl;
   Log() << "Some classifiers are hard to boost and do not improve much in"<<Endl; 
   Log() << "their performance by boosting them, some even slightly deteriorate"<< Endl;
   Log() << "due to the boosting." <<Endl;
   Log() << "The booking of the boost method is special since it requires"<<Endl;
   Log() << "the booing of the method to be boosted and the boost itself."<<Endl;
   Log() << "This is solved by booking the method to be boosted and to add"<<Endl;
   Log() << "all Boost parameters, which all begin with \"Boost_\" to the"<<Endl;
   Log() << "options string. The factory separates the options and initiates"<<Endl;
   Log() << "the boost process. The TMVA macro directory contains the example"<<Endl;
   Log() << "macro \"Boost.C\"" <<Endl;
}

//_______________________________________________________________________
const TMVA::Ranking* TMVA::MethodBoost::CreateRanking()
{ 
   return 0;
}

//_______________________________________________________________________
Double_t TMVA::MethodBoost::GetMvaValue( Double_t* err, Double_t* errUpper )
{
   // return boosted MVA response
   Double_t mvaValue = 0;
   Double_t epsilon = TMath::Exp(-1.);
   //Double_t fact    = TMath::Exp(-1.)+TMath::Exp(1.);
   for (UInt_t i=0;i< fMethods.size(); i++){
      MethodBase* m = dynamic_cast<MethodBase*>(fMethods[i]);
      if (m==0) continue;
      Double_t val = fTmpEvent ? m->GetMvaValue(fTmpEvent) : m->GetMvaValue();
      Double_t sigcut = m->GetSignalReferenceCut();
      
      // default is no transform
      if (fTransformString == "linear"){

      }
      else if (fTransformString == "log"){
         if (val < sigcut) val = sigcut;

         val = TMath::Log((val-sigcut)+epsilon);
      }
      else if (fTransformString == "step" ){
         if (m->IsSignalLike(val)) val = 1.;
         else val = -1.;
      }
      else if (fTransformString == "gauss"){
         val = TMath::Gaus((val-sigcut),1);
      }
      else {
         Log() << kFATAL << "error unknown transformation " << fTransformString<<Endl;
      }
      mvaValue+=val*fMethodWeight[i];
   }
   // cannot determine error
   NoErrorCalc(err, errUpper);

   return mvaValue;
}

//_______________________________________________________________________
Double_t TMVA::MethodBoost::GetBoostROCIntegral(Bool_t singleMethod, Types::ETreeType eTT, Bool_t CalcOverlapIntergral)
{
   // Calculate the ROC integral of a single classifier or even the
   // whole boosted classifier.  The tree type (training or testing
   // sample) is specified by 'eTT'.
   //
   // If tree type kTraining is set, the original training sample is
   // used to compute the ROC integral (original weights).
   //
   // - singleMethod - if kTRUE, return ROC integral of single (last
   //                  trained) classifier; if kFALSE, return ROC
   //                  integral of full classifier
   //
   // - eTT - tree type (Types::kTraining / Types::kTesting)
   //
   // - CalcOverlapIntergral - if kTRUE, the overlap integral of the
   //                          signal/background MVA distributions
   //                          is calculated and stored in
   //                          'fOverlap_integral'

   // set data sample training / testing
   Data()->SetCurrentType(eTT);

   MethodBase* method = singleMethod ? dynamic_cast<MethodBase*>(fMethods.back()) : 0; // ToDo CoVerity flags this line as there is no prtection against a zero-pointer delivered by dynamic_cast
   // to make CoVerity happy (although, OF COURSE, the last method in the commitee
   // has to be also of type MethodBase as ANY method is... hence the dynamic_cast
   // will never by "zero" ...
   if (singleMethod && !method) {
      Log() << kFATAL << " What do you do? Your method:"
            << fMethods.back()->GetName() 
            << " seems not to be a propper TMVA method" 
            << Endl;
      std::exit(1);
   }
   Double_t err = 0.0;

   // temporary renormalize the method weights in case of evaluation
   // of full classifier.
   // save the old normalization of the methods
   std::vector<Double_t> OldMethodWeight(fMethodWeight);
   if (!singleMethod) {
      // calculate sum of weights of all methods
      Double_t AllMethodsWeight = 0;
      for (Int_t i=0; i<=fMethodIndex; i++)
         AllMethodsWeight += fMethodWeight.at(i);
      // normalize the weights of the classifiers
      if (fMethodWeightType == "LastMethod")
         fMethodWeight.back() = AllMethodsWeight = 1.0;
      if (AllMethodsWeight != 0.0) {
         for (Int_t i=0; i<=fMethodIndex; i++)
            fMethodWeight[i] /= AllMethodsWeight;
      }
   }

   // calculate MVA values
   Double_t meanS, meanB, rmsS, rmsB, xmin, xmax, nrms = 10;
   std::vector <Float_t>* mvaRes;
   if (singleMethod && eTT==Types::kTraining)
      mvaRes = fMVAvalues; // values already calculated
   else {  
      mvaRes = new std::vector <Float_t>(GetNEvents());
      for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
         GetEvent(ievt);
         (*mvaRes)[ievt] = singleMethod ? method->GetMvaValue(&err) : GetMvaValue(&err);
      }
   }

   // restore the method weights
   if (!singleMethod)
      fMethodWeight = OldMethodWeight;

   // now create histograms for calculation of the ROC integral
   Int_t signalClass = 0;
   if (DataInfo().GetClassInfo("Signal") != 0) {
      signalClass = DataInfo().GetClassInfo("Signal")->GetNumber();
   }
   gTools().ComputeStat( GetEventCollection(eTT), mvaRes,
                         meanS, meanB, rmsS, rmsB, xmin, xmax, signalClass );

   fNbins = gConfig().fVariablePlotting.fNbinsXOfROCCurve;
   xmin = TMath::Max( TMath::Min(meanS - nrms*rmsS, meanB - nrms*rmsB ), xmin );
   xmax = TMath::Min( TMath::Max(meanS + nrms*rmsS, meanB + nrms*rmsB ), xmax ) + 0.0001;

   // calculate ROC integral
   TH1* mva_s = new TH1F( "MVA_S", "MVA_S", fNbins, xmin, xmax );
   TH1* mva_b = new TH1F( "MVA_B", "MVA_B", fNbins, xmin, xmax );
   TH1 *mva_s_overlap=0, *mva_b_overlap=0;
   if (CalcOverlapIntergral) {
      mva_s_overlap = new TH1F( "MVA_S_OVERLAP", "MVA_S_OVERLAP", fNbins, xmin, xmax );
      mva_b_overlap = new TH1F( "MVA_B_OVERLAP", "MVA_B_OVERLAP", fNbins, xmin, xmax );
   }
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
      const Event* ev = GetEvent(ievt);
      Float_t w = (eTT==Types::kTesting ? ev->GetWeight() : ev->GetOriginalWeight());
      if (DataInfo().IsSignal(ev))  mva_s->Fill( (*mvaRes)[ievt], w );
      else                          mva_b->Fill( (*mvaRes)[ievt], w );

      if (CalcOverlapIntergral) {
	 Float_t w_ov = ev->GetWeight();
	 if (DataInfo().IsSignal(ev))  
	    mva_s_overlap->Fill( (*mvaRes)[ievt], w_ov );
	 else
	    mva_b_overlap->Fill( (*mvaRes)[ievt], w_ov );
      }
   }
   gTools().NormHist( mva_s );
   gTools().NormHist( mva_b );
   PDF *fS = new PDF( "PDF Sig", mva_s, PDF::kSpline2 );
   PDF *fB = new PDF( "PDF Bkg", mva_b, PDF::kSpline2 );

   // calculate ROC integral from fS, fB
   Double_t ROC = MethodBase::GetROCIntegral(fS, fB);
   
   // calculate overlap integral
   if (CalcOverlapIntergral) {
      gTools().NormHist( mva_s_overlap );
      gTools().NormHist( mva_b_overlap );

      fOverlap_integral = 0.0;
      for (Int_t bin=1; bin<=mva_s_overlap->GetNbinsX(); bin++){
	 Double_t bc_s = mva_s_overlap->GetBinContent(bin);
	 Double_t bc_b = mva_b_overlap->GetBinContent(bin);
	 if (bc_s > 0.0 && bc_b > 0.0)
	    fOverlap_integral += TMath::Min(bc_s, bc_b);
      }

      delete mva_s_overlap;
      delete mva_b_overlap;
   }

   delete mva_s;
   delete mva_b;
   delete fS;
   delete fB;
   if (!(singleMethod && eTT==Types::kTraining))  delete mvaRes;

   Data()->SetCurrentType(Types::kTraining);

   return ROC;
}

void TMVA::MethodBoost::CalcMVAValues()
{
   // Calculate MVA values of current method fMethods.back() on
   // training sample

   Data()->SetCurrentType(Types::kTraining);
   MethodBase* method = dynamic_cast<MethodBase*>(fMethods.back());
   if (!method) {
      Log() << kFATAL << "dynamic cast to MethodBase* failed" <<Endl;
      return;
   }
   // calculate MVA values
   for (Long64_t ievt=0; ievt<GetNEvents(); ievt++) {
      GetEvent(ievt);
      fMVAvalues->at(ievt) = method->GetMvaValue();
   }
}

 MethodBoost.cxx:1
 MethodBoost.cxx:2
 MethodBoost.cxx:3
 MethodBoost.cxx:4
 MethodBoost.cxx:5
 MethodBoost.cxx:6
 MethodBoost.cxx:7
 MethodBoost.cxx:8
 MethodBoost.cxx:9
 MethodBoost.cxx:10
 MethodBoost.cxx:11
 MethodBoost.cxx:12
 MethodBoost.cxx:13
 MethodBoost.cxx:14
 MethodBoost.cxx:15
 MethodBoost.cxx:16
 MethodBoost.cxx:17
 MethodBoost.cxx:18
 MethodBoost.cxx:19
 MethodBoost.cxx:20
 MethodBoost.cxx:21
 MethodBoost.cxx:22
 MethodBoost.cxx:23
 MethodBoost.cxx:24
 MethodBoost.cxx:25
 MethodBoost.cxx:26
 MethodBoost.cxx:27
 MethodBoost.cxx:28
 MethodBoost.cxx:29
 MethodBoost.cxx:30
 MethodBoost.cxx:31
 MethodBoost.cxx:32
 MethodBoost.cxx:33
 MethodBoost.cxx:34
 MethodBoost.cxx:35
 MethodBoost.cxx:36
 MethodBoost.cxx:37
 MethodBoost.cxx:38
 MethodBoost.cxx:39
 MethodBoost.cxx:40
 MethodBoost.cxx:41
 MethodBoost.cxx:42
 MethodBoost.cxx:43
 MethodBoost.cxx:44
 MethodBoost.cxx:45
 MethodBoost.cxx:46
 MethodBoost.cxx:47
 MethodBoost.cxx:48
 MethodBoost.cxx:49
 MethodBoost.cxx:50
 MethodBoost.cxx:51
 MethodBoost.cxx:52
 MethodBoost.cxx:53
 MethodBoost.cxx:54
 MethodBoost.cxx:55
 MethodBoost.cxx:56
 MethodBoost.cxx:57
 MethodBoost.cxx:58
 MethodBoost.cxx:59
 MethodBoost.cxx:60
 MethodBoost.cxx:61
 MethodBoost.cxx:62
 MethodBoost.cxx:63
 MethodBoost.cxx:64
 MethodBoost.cxx:65
 MethodBoost.cxx:66
 MethodBoost.cxx:67
 MethodBoost.cxx:68
 MethodBoost.cxx:69
 MethodBoost.cxx:70
 MethodBoost.cxx:71
 MethodBoost.cxx:72
 MethodBoost.cxx:73
 MethodBoost.cxx:74
 MethodBoost.cxx:75
 MethodBoost.cxx:76
 MethodBoost.cxx:77
 MethodBoost.cxx:78
 MethodBoost.cxx:79
 MethodBoost.cxx:80
 MethodBoost.cxx:81
 MethodBoost.cxx:82
 MethodBoost.cxx:83
 MethodBoost.cxx:84
 MethodBoost.cxx:85
 MethodBoost.cxx:86
 MethodBoost.cxx:87
 MethodBoost.cxx:88
 MethodBoost.cxx:89
 MethodBoost.cxx:90
 MethodBoost.cxx:91
 MethodBoost.cxx:92
 MethodBoost.cxx:93
 MethodBoost.cxx:94
 MethodBoost.cxx:95
 MethodBoost.cxx:96
 MethodBoost.cxx:97
 MethodBoost.cxx:98
 MethodBoost.cxx:99
 MethodBoost.cxx:100
 MethodBoost.cxx:101
 MethodBoost.cxx:102
 MethodBoost.cxx:103
 MethodBoost.cxx:104
 MethodBoost.cxx:105
 MethodBoost.cxx:106
 MethodBoost.cxx:107
 MethodBoost.cxx:108
 MethodBoost.cxx:109
 MethodBoost.cxx:110
 MethodBoost.cxx:111
 MethodBoost.cxx:112
 MethodBoost.cxx:113
 MethodBoost.cxx:114
 MethodBoost.cxx:115
 MethodBoost.cxx:116
 MethodBoost.cxx:117
 MethodBoost.cxx:118
 MethodBoost.cxx:119
 MethodBoost.cxx:120
 MethodBoost.cxx:121
 MethodBoost.cxx:122
 MethodBoost.cxx:123
 MethodBoost.cxx:124
 MethodBoost.cxx:125
 MethodBoost.cxx:126
 MethodBoost.cxx:127
 MethodBoost.cxx:128
 MethodBoost.cxx:129
 MethodBoost.cxx:130
 MethodBoost.cxx:131
 MethodBoost.cxx:132
 MethodBoost.cxx:133
 MethodBoost.cxx:134
 MethodBoost.cxx:135
 MethodBoost.cxx:136
 MethodBoost.cxx:137
 MethodBoost.cxx:138
 MethodBoost.cxx:139
 MethodBoost.cxx:140
 MethodBoost.cxx:141
 MethodBoost.cxx:142
 MethodBoost.cxx:143
 MethodBoost.cxx:144
 MethodBoost.cxx:145
 MethodBoost.cxx:146
 MethodBoost.cxx:147
 MethodBoost.cxx:148
 MethodBoost.cxx:149
 MethodBoost.cxx:150
 MethodBoost.cxx:151
 MethodBoost.cxx:152
 MethodBoost.cxx:153
 MethodBoost.cxx:154
 MethodBoost.cxx:155
 MethodBoost.cxx:156
 MethodBoost.cxx:157
 MethodBoost.cxx:158
 MethodBoost.cxx:159
 MethodBoost.cxx:160
 MethodBoost.cxx:161
 MethodBoost.cxx:162
 MethodBoost.cxx:163
 MethodBoost.cxx:164
 MethodBoost.cxx:165
 MethodBoost.cxx:166
 MethodBoost.cxx:167
 MethodBoost.cxx:168
 MethodBoost.cxx:169
 MethodBoost.cxx:170
 MethodBoost.cxx:171
 MethodBoost.cxx:172
 MethodBoost.cxx:173
 MethodBoost.cxx:174
 MethodBoost.cxx:175
 MethodBoost.cxx:176
 MethodBoost.cxx:177
 MethodBoost.cxx:178
 MethodBoost.cxx:179
 MethodBoost.cxx:180
 MethodBoost.cxx:181
 MethodBoost.cxx:182
 MethodBoost.cxx:183
 MethodBoost.cxx:184
 MethodBoost.cxx:185
 MethodBoost.cxx:186
 MethodBoost.cxx:187
 MethodBoost.cxx:188
 MethodBoost.cxx:189
 MethodBoost.cxx:190
 MethodBoost.cxx:191
 MethodBoost.cxx:192
 MethodBoost.cxx:193
 MethodBoost.cxx:194
 MethodBoost.cxx:195
 MethodBoost.cxx:196
 MethodBoost.cxx:197
 MethodBoost.cxx:198
 MethodBoost.cxx:199
 MethodBoost.cxx:200
 MethodBoost.cxx:201
 MethodBoost.cxx:202
 MethodBoost.cxx:203
 MethodBoost.cxx:204
 MethodBoost.cxx:205
 MethodBoost.cxx:206
 MethodBoost.cxx:207
 MethodBoost.cxx:208
 MethodBoost.cxx:209
 MethodBoost.cxx:210
 MethodBoost.cxx:211
 MethodBoost.cxx:212
 MethodBoost.cxx:213
 MethodBoost.cxx:214
 MethodBoost.cxx:215
 MethodBoost.cxx:216
 MethodBoost.cxx:217
 MethodBoost.cxx:218
 MethodBoost.cxx:219
 MethodBoost.cxx:220
 MethodBoost.cxx:221
 MethodBoost.cxx:222
 MethodBoost.cxx:223
 MethodBoost.cxx:224
 MethodBoost.cxx:225
 MethodBoost.cxx:226
 MethodBoost.cxx:227
 MethodBoost.cxx:228
 MethodBoost.cxx:229
 MethodBoost.cxx:230
 MethodBoost.cxx:231
 MethodBoost.cxx:232
 MethodBoost.cxx:233
 MethodBoost.cxx:234
 MethodBoost.cxx:235
 MethodBoost.cxx:236
 MethodBoost.cxx:237
 MethodBoost.cxx:238
 MethodBoost.cxx:239
 MethodBoost.cxx:240
 MethodBoost.cxx:241
 MethodBoost.cxx:242
 MethodBoost.cxx:243
 MethodBoost.cxx:244
 MethodBoost.cxx:245
 MethodBoost.cxx:246
 MethodBoost.cxx:247
 MethodBoost.cxx:248
 MethodBoost.cxx:249
 MethodBoost.cxx:250
 MethodBoost.cxx:251
 MethodBoost.cxx:252
 MethodBoost.cxx:253
 MethodBoost.cxx:254
 MethodBoost.cxx:255
 MethodBoost.cxx:256
 MethodBoost.cxx:257
 MethodBoost.cxx:258
 MethodBoost.cxx:259
 MethodBoost.cxx:260
 MethodBoost.cxx:261
 MethodBoost.cxx:262
 MethodBoost.cxx:263
 MethodBoost.cxx:264
 MethodBoost.cxx:265
 MethodBoost.cxx:266
 MethodBoost.cxx:267
 MethodBoost.cxx:268
 MethodBoost.cxx:269
 MethodBoost.cxx:270
 MethodBoost.cxx:271
 MethodBoost.cxx:272
 MethodBoost.cxx:273
 MethodBoost.cxx:274
 MethodBoost.cxx:275
 MethodBoost.cxx:276
 MethodBoost.cxx:277
 MethodBoost.cxx:278
 MethodBoost.cxx:279
 MethodBoost.cxx:280
 MethodBoost.cxx:281
 MethodBoost.cxx:282
 MethodBoost.cxx:283
 MethodBoost.cxx:284
 MethodBoost.cxx:285
 MethodBoost.cxx:286
 MethodBoost.cxx:287
 MethodBoost.cxx:288
 MethodBoost.cxx:289
 MethodBoost.cxx:290
 MethodBoost.cxx:291
 MethodBoost.cxx:292
 MethodBoost.cxx:293
 MethodBoost.cxx:294
 MethodBoost.cxx:295
 MethodBoost.cxx:296
 MethodBoost.cxx:297
 MethodBoost.cxx:298
 MethodBoost.cxx:299
 MethodBoost.cxx:300
 MethodBoost.cxx:301
 MethodBoost.cxx:302
 MethodBoost.cxx:303
 MethodBoost.cxx:304
 MethodBoost.cxx:305
 MethodBoost.cxx:306
 MethodBoost.cxx:307
 MethodBoost.cxx:308
 MethodBoost.cxx:309
 MethodBoost.cxx:310
 MethodBoost.cxx:311
 MethodBoost.cxx:312
 MethodBoost.cxx:313
 MethodBoost.cxx:314
 MethodBoost.cxx:315
 MethodBoost.cxx:316
 MethodBoost.cxx:317
 MethodBoost.cxx:318
 MethodBoost.cxx:319
 MethodBoost.cxx:320
 MethodBoost.cxx:321
 MethodBoost.cxx:322
 MethodBoost.cxx:323
 MethodBoost.cxx:324
 MethodBoost.cxx:325
 MethodBoost.cxx:326
 MethodBoost.cxx:327
 MethodBoost.cxx:328
 MethodBoost.cxx:329
 MethodBoost.cxx:330
 MethodBoost.cxx:331
 MethodBoost.cxx:332
 MethodBoost.cxx:333
 MethodBoost.cxx:334
 MethodBoost.cxx:335
 MethodBoost.cxx:336
 MethodBoost.cxx:337
 MethodBoost.cxx:338
 MethodBoost.cxx:339
 MethodBoost.cxx:340
 MethodBoost.cxx:341
 MethodBoost.cxx:342
 MethodBoost.cxx:343
 MethodBoost.cxx:344
 MethodBoost.cxx:345
 MethodBoost.cxx:346
 MethodBoost.cxx:347
 MethodBoost.cxx:348
 MethodBoost.cxx:349
 MethodBoost.cxx:350
 MethodBoost.cxx:351
 MethodBoost.cxx:352
 MethodBoost.cxx:353
 MethodBoost.cxx:354
 MethodBoost.cxx:355
 MethodBoost.cxx:356
 MethodBoost.cxx:357
 MethodBoost.cxx:358
 MethodBoost.cxx:359
 MethodBoost.cxx:360
 MethodBoost.cxx:361
 MethodBoost.cxx:362
 MethodBoost.cxx:363
 MethodBoost.cxx:364
 MethodBoost.cxx:365
 MethodBoost.cxx:366
 MethodBoost.cxx:367
 MethodBoost.cxx:368
 MethodBoost.cxx:369
 MethodBoost.cxx:370
 MethodBoost.cxx:371
 MethodBoost.cxx:372
 MethodBoost.cxx:373
 MethodBoost.cxx:374
 MethodBoost.cxx:375
 MethodBoost.cxx:376
 MethodBoost.cxx:377
 MethodBoost.cxx:378
 MethodBoost.cxx:379
 MethodBoost.cxx:380
 MethodBoost.cxx:381
 MethodBoost.cxx:382
 MethodBoost.cxx:383
 MethodBoost.cxx:384
 MethodBoost.cxx:385
 MethodBoost.cxx:386
 MethodBoost.cxx:387
 MethodBoost.cxx:388
 MethodBoost.cxx:389
 MethodBoost.cxx:390
 MethodBoost.cxx:391
 MethodBoost.cxx:392
 MethodBoost.cxx:393
 MethodBoost.cxx:394
 MethodBoost.cxx:395
 MethodBoost.cxx:396
 MethodBoost.cxx:397
 MethodBoost.cxx:398
 MethodBoost.cxx:399
 MethodBoost.cxx:400
 MethodBoost.cxx:401
 MethodBoost.cxx:402
 MethodBoost.cxx:403
 MethodBoost.cxx:404
 MethodBoost.cxx:405
 MethodBoost.cxx:406
 MethodBoost.cxx:407
 MethodBoost.cxx:408
 MethodBoost.cxx:409
 MethodBoost.cxx:410
 MethodBoost.cxx:411
 MethodBoost.cxx:412
 MethodBoost.cxx:413
 MethodBoost.cxx:414
 MethodBoost.cxx:415
 MethodBoost.cxx:416
 MethodBoost.cxx:417
 MethodBoost.cxx:418
 MethodBoost.cxx:419
 MethodBoost.cxx:420
 MethodBoost.cxx:421
 MethodBoost.cxx:422
 MethodBoost.cxx:423
 MethodBoost.cxx:424
 MethodBoost.cxx:425
 MethodBoost.cxx:426
 MethodBoost.cxx:427
 MethodBoost.cxx:428
 MethodBoost.cxx:429
 MethodBoost.cxx:430
 MethodBoost.cxx:431
 MethodBoost.cxx:432
 MethodBoost.cxx:433
 MethodBoost.cxx:434
 MethodBoost.cxx:435
 MethodBoost.cxx:436
 MethodBoost.cxx:437
 MethodBoost.cxx:438
 MethodBoost.cxx:439
 MethodBoost.cxx:440
 MethodBoost.cxx:441
 MethodBoost.cxx:442
 MethodBoost.cxx:443
 MethodBoost.cxx:444
 MethodBoost.cxx:445
 MethodBoost.cxx:446
 MethodBoost.cxx:447
 MethodBoost.cxx:448
 MethodBoost.cxx:449
 MethodBoost.cxx:450
 MethodBoost.cxx:451
 MethodBoost.cxx:452
 MethodBoost.cxx:453
 MethodBoost.cxx:454
 MethodBoost.cxx:455
 MethodBoost.cxx:456
 MethodBoost.cxx:457
 MethodBoost.cxx:458
 MethodBoost.cxx:459
 MethodBoost.cxx:460
 MethodBoost.cxx:461
 MethodBoost.cxx:462
 MethodBoost.cxx:463
 MethodBoost.cxx:464
 MethodBoost.cxx:465
 MethodBoost.cxx:466
 MethodBoost.cxx:467
 MethodBoost.cxx:468
 MethodBoost.cxx:469
 MethodBoost.cxx:470
 MethodBoost.cxx:471
 MethodBoost.cxx:472
 MethodBoost.cxx:473
 MethodBoost.cxx:474
 MethodBoost.cxx:475
 MethodBoost.cxx:476
 MethodBoost.cxx:477
 MethodBoost.cxx:478
 MethodBoost.cxx:479
 MethodBoost.cxx:480
 MethodBoost.cxx:481
 MethodBoost.cxx:482
 MethodBoost.cxx:483
 MethodBoost.cxx:484
 MethodBoost.cxx:485
 MethodBoost.cxx:486
 MethodBoost.cxx:487
 MethodBoost.cxx:488
 MethodBoost.cxx:489
 MethodBoost.cxx:490
 MethodBoost.cxx:491
 MethodBoost.cxx:492
 MethodBoost.cxx:493
 MethodBoost.cxx:494
 MethodBoost.cxx:495
 MethodBoost.cxx:496
 MethodBoost.cxx:497
 MethodBoost.cxx:498
 MethodBoost.cxx:499
 MethodBoost.cxx:500
 MethodBoost.cxx:501
 MethodBoost.cxx:502
 MethodBoost.cxx:503
 MethodBoost.cxx:504
 MethodBoost.cxx:505
 MethodBoost.cxx:506
 MethodBoost.cxx:507
 MethodBoost.cxx:508
 MethodBoost.cxx:509
 MethodBoost.cxx:510
 MethodBoost.cxx:511
 MethodBoost.cxx:512
 MethodBoost.cxx:513
 MethodBoost.cxx:514
 MethodBoost.cxx:515
 MethodBoost.cxx:516
 MethodBoost.cxx:517
 MethodBoost.cxx:518
 MethodBoost.cxx:519
 MethodBoost.cxx:520
 MethodBoost.cxx:521
 MethodBoost.cxx:522
 MethodBoost.cxx:523
 MethodBoost.cxx:524
 MethodBoost.cxx:525
 MethodBoost.cxx:526
 MethodBoost.cxx:527
 MethodBoost.cxx:528
 MethodBoost.cxx:529
 MethodBoost.cxx:530
 MethodBoost.cxx:531
 MethodBoost.cxx:532
 MethodBoost.cxx:533
 MethodBoost.cxx:534
 MethodBoost.cxx:535
 MethodBoost.cxx:536
 MethodBoost.cxx:537
 MethodBoost.cxx:538
 MethodBoost.cxx:539
 MethodBoost.cxx:540
 MethodBoost.cxx:541
 MethodBoost.cxx:542
 MethodBoost.cxx:543
 MethodBoost.cxx:544
 MethodBoost.cxx:545
 MethodBoost.cxx:546
 MethodBoost.cxx:547
 MethodBoost.cxx:548
 MethodBoost.cxx:549
 MethodBoost.cxx:550
 MethodBoost.cxx:551
 MethodBoost.cxx:552
 MethodBoost.cxx:553
 MethodBoost.cxx:554
 MethodBoost.cxx:555
 MethodBoost.cxx:556
 MethodBoost.cxx:557
 MethodBoost.cxx:558
 MethodBoost.cxx:559
 MethodBoost.cxx:560
 MethodBoost.cxx:561
 MethodBoost.cxx:562
 MethodBoost.cxx:563
 MethodBoost.cxx:564
 MethodBoost.cxx:565
 MethodBoost.cxx:566
 MethodBoost.cxx:567
 MethodBoost.cxx:568
 MethodBoost.cxx:569
 MethodBoost.cxx:570
 MethodBoost.cxx:571
 MethodBoost.cxx:572
 MethodBoost.cxx:573
 MethodBoost.cxx:574
 MethodBoost.cxx:575
 MethodBoost.cxx:576
 MethodBoost.cxx:577
 MethodBoost.cxx:578
 MethodBoost.cxx:579
 MethodBoost.cxx:580
 MethodBoost.cxx:581
 MethodBoost.cxx:582
 MethodBoost.cxx:583
 MethodBoost.cxx:584
 MethodBoost.cxx:585
 MethodBoost.cxx:586
 MethodBoost.cxx:587
 MethodBoost.cxx:588
 MethodBoost.cxx:589
 MethodBoost.cxx:590
 MethodBoost.cxx:591
 MethodBoost.cxx:592
 MethodBoost.cxx:593
 MethodBoost.cxx:594
 MethodBoost.cxx:595
 MethodBoost.cxx:596
 MethodBoost.cxx:597
 MethodBoost.cxx:598
 MethodBoost.cxx:599
 MethodBoost.cxx:600
 MethodBoost.cxx:601
 MethodBoost.cxx:602
 MethodBoost.cxx:603
 MethodBoost.cxx:604
 MethodBoost.cxx:605
 MethodBoost.cxx:606
 MethodBoost.cxx:607
 MethodBoost.cxx:608
 MethodBoost.cxx:609
 MethodBoost.cxx:610
 MethodBoost.cxx:611
 MethodBoost.cxx:612
 MethodBoost.cxx:613
 MethodBoost.cxx:614
 MethodBoost.cxx:615
 MethodBoost.cxx:616
 MethodBoost.cxx:617
 MethodBoost.cxx:618
 MethodBoost.cxx:619
 MethodBoost.cxx:620
 MethodBoost.cxx:621
 MethodBoost.cxx:622
 MethodBoost.cxx:623
 MethodBoost.cxx:624
 MethodBoost.cxx:625
 MethodBoost.cxx:626
 MethodBoost.cxx:627
 MethodBoost.cxx:628
 MethodBoost.cxx:629
 MethodBoost.cxx:630
 MethodBoost.cxx:631
 MethodBoost.cxx:632
 MethodBoost.cxx:633
 MethodBoost.cxx:634
 MethodBoost.cxx:635
 MethodBoost.cxx:636
 MethodBoost.cxx:637
 MethodBoost.cxx:638
 MethodBoost.cxx:639
 MethodBoost.cxx:640
 MethodBoost.cxx:641
 MethodBoost.cxx:642
 MethodBoost.cxx:643
 MethodBoost.cxx:644
 MethodBoost.cxx:645
 MethodBoost.cxx:646
 MethodBoost.cxx:647
 MethodBoost.cxx:648
 MethodBoost.cxx:649
 MethodBoost.cxx:650
 MethodBoost.cxx:651
 MethodBoost.cxx:652
 MethodBoost.cxx:653
 MethodBoost.cxx:654
 MethodBoost.cxx:655
 MethodBoost.cxx:656
 MethodBoost.cxx:657
 MethodBoost.cxx:658
 MethodBoost.cxx:659
 MethodBoost.cxx:660
 MethodBoost.cxx:661
 MethodBoost.cxx:662
 MethodBoost.cxx:663
 MethodBoost.cxx:664
 MethodBoost.cxx:665
 MethodBoost.cxx:666
 MethodBoost.cxx:667
 MethodBoost.cxx:668
 MethodBoost.cxx:669
 MethodBoost.cxx:670
 MethodBoost.cxx:671
 MethodBoost.cxx:672
 MethodBoost.cxx:673
 MethodBoost.cxx:674
 MethodBoost.cxx:675
 MethodBoost.cxx:676
 MethodBoost.cxx:677
 MethodBoost.cxx:678
 MethodBoost.cxx:679
 MethodBoost.cxx:680
 MethodBoost.cxx:681
 MethodBoost.cxx:682
 MethodBoost.cxx:683
 MethodBoost.cxx:684
 MethodBoost.cxx:685
 MethodBoost.cxx:686
 MethodBoost.cxx:687
 MethodBoost.cxx:688
 MethodBoost.cxx:689
 MethodBoost.cxx:690
 MethodBoost.cxx:691
 MethodBoost.cxx:692
 MethodBoost.cxx:693
 MethodBoost.cxx:694
 MethodBoost.cxx:695
 MethodBoost.cxx:696
 MethodBoost.cxx:697
 MethodBoost.cxx:698
 MethodBoost.cxx:699
 MethodBoost.cxx:700
 MethodBoost.cxx:701
 MethodBoost.cxx:702
 MethodBoost.cxx:703
 MethodBoost.cxx:704
 MethodBoost.cxx:705
 MethodBoost.cxx:706
 MethodBoost.cxx:707
 MethodBoost.cxx:708
 MethodBoost.cxx:709
 MethodBoost.cxx:710
 MethodBoost.cxx:711
 MethodBoost.cxx:712
 MethodBoost.cxx:713
 MethodBoost.cxx:714
 MethodBoost.cxx:715
 MethodBoost.cxx:716
 MethodBoost.cxx:717
 MethodBoost.cxx:718
 MethodBoost.cxx:719
 MethodBoost.cxx:720
 MethodBoost.cxx:721
 MethodBoost.cxx:722
 MethodBoost.cxx:723
 MethodBoost.cxx:724
 MethodBoost.cxx:725
 MethodBoost.cxx:726
 MethodBoost.cxx:727
 MethodBoost.cxx:728
 MethodBoost.cxx:729
 MethodBoost.cxx:730
 MethodBoost.cxx:731
 MethodBoost.cxx:732
 MethodBoost.cxx:733
 MethodBoost.cxx:734
 MethodBoost.cxx:735
 MethodBoost.cxx:736
 MethodBoost.cxx:737
 MethodBoost.cxx:738
 MethodBoost.cxx:739
 MethodBoost.cxx:740
 MethodBoost.cxx:741
 MethodBoost.cxx:742
 MethodBoost.cxx:743
 MethodBoost.cxx:744
 MethodBoost.cxx:745
 MethodBoost.cxx:746
 MethodBoost.cxx:747
 MethodBoost.cxx:748
 MethodBoost.cxx:749
 MethodBoost.cxx:750
 MethodBoost.cxx:751
 MethodBoost.cxx:752
 MethodBoost.cxx:753
 MethodBoost.cxx:754
 MethodBoost.cxx:755
 MethodBoost.cxx:756
 MethodBoost.cxx:757
 MethodBoost.cxx:758
 MethodBoost.cxx:759
 MethodBoost.cxx:760
 MethodBoost.cxx:761
 MethodBoost.cxx:762
 MethodBoost.cxx:763
 MethodBoost.cxx:764
 MethodBoost.cxx:765
 MethodBoost.cxx:766
 MethodBoost.cxx:767
 MethodBoost.cxx:768
 MethodBoost.cxx:769
 MethodBoost.cxx:770
 MethodBoost.cxx:771
 MethodBoost.cxx:772
 MethodBoost.cxx:773
 MethodBoost.cxx:774
 MethodBoost.cxx:775
 MethodBoost.cxx:776
 MethodBoost.cxx:777
 MethodBoost.cxx:778
 MethodBoost.cxx:779
 MethodBoost.cxx:780
 MethodBoost.cxx:781
 MethodBoost.cxx:782
 MethodBoost.cxx:783
 MethodBoost.cxx:784
 MethodBoost.cxx:785
 MethodBoost.cxx:786
 MethodBoost.cxx:787
 MethodBoost.cxx:788
 MethodBoost.cxx:789
 MethodBoost.cxx:790
 MethodBoost.cxx:791
 MethodBoost.cxx:792
 MethodBoost.cxx:793
 MethodBoost.cxx:794
 MethodBoost.cxx:795
 MethodBoost.cxx:796
 MethodBoost.cxx:797
 MethodBoost.cxx:798
 MethodBoost.cxx:799
 MethodBoost.cxx:800
 MethodBoost.cxx:801
 MethodBoost.cxx:802
 MethodBoost.cxx:803
 MethodBoost.cxx:804
 MethodBoost.cxx:805
 MethodBoost.cxx:806
 MethodBoost.cxx:807
 MethodBoost.cxx:808
 MethodBoost.cxx:809
 MethodBoost.cxx:810
 MethodBoost.cxx:811
 MethodBoost.cxx:812
 MethodBoost.cxx:813
 MethodBoost.cxx:814
 MethodBoost.cxx:815
 MethodBoost.cxx:816
 MethodBoost.cxx:817
 MethodBoost.cxx:818
 MethodBoost.cxx:819
 MethodBoost.cxx:820
 MethodBoost.cxx:821
 MethodBoost.cxx:822
 MethodBoost.cxx:823
 MethodBoost.cxx:824
 MethodBoost.cxx:825
 MethodBoost.cxx:826
 MethodBoost.cxx:827
 MethodBoost.cxx:828
 MethodBoost.cxx:829
 MethodBoost.cxx:830
 MethodBoost.cxx:831
 MethodBoost.cxx:832
 MethodBoost.cxx:833
 MethodBoost.cxx:834
 MethodBoost.cxx:835
 MethodBoost.cxx:836
 MethodBoost.cxx:837
 MethodBoost.cxx:838
 MethodBoost.cxx:839
 MethodBoost.cxx:840
 MethodBoost.cxx:841
 MethodBoost.cxx:842
 MethodBoost.cxx:843
 MethodBoost.cxx:844
 MethodBoost.cxx:845
 MethodBoost.cxx:846
 MethodBoost.cxx:847
 MethodBoost.cxx:848
 MethodBoost.cxx:849
 MethodBoost.cxx:850
 MethodBoost.cxx:851
 MethodBoost.cxx:852
 MethodBoost.cxx:853
 MethodBoost.cxx:854
 MethodBoost.cxx:855
 MethodBoost.cxx:856
 MethodBoost.cxx:857
 MethodBoost.cxx:858
 MethodBoost.cxx:859
 MethodBoost.cxx:860
 MethodBoost.cxx:861
 MethodBoost.cxx:862
 MethodBoost.cxx:863
 MethodBoost.cxx:864
 MethodBoost.cxx:865
 MethodBoost.cxx:866
 MethodBoost.cxx:867
 MethodBoost.cxx:868
 MethodBoost.cxx:869
 MethodBoost.cxx:870
 MethodBoost.cxx:871
 MethodBoost.cxx:872
 MethodBoost.cxx:873
 MethodBoost.cxx:874
 MethodBoost.cxx:875
 MethodBoost.cxx:876
 MethodBoost.cxx:877
 MethodBoost.cxx:878
 MethodBoost.cxx:879
 MethodBoost.cxx:880
 MethodBoost.cxx:881
 MethodBoost.cxx:882
 MethodBoost.cxx:883
 MethodBoost.cxx:884
 MethodBoost.cxx:885
 MethodBoost.cxx:886
 MethodBoost.cxx:887
 MethodBoost.cxx:888
 MethodBoost.cxx:889
 MethodBoost.cxx:890
 MethodBoost.cxx:891
 MethodBoost.cxx:892
 MethodBoost.cxx:893
 MethodBoost.cxx:894
 MethodBoost.cxx:895
 MethodBoost.cxx:896
 MethodBoost.cxx:897
 MethodBoost.cxx:898
 MethodBoost.cxx:899
 MethodBoost.cxx:900
 MethodBoost.cxx:901
 MethodBoost.cxx:902
 MethodBoost.cxx:903
 MethodBoost.cxx:904
 MethodBoost.cxx:905
 MethodBoost.cxx:906
 MethodBoost.cxx:907
 MethodBoost.cxx:908
 MethodBoost.cxx:909
 MethodBoost.cxx:910
 MethodBoost.cxx:911
 MethodBoost.cxx:912
 MethodBoost.cxx:913
 MethodBoost.cxx:914
 MethodBoost.cxx:915
 MethodBoost.cxx:916
 MethodBoost.cxx:917
 MethodBoost.cxx:918
 MethodBoost.cxx:919
 MethodBoost.cxx:920
 MethodBoost.cxx:921
 MethodBoost.cxx:922
 MethodBoost.cxx:923
 MethodBoost.cxx:924
 MethodBoost.cxx:925
 MethodBoost.cxx:926
 MethodBoost.cxx:927
 MethodBoost.cxx:928
 MethodBoost.cxx:929
 MethodBoost.cxx:930
 MethodBoost.cxx:931
 MethodBoost.cxx:932
 MethodBoost.cxx:933
 MethodBoost.cxx:934
 MethodBoost.cxx:935
 MethodBoost.cxx:936
 MethodBoost.cxx:937
 MethodBoost.cxx:938
 MethodBoost.cxx:939
 MethodBoost.cxx:940
 MethodBoost.cxx:941
 MethodBoost.cxx:942
 MethodBoost.cxx:943
 MethodBoost.cxx:944
 MethodBoost.cxx:945
 MethodBoost.cxx:946
 MethodBoost.cxx:947
 MethodBoost.cxx:948
 MethodBoost.cxx:949
 MethodBoost.cxx:950
 MethodBoost.cxx:951
 MethodBoost.cxx:952
 MethodBoost.cxx:953
 MethodBoost.cxx:954
 MethodBoost.cxx:955
 MethodBoost.cxx:956
 MethodBoost.cxx:957
 MethodBoost.cxx:958
 MethodBoost.cxx:959
 MethodBoost.cxx:960
 MethodBoost.cxx:961
 MethodBoost.cxx:962
 MethodBoost.cxx:963
 MethodBoost.cxx:964
 MethodBoost.cxx:965
 MethodBoost.cxx:966
 MethodBoost.cxx:967
 MethodBoost.cxx:968
 MethodBoost.cxx:969
 MethodBoost.cxx:970
 MethodBoost.cxx:971
 MethodBoost.cxx:972
 MethodBoost.cxx:973
 MethodBoost.cxx:974
 MethodBoost.cxx:975
 MethodBoost.cxx:976
 MethodBoost.cxx:977
 MethodBoost.cxx:978
 MethodBoost.cxx:979
 MethodBoost.cxx:980
 MethodBoost.cxx:981
 MethodBoost.cxx:982
 MethodBoost.cxx:983
 MethodBoost.cxx:984
 MethodBoost.cxx:985
 MethodBoost.cxx:986
 MethodBoost.cxx:987
 MethodBoost.cxx:988
 MethodBoost.cxx:989
 MethodBoost.cxx:990
 MethodBoost.cxx:991
 MethodBoost.cxx:992
 MethodBoost.cxx:993
 MethodBoost.cxx:994
 MethodBoost.cxx:995
 MethodBoost.cxx:996
 MethodBoost.cxx:997
 MethodBoost.cxx:998
 MethodBoost.cxx:999
 MethodBoost.cxx:1000
 MethodBoost.cxx:1001
 MethodBoost.cxx:1002
 MethodBoost.cxx:1003
 MethodBoost.cxx:1004
 MethodBoost.cxx:1005
 MethodBoost.cxx:1006
 MethodBoost.cxx:1007
 MethodBoost.cxx:1008
 MethodBoost.cxx:1009
 MethodBoost.cxx:1010
 MethodBoost.cxx:1011
 MethodBoost.cxx:1012
 MethodBoost.cxx:1013
 MethodBoost.cxx:1014
 MethodBoost.cxx:1015
 MethodBoost.cxx:1016
 MethodBoost.cxx:1017
 MethodBoost.cxx:1018
 MethodBoost.cxx:1019
 MethodBoost.cxx:1020
 MethodBoost.cxx:1021
 MethodBoost.cxx:1022
 MethodBoost.cxx:1023
 MethodBoost.cxx:1024
 MethodBoost.cxx:1025
 MethodBoost.cxx:1026
 MethodBoost.cxx:1027
 MethodBoost.cxx:1028
 MethodBoost.cxx:1029
 MethodBoost.cxx:1030
 MethodBoost.cxx:1031
 MethodBoost.cxx:1032
 MethodBoost.cxx:1033
 MethodBoost.cxx:1034
 MethodBoost.cxx:1035
 MethodBoost.cxx:1036
 MethodBoost.cxx:1037
 MethodBoost.cxx:1038
 MethodBoost.cxx:1039
 MethodBoost.cxx:1040
 MethodBoost.cxx:1041
 MethodBoost.cxx:1042
 MethodBoost.cxx:1043
 MethodBoost.cxx:1044
 MethodBoost.cxx:1045
 MethodBoost.cxx:1046
 MethodBoost.cxx:1047
 MethodBoost.cxx:1048
 MethodBoost.cxx:1049
 MethodBoost.cxx:1050
 MethodBoost.cxx:1051
 MethodBoost.cxx:1052
 MethodBoost.cxx:1053
 MethodBoost.cxx:1054
 MethodBoost.cxx:1055
 MethodBoost.cxx:1056
 MethodBoost.cxx:1057
 MethodBoost.cxx:1058
 MethodBoost.cxx:1059
 MethodBoost.cxx:1060
 MethodBoost.cxx:1061
 MethodBoost.cxx:1062
 MethodBoost.cxx:1063
 MethodBoost.cxx:1064
 MethodBoost.cxx:1065
 MethodBoost.cxx:1066
 MethodBoost.cxx:1067
 MethodBoost.cxx:1068
 MethodBoost.cxx:1069
 MethodBoost.cxx:1070
 MethodBoost.cxx:1071
 MethodBoost.cxx:1072
 MethodBoost.cxx:1073
 MethodBoost.cxx:1074
 MethodBoost.cxx:1075
 MethodBoost.cxx:1076
 MethodBoost.cxx:1077
 MethodBoost.cxx:1078
 MethodBoost.cxx:1079
 MethodBoost.cxx:1080
 MethodBoost.cxx:1081
 MethodBoost.cxx:1082
 MethodBoost.cxx:1083
 MethodBoost.cxx:1084
 MethodBoost.cxx:1085
 MethodBoost.cxx:1086
 MethodBoost.cxx:1087
 MethodBoost.cxx:1088
 MethodBoost.cxx:1089
 MethodBoost.cxx:1090
 MethodBoost.cxx:1091
 MethodBoost.cxx:1092
 MethodBoost.cxx:1093
 MethodBoost.cxx:1094
 MethodBoost.cxx:1095
 MethodBoost.cxx:1096
 MethodBoost.cxx:1097
 MethodBoost.cxx:1098
 MethodBoost.cxx:1099
 MethodBoost.cxx:1100
 MethodBoost.cxx:1101
 MethodBoost.cxx:1102
 MethodBoost.cxx:1103
 MethodBoost.cxx:1104
 MethodBoost.cxx:1105
 MethodBoost.cxx:1106
 MethodBoost.cxx:1107
 MethodBoost.cxx:1108
 MethodBoost.cxx:1109
 MethodBoost.cxx:1110
 MethodBoost.cxx:1111
 MethodBoost.cxx:1112
 MethodBoost.cxx:1113
 MethodBoost.cxx:1114
 MethodBoost.cxx:1115
 MethodBoost.cxx:1116
 MethodBoost.cxx:1117
 MethodBoost.cxx:1118
 MethodBoost.cxx:1119
 MethodBoost.cxx:1120
 MethodBoost.cxx:1121
 MethodBoost.cxx:1122
 MethodBoost.cxx:1123
 MethodBoost.cxx:1124
 MethodBoost.cxx:1125
 MethodBoost.cxx:1126
 MethodBoost.cxx:1127
 MethodBoost.cxx:1128
 MethodBoost.cxx:1129
 MethodBoost.cxx:1130
 MethodBoost.cxx:1131
 MethodBoost.cxx:1132
 MethodBoost.cxx:1133
 MethodBoost.cxx:1134
 MethodBoost.cxx:1135
 MethodBoost.cxx:1136
 MethodBoost.cxx:1137
 MethodBoost.cxx:1138
 MethodBoost.cxx:1139
 MethodBoost.cxx:1140
 MethodBoost.cxx:1141
 MethodBoost.cxx:1142
 MethodBoost.cxx:1143
 MethodBoost.cxx:1144
 MethodBoost.cxx:1145
 MethodBoost.cxx:1146
 MethodBoost.cxx:1147
 MethodBoost.cxx:1148
 MethodBoost.cxx:1149
 MethodBoost.cxx:1150
 MethodBoost.cxx:1151
 MethodBoost.cxx:1152
 MethodBoost.cxx:1153
 MethodBoost.cxx:1154
 MethodBoost.cxx:1155
 MethodBoost.cxx:1156
 MethodBoost.cxx:1157
 MethodBoost.cxx:1158
 MethodBoost.cxx:1159
 MethodBoost.cxx:1160
 MethodBoost.cxx:1161
 MethodBoost.cxx:1162
 MethodBoost.cxx:1163
 MethodBoost.cxx:1164
 MethodBoost.cxx:1165
 MethodBoost.cxx:1166
 MethodBoost.cxx:1167
 MethodBoost.cxx:1168
 MethodBoost.cxx:1169
 MethodBoost.cxx:1170
 MethodBoost.cxx:1171
 MethodBoost.cxx:1172
 MethodBoost.cxx:1173
 MethodBoost.cxx:1174
 MethodBoost.cxx:1175