From 3cad33b0ef9edddc7e186ad6253e7bc39b3f1084 Mon Sep 17 00:00:00 2001 From: Danilo Piparo <danilo.piparo@cern.ch> Date: Thu, 23 Oct 2014 16:25:13 +0200 Subject: [PATCH] Reduce the size of the TFormula instances used by the TNeurons --- hist/hist/inc/TFormula.h | 1 + hist/hist/src/TFormula.cxx | 13 +++++++++++++ math/mlp/src/TMultiLayerPerceptron.cxx | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/hist/hist/inc/TFormula.h b/hist/hist/inc/TFormula.h index 32de78d1565..729aa22a267 100644 --- a/hist/hist/inc/TFormula.h +++ b/hist/hist/inc/TFormula.h @@ -263,6 +263,7 @@ public: virtual void Update() {;} static void SetMaxima(Int_t maxop=1000, Int_t maxpar=1000, Int_t maxconst=1000); + static void GetMaxima(Int_t& maxop, Int_t& maxpar, Int_t& maxconst); ClassDef(TFormula,8) //The formula base class f(x,y,z,par) }; diff --git a/hist/hist/src/TFormula.cxx b/hist/hist/src/TFormula.cxx index efc62bc0854..9c7583a7b18 100644 --- a/hist/hist/src/TFormula.cxx +++ b/hist/hist/src/TFormula.cxx @@ -4461,3 +4461,16 @@ void TFormula::SetMaxima(Int_t maxop, Int_t maxpar, Int_t maxconst) gMAXPAR = TMath::Max(10,maxpar); gMAXCONST = TMath::Max(10,maxconst); } + +//______________________________________________________________________________ +void TFormula::GetMaxima(Int_t& maxop, Int_t& maxpar, Int_t& maxconst) +{ + // static function to get the maximum value of 3 parameters + // -maxop : maximum number of operations + // -maxpar : maximum number of parameters + // -maxconst : maximum number of constants + + maxop = gMAXOP; + maxpar = gMAXPAR; + maxconst = gMAXCONST; +} diff --git a/math/mlp/src/TMultiLayerPerceptron.cxx b/math/mlp/src/TMultiLayerPerceptron.cxx index 3f9aed1d489..650d7efa0b6 100644 --- a/math/mlp/src/TMultiLayerPerceptron.cxx +++ b/math/mlp/src/TMultiLayerPerceptron.cxx @@ -1194,6 +1194,12 @@ void TMultiLayerPerceptron::AttachData() TNeuron *neuron = 0; Bool_t normalize = false; fManager = new TTreeFormulaManager; + + // Set the size of the internal array of parameters of the formula + Int_t maxop, maxpar, maxconst; + TFormula::GetMaxima(maxop, maxpar, maxconst); + TFormula::SetMaxima(10, 10, 10); + //first layer const TString input = TString(fStructure(0, fStructure.First(':'))); const TObjArray *inpL = input.Tokenize(", "); @@ -1232,6 +1238,9 @@ void TMultiLayerPerceptron::AttachData() fManager->Add((fEventWeight = new TTreeFormula("NNweight",fWeight.Data(),fData))); //fManager->Sync(); + + // Set the old values + TFormula::SetMaxima(maxop, maxpar, maxconst); } //______________________________________________________________________________ -- GitLab