From c933c105d2f7895bf61d7d92f763a652d6cda700 Mon Sep 17 00:00:00 2001 From: IftachSadeh Date: Mon, 3 Aug 2015 20:03:35 +0200 Subject: [PATCH] kd-tree var scaling for err calc --- src/ANNZ_err.cpp | 8 +++++--- src/CatFormat_wgtKNN.cpp | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ANNZ_err.cpp b/src/ANNZ_err.cpp index fc7fdc5..624e93d 100644 --- a/src/ANNZ_err.cpp +++ b/src/ANNZ_err.cpp @@ -221,10 +221,12 @@ void ANNZ::setupKdTreeKNN(TChain * aChainKnn, TFile *& knnErrOutFile, TMVA::Fact // transform the input variable // ----------------------------------------------------------------------------------------------------------- if(quantV[0] < quantV[1]) { - varScaled = (TString)"(("+inNamesVar[nMLMnow][nVarNow]+") - "+utils->floatToStr(quantV[0]) - +") * "+utils->floatToStr( 2/(quantV[1] - quantV[0]) )+" - 1"; + TString shiftStr = (TString)((quantV[0] > 0) ? " - " : " + ") + utils->floatToStr(fabs(quantV[0])); - TString varScaledFunc = varScaled; varScaledFunc.ReplaceAll(inNamesVar[nMLMnow][nVarNow],"x"); + varScaled = (TString)"(("+inNamesVar[nMLMnow][nVarNow]+")"+shiftStr+") * "+utils->floatToStr( 2/(quantV[1] - quantV[0]) )+" - 1"; + + TString varScaledFunc(varScaled); varScaledFunc.ReplaceAll(inNamesVar[nMLMnow][nVarNow],"x"); + inVarsScaleFunc[nMLMnow][nVarNow] = new TF1(varScaledFunc,varScaledFunc); //cout<<" ---> "< Transformation to range [-1,1] from "<floatToStr(valMin)+") * "+utils->floatToStr( 2/(valMax - valMin) )+" - 1"; + TString shiftStr = (TString)((valMin > 0) ? " - " : " + ") + utils->floatToStr(fabs(valMin)); + + varNamesScaled[nVarNow] = (TString)"(("+varNames[nVarNow]+") "+shiftStr+") * "+utils->floatToStr( 2/(valMax - valMin) )+" - 1"; aLOG(Log::INFO)<