From b3dfed2dade582c1f9bb73317c6d5817fff46b31 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <mouginot.baptiste@gmail.com> Date: Thu, 7 Jan 2016 21:49:41 +0000 Subject: [PATCH] 1 add Setter for the Model in PhysicsModels: SetXSModel SetEquivlalenceModel SetIrradiationModel Many MLP modification have been made it may not be 100% working for the moment... But the modification should improve the MLP model performance... and it by far... This prevent to recreate a new inputTTree at each call of the MLP model, it will load the reader when the model is loaded, and link it the some class parameter. At each call of the MLP model, it only update the values of the internal parameter (linked to the reader) and launch the TMVA execution... which should be much faster than recreating a new inputTTrre, a new reader and new internal parameter link to it at each call of the MLP model.... git-svn-id: svn+ssh://svn.in2p3.fr/class@797 0e7d625b-0364-4367-a6be-d5be4a48d228 --- .../Model/Equivalence/EQM_FBR_MLP_Keff.cxx | 131 +++++--------- .../Model/Equivalence/EQM_FBR_MLP_Keff.hxx | 15 +- .../Equivalence/EQM_FBR_MLP_Keff_BOUND.cxx | 165 +++++++---------- .../Equivalence/EQM_FBR_MLP_Keff_BOUND.hxx | 23 ++- .../BaM/Model/Equivalence/EQM_MLP_Kinf.cxx | 167 +++++++----------- .../BaM/Model/Equivalence/EQM_MLP_Kinf.hxx | 27 +-- .../BaM/Model/Equivalence/EQM_PWR_MLP_MOX.cxx | 145 ++++++--------- .../BaM/Model/Equivalence/EQM_PWR_MLP_MOX.hxx | 19 +- .../Model/Equivalence/EQM_PWR_MLP_MOX_Am.cxx | 104 ++++------- .../Model/Equivalence/EQM_PWR_MLP_MOX_Am.hxx | 24 ++- source/branches/BaM/include/PhysicsModels.hxx | 4 +- 11 files changed, 348 insertions(+), 476 deletions(-) diff --git a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.cxx b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.cxx index c6998f89e..bce3fb384 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.cxx +++ b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.cxx @@ -12,7 +12,6 @@ #include <map> #include "TSystem.h" -#include "TMVA/Reader.h" #include "TMVA/Tools.h" #include "TMVA/MethodCuts.h" @@ -51,7 +50,9 @@ EQM_FBR_MLP_Keff::EQM_FBR_MLP_Keff(string TMVAWeightPath, double keff_target, st fInformationFile = InformationFile; LoadKeyword(); ReadNFO();//Getting information from fMLPInformationFile - + + InitialiseTMVAReader(); + if(fMaximalContent == 0 ) { ERROR<<"Can't find the k_maxfiscontent keyword in .nfo file\n this is mandatory"<<endl; @@ -97,7 +98,9 @@ EQM_FBR_MLP_Keff::EQM_FBR_MLP_Keff(CLASSLogger* log, string TMVAWeightPath, doub fInformationFile = InformationFile; LoadKeyword(); ReadNFO();//Getting information from fMLPInformationFile - + + InitialiseTMVAReader(); + if(fMaximalContent == 0 ) { ERROR<<"Can't find the k_maxfiscontent keyword in .nfo file\n this is mandatory"<<endl; @@ -124,112 +127,60 @@ EQM_FBR_MLP_Keff::EQM_FBR_MLP_Keff(CLASSLogger* log, string TMVAWeightPath, doub DBGL } -//________________________________________________________________________ -TTree* EQM_FBR_MLP_Keff::CreateTMVAInputTree(IsotopicVector TheFreshfuel, double ThisTime) + +void EQM_FBR_MLP_Keff::InitialiseTMVAReader() { - DBGL - /******Create Input data tree to be interpreted by TMVA::Reader***/ - TTree* InputTree = new TTree("InTMPKef", "InTMPKef"); + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); + reader = new TMVA::Reader( "Silent" ); - float Time = 0; - IsotopicVector IVInputTMVA; - map<ZAI ,string >::iterator it; - int j = 0; + // Create a set of variables and declare them to the reader + // - the variable names MUST corresponds in name and type to those given in the weight file(s) used + vector<float> InputTMVA; + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); + Float_t Time; - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { - InputTree->Branch( ((*it).second).c_str() ,&InputTMVA[j], ((*it).second + "/F").c_str()); - IVInputTMVA+= ((*it).first)*1; - j++; - } + map<ZAI ,string >::iterator it; + int j = 0; + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) + { + reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); + IVInputTMVA += ((*it).first)*1; + j++; + } - if(ThisTime != -1) - InputTree->Branch( "Time" ,&Time ,"Time/F" ); +} - IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); +void EQM_FBR_MLP_Keff::UpdateInputComposition(IsotopicVector TheFreshfuel) +{ - double Ntot = IVAccordingToUserInfoFile.GetSumOfAll(); - IVAccordingToUserInfoFile = IVAccordingToUserInfoFile/Ntot; + IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); - j = 0; - map<ZAI ,string >::iterator it2; - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) - { - InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it2).first ) ; - j++; - } + map<ZAI,string>::iterator it; + int j = 0; - Time = ThisTime; + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) + { + InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it).first ) ; + j++; + } - InputTree->Fill(); +} - DBGL - return InputTree; -} //________________________________________________________________________ -double EQM_FBR_MLP_Keff::ExecuteTMVA(TTree* InputTree, bool IsTimeDependent) +double EQM_FBR_MLP_Keff::ExecuteTMVA(IsotopicVector TheFreshfuel) { DBGL - - // --- Create the Reader object - TMVA::Reader *reader = new TMVA::Reader( "Silent" ); - - // Create a set of variables and declare them to the reader - // - the variable names MUST corresponds in name and type to those given in the weight file(s) used - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); - - Float_t Time = 0; - - - map<ZAI ,string >::iterator it; - int j = 0; - - - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - reader->AddVariable( "Time" ,&Time); - - - // --- Book the MVA methods + Float_t val = (reader->EvaluateRegression( "MLP Method" ))[0]; - // Book method MLP - TString methodName = "MLP method"; - reader->BookMVA( methodName, fTMVAWeightPath ); - - map<ZAI ,string >::iterator it2; - j = 0; - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) - { - InputTree->SetBranchAddress(( (*it2).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - InputTree->SetBranchAddress( "Time" ,&Time ); - - InputTree->GetEntry(0); - - Float_t val = (reader->EvaluateRegression( methodName ))[0]; - - delete reader; - - DBGL return (double)val; //return k_{eff}(t = Time) } //________________________________________________________________________ @@ -312,7 +263,7 @@ double EQM_FBR_MLP_Keff::GetFissileMolarFraction(IsotopicVector Fissile,Isotopic double OldFissileContentPlus = fMaximalContent; double PredictedKeff = 0 ; IsotopicVector FreshFuel = (1-FissileContent)*(Fertile/Fertile.GetSumOfAll()) + FissileContent*(Fissile/Fissile.GetSumOfAll()); - double OldPredictedKeff = GetKeffAtFixedTime(FreshFuel); + double OldPredictedKeff = ExecuteTMVA(FreshFuel); double Precision = fPCMprecision/1e5*fTargetKeff; //pcm to 1 @@ -339,7 +290,7 @@ double EQM_FBR_MLP_Keff::GetFissileMolarFraction(IsotopicVector Fissile,Isotopic IsotopicVector FreshFuel = (1-FissileContent)*(Fertile/Fertile.GetSumOfAll()) + FissileContent*(Fissile/Fissile.GetSumOfAll()); - PredictedKeff = GetKeffAtFixedTime(FreshFuel); + PredictedKeff = ExecuteTMVA(FreshFuel); OldPredictedKeff = PredictedKeff; count ++; diff --git a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.hxx b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.hxx index 9a12a9d59..2da269a84 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.hxx +++ b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff.hxx @@ -4,6 +4,8 @@ #include "EquivalenceModel.hxx" #include "TTree.h" #include "TGraph.h" +#include "TMVA/Reader.h" + #include <string> #include <fstream> #include <iostream> @@ -100,9 +102,11 @@ class EQM_FBR_MLP_Keff : public EquivalenceModel \name TMVA related methods */ //@{ - TTree* CreateTMVAInputTree(IsotopicVector FreshFuel, double ThisTime);//!<Create input tmva tree to be read by ExecuteTMVA + void InitialiseTMVAReader(); + + void UpdateInputComposition(IsotopicVector FreshFuel);//!<Create input tmva tree to be read by ExecuteTMVA - double ExecuteTMVA(TTree* theTree, bool IsTimeDependant);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree + double ExecuteTMVA(IsotopicVector TheFreshfuel);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree //@} @@ -177,14 +181,17 @@ class EQM_FBR_MLP_Keff : public EquivalenceModel double fTargetKeff; //!< Use for Varying Fissile content to reach fTargetKeff at time used in the MLP Training + TMVA::Reader *reader; + vector<float> InputTMVA; + IsotopicVector IVInputTMVA; + float Time; + /*! \name keff prediction methods & keff averaging */ //@{ - double GetKeffAtFixedTime(IsotopicVector FreshFuel){TTree* Input = CreateTMVAInputTree(FreshFuel,-1); double Keff = ExecuteTMVA( Input, false ); delete Input; return Keff;} //!<time independant since the MLP is trained for 1 time - TGraph* BuildKeffGraph(IsotopicVector FreshFuel); TGraph* BuildAverageKeffGraph(TGraph* GRAPH_KEFF); double GetKeffAt(TGraph* GRAPH_KEFF, int Step); diff --git a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.cxx b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.cxx index 47cc75a67..fdc098c95 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.cxx +++ b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.cxx @@ -11,7 +11,6 @@ #include <cassert> #include "TSystem.h" -#include "TMVA/Reader.h" #include "TMVA/Tools.h" #include "TMVA/MethodCuts.h" @@ -52,7 +51,10 @@ EQM_FBR_MLP_Keff_BOUND::EQM_FBR_MLP_Keff_BOUND(string TMVAWeightPath, int NumOf LoadKeyword(); ReadNFO();//Getting information from fInformationFile - + + + InitialiseTMVAReader(); + /* OTHER MODEL PARAMETERS */ @@ -115,7 +117,8 @@ EQM_FBR_MLP_Keff_BOUND::EQM_FBR_MLP_Keff_BOUND(CLASSLogger* log, string TMVAWeig LoadKeyword(); ReadNFO();//Getting information from fInformationFile - + InitialiseTMVAReader(); + /* OTHER MODEL PARAMETERS */ @@ -165,9 +168,7 @@ TGraph* EQM_FBR_MLP_Keff_BOUND::BuildKeffGraph(IsotopicVector FreshFuel) TGraph * keffGraph = new TGraph(); for(int i = 0 ; i < (int) fMLP_Time.size() ; i++) { - TTree *InputTree = CreateTMVAInputTree(FreshFuel,(float) fMLP_Time[i]); - double keff_t = ExecuteTMVA( InputTree, true ); - delete InputTree; + double keff_t = ExecuteTMVA( FreshFuel, (float)fMLP_Time[i] ); keffGraph->SetPoint(i, (double)fMLP_Time[i], keff_t ); } @@ -222,106 +223,72 @@ double EQM_FBR_MLP_Keff_BOUND::GetKeffAt(TGraph* GRAPH_KEFF, int Step) return Keff; } //________________________________________________________________________ -TTree* EQM_FBR_MLP_Keff_BOUND::CreateTMVAInputTree(IsotopicVector TheFreshfuel, double ThisTime) + + +void EQM_FBR_MLP_Keff_BOUND::UpdateInputComposition(IsotopicVector TheFreshfuel, double ThisTime) { - DBGL - /******Create Input data tree to be interpreted by TMVA::Reader***/ - TTree* InputTree = new TTree("InTMPKef", "InTMPKef"); - - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); - - float Time = 0; - - IsotopicVector IVInputTMVA; - map<ZAI ,string >::iterator it; - int j = 0; - - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { - InputTree->Branch( ((*it).second).c_str() ,&InputTMVA[j], ((*it).second + "/F").c_str()); - IVInputTMVA+= ((*it).first)*1; - j++; - } - - if(ThisTime != -1) - InputTree->Branch( "Time" ,&Time ,"Time/F" ); - - IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); - - double Ntot = IVAccordingToUserInfoFile.GetSumOfAll(); - - IVAccordingToUserInfoFile = IVAccordingToUserInfoFile/Ntot; - - j = 0; - map<ZAI ,string >::iterator it2; - - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) - { - InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it2).first ) ; - j++; - } - - Time = ThisTime; - - InputTree->Fill(); - - DBGL - return InputTree; - + + IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); + + + map<ZAI,string>::iterator it; + int j = 0; + + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) + { + InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it).first ) ; + j++; + } + + Time = ThisTime; + +} + + +void EQM_FBR_MLP_Keff_BOUND::InitialiseTMVAReader() +{ + + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); + + reader = new TMVA::Reader( "Silent" ); + + + // Create a set of variables and declare them to the reader + // - the variable names MUST corresponds in name and type to those given in the weight file(s) used + vector<float> InputTMVA; + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); + Float_t Time; + + map<ZAI ,string >::iterator it; + int j = 0; + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) + { + reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); + IVInputTMVA += ((*it).first)*1; + j++; + } + + if(fTMVAWeightPath.size() == 1) + reader->AddVariable( "Time" ,&Time); + + } + //________________________________________________________________________ -double EQM_FBR_MLP_Keff_BOUND::ExecuteTMVA(TTree* InputTree, bool IsTimeDependent) +double EQM_FBR_MLP_Keff_BOUND::ExecuteTMVA(IsotopicVector TheFreshfuel, double ThisTime) { - DBGL + UpdateInputComposition(TheFreshfuel,ThisTime); - // --- Create the Reader object - TMVA::Reader *reader = new TMVA::Reader( "Silent" ); - - // Create a set of variables and declare them to the reader - // - the variable names MUST corresponds in name and type to those given in the weight file(s) used - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); - Float_t Time; - - map<ZAI ,string >::iterator it; - int j = 0; - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - reader->AddVariable( "Time" ,&Time); - - // --- Book the MVA methods - - // Book method MLP - TString methodName = "MLP method"; - reader->BookMVA( methodName, fTMVAWeightPath ); - - map<ZAI ,string >::iterator it2; - j = 0; - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) - { - InputTree->SetBranchAddress(( (*it2).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - InputTree->SetBranchAddress( "Time" ,&Time ); - - InputTree->GetEntry(0); - Float_t val = (reader->EvaluateRegression( methodName ))[0]; - - delete reader; - - DBGL - return (double)val; //return k_{eff}(t = Time) + reader->BookMVA( "MLP Method", fTMVAWeightPath ); + + Float_t val = (reader->EvaluateRegression( "MLP Method" ))[0]; + + return (double)val;//retourn k_{inf}(t = Time) } + //________________________________________________________________________ void EQM_FBR_MLP_Keff_BOUND::LoadKeyword() { diff --git a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.hxx b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.hxx index e9984b5b4..df0219738 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.hxx +++ b/source/branches/BaM/Model/Equivalence/EQM_FBR_MLP_Keff_BOUND.hxx @@ -2,6 +2,8 @@ #define _EQM_FBR_MLP_Keff_BOUND_HXX_ #include "EquivalenceModel.hxx" + +#include "TMVA/Reader.h" #include "TTree.h" #include "TGraph.h" @@ -106,9 +108,12 @@ class EQM_FBR_MLP_Keff_BOUND : public EquivalenceModel \name TMVA related methods */ //@{ - TTree* CreateTMVAInputTree(IsotopicVector FreshFuel, double ThisTime);//!<Create input tmva tree to be read by ExecuteTMVA - - double ExecuteTMVA(TTree* theTree, bool IsTimeDependant);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree + + void InitialiseTMVAReader(); + + void UpdateInputComposition(IsotopicVector TheFreshfuel, double ThisTime); + + double ExecuteTMVA(IsotopicVector TheFreshfuel, double ThisTime);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree //@} @@ -179,7 +184,11 @@ class EQM_FBR_MLP_Keff_BOUND : public EquivalenceModel double fTargetKeff; //!< Use for Varying Fissile content to reach fTargetKeff at time used in the MLP Training - + TMVA::Reader *reader; + vector<float> InputTMVA; + IsotopicVector IVInputTMVA; + float Time; + /*! @@ -187,8 +196,10 @@ class EQM_FBR_MLP_Keff_BOUND : public EquivalenceModel */ //@{ - double GetKeffAtFixedTime(IsotopicVector FreshFuel){TTree* Input = CreateTMVAInputTree(FreshFuel,-1); double Keff = ExecuteTMVA( Input, false ); delete Input; return Keff;} //!<time independant since the MLP is trained for 1 time - +/* double GetKeffAtFixedTime(IsotopicVector FreshFuel){ + TTree* Input = CreateTMVAInputTree(FreshFuel,-1); + double Keff = ExecuteTMVA( Input, false ); delete Input; return Keff;} //!<time independant since the MLP is trained for 1 time +*/ TGraph* BuildKeffGraph(IsotopicVector FreshFuel); TGraph* BuildAverageKeffGraph(TGraph* GRAPH_KEFF); diff --git a/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.cxx b/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.cxx index 24a8eb53f..871f5efa4 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.cxx +++ b/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.cxx @@ -11,7 +11,6 @@ #include <cassert> #include "TSystem.h" -#include "TMVA/Reader.h" #include "TMVA/Tools.h" #include "TMVA/MethodCuts.h" @@ -75,7 +74,9 @@ EQM_MLP_Kinf::EQM_MLP_Kinf(CLASSLogger* log, string WeightPathAlpha0, string Wei LoadKeyword(); ReadNFO();//Getting information from fInformationFile - fNumberOfBatch = NumOfBatch; + InitialiseTMVAReader(); + + fNumberOfBatch = NumOfBatch; fKThreshold = CriticalityThreshold ; SetBurnUpPrecision(0.005);//1 % of the targeted burnup SetBuildFuelFirstGuess(0.04);//First fissile content guess for the EquivalenceModel::BuildFuel algorithm @@ -115,7 +116,9 @@ EQM_MLP_Kinf::EQM_MLP_Kinf(string TMVAWeightPath, int NumOfBatch, string Inform fInformationFile = InformationFile; LoadKeyword(); ReadNFO();//Getting information from fInformationFile - + + InitialiseTMVAReader(); + fNumberOfBatch = NumOfBatch; fKThreshold = CriticalityThreshold ; SetBurnUpPrecision(0.005);//1 % of the targeted burnup @@ -152,7 +155,9 @@ EQM_MLP_Kinf::EQM_MLP_Kinf(CLASSLogger* log, string TMVAWeightPath, int NumOfBa fInformationFile = InformationFile; LoadKeyword(); ReadNFO();//Getting information from fMLPInformationFile - + + InitialiseTMVAReader(); + fNumberOfBatch = NumOfBatch; fKThreshold = CriticalityThreshold ; SetBurnUpPrecision(0.005);//1 % of the targeted burnup @@ -257,100 +262,66 @@ void EQM_MLP_Kinf::ReadLine(string line) DBGL } -//________________________________________________________________________ -TTree* EQM_MLP_Kinf::CreateTMVAInputTree(IsotopicVector TheFreshfuel, double ThisTime) + +void EQM_MLP_Kinf::InitialiseTMVAReader() { - /******Create Input data tree to be interpreted by TMVA::Reader***/ - TTree* InputTree = new TTree("InTMPKinf", "InTMPKinf"); - - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); - - float Time = 0; - - IsotopicVector IVInputTMVA; - map<ZAI ,string >::iterator it; - int j = 0; - - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { - InputTree->Branch( ((*it).second).c_str() ,&InputTMVA[j], ((*it).second + "/F").c_str()); - IVInputTMVA+= ((*it).first)*1; - j++; - } - - if(ThisTime != -1) - InputTree->Branch( "Time" ,&Time ,"Time/F" ); - - IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); - - double Ntot = IVAccordingToUserInfoFile.GetSumOfAll(); - - IVAccordingToUserInfoFile = IVAccordingToUserInfoFile/Ntot; - - j = 0; - map<ZAI ,string >::iterator it2; - - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) + + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); + + reader = new TMVA::Reader( "Silent" ); + + + // Create a set of variables and declare them to the reader + // - the variable names MUST corresponds in name and type to those given in the weight file(s) used + vector<float> InputTMVA; + for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) + InputTMVA.push_back(0); + Float_t Time; + + map<ZAI ,string >::iterator it; + int j = 0; + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) + { + reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); + IVInputTMVA += ((*it).first)*1; + j++; + } + + if(fTMVAWeightPath.size() == 1) + reader->AddVariable( "Time" ,&Time); + +} + + +void EQM_MLP_Kinf::UpdateInputComposition(IsotopicVector TheFreshfuel, double ThisTime) +{ + + + IsotopicVector IVAccordingToUserInfoFile = TheFreshfuel.GetThisComposition(IVInputTMVA); + + + map<ZAI,string>::iterator it; + int j = 0; + + for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) { - InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it2).first ) ; + InputTMVA[j] = IVAccordingToUserInfoFile.GetZAIIsotopicQuantity( (*it).first ) ; j++; } Time = ThisTime; - - InputTree->Fill(); - - return InputTree; - + } //________________________________________________________________________ -double EQM_MLP_Kinf::ExecuteTMVA(TTree* InputTree,string WeightPath, bool IsTimeDependent) +double EQM_MLP_Kinf::ExecuteTMVA(IsotopicVector TheFreshfuel, double ThisTime, string TMVAWeightPath) { - - // --- Create the Reader object - TMVA::Reader *reader = new TMVA::Reader( "Silent" ); - - // Create a set of variables and declare them to the reader - // - the variable names MUST corresponds in name and type to those given in the weight file(s) used - vector<float> InputTMVA; - for(int i = 0 ; i< (int)fMapOfTMVAVariableNames.size() ; i++) - InputTMVA.push_back(0); - Float_t Time; - - map<ZAI ,string >::iterator it; - int j = 0; - for( it = fMapOfTMVAVariableNames.begin() ; it != fMapOfTMVAVariableNames.end() ; it++) - { reader->AddVariable( ( (*it).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - reader->AddVariable( "Time" ,&Time); - - // --- Book the MVA methods - - // Book method MLP - TString methodName = "MLP method"; - reader->BookMVA( methodName, WeightPath ); - - map<ZAI ,string >::iterator it2; - j = 0; - for( it2 = fMapOfTMVAVariableNames.begin() ; it2 != fMapOfTMVAVariableNames.end() ; it2++) - { - InputTree->SetBranchAddress(( (*it2).second ).c_str(),&InputTMVA[j]); - j++; - } - - if(IsTimeDependent) - InputTree->SetBranchAddress( "Time" ,&Time ); - - InputTree->GetEntry(0); - Float_t val = (reader->EvaluateRegression( methodName ))[0]; - - delete reader; - + UpdateInputComposition(TheFreshfuel,ThisTime); + + reader->BookMVA( "MLP Method", TMVAWeightPath ); + + Float_t val = (reader->EvaluateRegression( "MLP Method" ))[0]; + return (double)val;//retourn k_{inf}(t = Time) } //________________________________________________________________________ @@ -371,9 +342,7 @@ double EQM_MLP_Kinf::GetMaximumBurnUp_MLP(IsotopicVector TheFuel, double TargetB for(int b = 0;b<fNumberOfBatch;b++) { float TheTime = (b+1)*TheFinalTime/fNumberOfBatch; - TTree* InputTree = CreateTMVAInputTree(TheFuel,TheTime); - OldPredictedk_av += ExecuteTMVA(InputTree,fTMVAWeightPath[0],true); - delete InputTree; + OldPredictedk_av += ExecuteTMVA(TheFuel,TheTime, fTMVAWeightPath[0]); } OldPredictedk_av/= fNumberOfBatch; @@ -409,9 +378,7 @@ double EQM_MLP_Kinf::GetMaximumBurnUp_MLP(IsotopicVector TheFuel, double TargetB for(int b = 0;b<fNumberOfBatch;b++) { float TheTime = (b+1)*TheFinalTime/fNumberOfBatch; - TTree* InputTree = CreateTMVAInputTree(TheFuel,TheTime); - k_av += ExecuteTMVA(InputTree,fTMVAWeightPath[0],true); - delete InputTree; + k_av += ExecuteTMVA(TheFuel,TheTime, fTMVAWeightPath[0]); } k_av/= fNumberOfBatch; @@ -426,12 +393,10 @@ double EQM_MLP_Kinf::GetMaximumBurnUp_MLP(IsotopicVector TheFuel, double TargetB double EQM_MLP_Kinf::GetMaximumBurnUp_Pol2(IsotopicVector TheFuel,double TargetBU) { - TTree* InputTree = CreateTMVAInputTree(TheFuel,-1); - double Alpha_0 = ExecuteTMVA(InputTree,fTMVAWeightPath[0],false); - double Alpha_1 = ExecuteTMVA(InputTree,fTMVAWeightPath[1],false); - double Alpha_2 = ExecuteTMVA(InputTree,fTMVAWeightPath[2],false); - delete InputTree; - + double Alpha_0 = ExecuteTMVA(TheFuel, -1, fTMVAWeightPath[0]); + double Alpha_1 = ExecuteTMVA(TheFuel, -1, fTMVAWeightPath[1]); + double Alpha_2 = ExecuteTMVA(TheFuel, -1, fTMVAWeightPath[2]); + if(Alpha_0 < fKThreshold) //not enought fissile for sure !! return 0; diff --git a/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.hxx b/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.hxx index 48e0296bb..43f9e384b 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.hxx +++ b/source/branches/BaM/Model/Equivalence/EQM_MLP_Kinf.hxx @@ -3,6 +3,8 @@ #include "EquivalenceModel.hxx" #include "TTree.h" +#include "TMVA/Reader.h" + #include <map> using namespace std; @@ -48,9 +50,9 @@ class EQM_MLP_Kinf : public EquivalenceModel /// @f$\alpha_{0}@f$, @f$\alpha_{1}@f$, @f$\alpha_{2}@f$ are predict by 3 MLP (one for each) /*! Create a EQM_MLP_Kinf - \param TMVAWeightPath0 : PAth to the .xml file containing neural network informations for @f$\alpha_{0}@f$ prediction : PATH/TMVAWeight.xml (total path to tmva weight) - \param TMVAWeightPath1 : PAth to the .xml file containing neural network informations for @f$\alpha_{1}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) - \param TMVAWeightPath2 : PAth to the .xml file containing neural network informations for @f$\alpha_{2}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath0 : Path to the .xml file containing neural network informations for @f$\alpha_{0}@f$ prediction : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath1 : Path to the .xml file containing neural network informations for @f$\alpha_{1}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath2 : Path to the .xml file containing neural network informations for @f$\alpha_{2}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) \param InformationFile : Total path to the file containing time steps, fissile and ferile list (ante and post fabrication time cooling). Default is the same total path as TMVAWeightPath but extension is replaced by .nfo \param NumOfBatch : Number of batch for the loading plan (often 3 or 4 for PWR) \param CriticalityThreshold : Threshold for the @f$k_{\infty}@f$ (see detailed description) @@ -63,9 +65,9 @@ class EQM_MLP_Kinf : public EquivalenceModel /*! Create a EQM_MLP_Kinf \param log : use for log - \param TMVAWeightPath0 : PAth to the .xml file containing neural network informations for @f$\alpha_{0}@f$ prediction : PATH/TMVAWeight.xml (total path to tmva weight) - \param TMVAWeightPath1 : PAth to the .xml file containing neural network informations for @f$\alpha_{1}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) - \param TMVAWeightPath2 : PAth to the .xml file containing neural network informations for @f$\alpha_{2}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath0 : Path to the .xml file containing neural network informations for @f$\alpha_{0}@f$ prediction : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath1 : Path to the .xml file containing neural network informations for @f$\alpha_{1}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath2 : Path to the .xml file containing neural network informations for @f$\alpha_{2}@f$ prediction: PATH/TMVAWeight.xml (total path to tmva weight) \param InformationFile : Total path to the file containing time steps, fissile and ferile list (ante and post fabrication time cooling). Default is the same total path as TMVAWeightPath but extension is replaced by .nfo \param NumOfBatch : Number of batch for the loading plan (often 3 or 4 for PWR) \param CriticalityThreshold : Threshold for the @f$k_{\infty}@f$ (see detailed description) @@ -76,7 +78,7 @@ class EQM_MLP_Kinf : public EquivalenceModel /// Neural network predictor. The kinf(t) is predicted with a MLP /*! Create a EQM_MLP_Kinf - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) \param NumOfBatch : Number of batch for the loading plan (often 3 or 4 for PWR) \param InformationFile : Total path to the file containing time steps, fissile and ferile list (ante and post fabrication time cooling). Default is the same total path as TMVAWeightPath but extension is replaced by .nfo \param CriticalityThreshold : Threshold for the @f$k_{\infty}@f$ (see detailed description) @@ -89,7 +91,7 @@ class EQM_MLP_Kinf : public EquivalenceModel /*! Create a EQM_MLP_Kinf \param log : use for log - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) \param NumOfBatch : Number of batch for the loading plan (often 3 or 4 for PWR) \param InformationFile : Total path to the file containing time steps, fissile and ferile list (ante and post fabrication time cooling). Default is the same total path as TMVAWeightPath but extension is replaced by .nfo \param CriticalityThreshold : Threshold for the @f$k_{\infty}@f$ (see detailed description) @@ -137,9 +139,10 @@ class EQM_MLP_Kinf : public EquivalenceModel \name TMVA related methods */ //@{ + void InitialiseTMVAReader(); - TTree* CreateTMVAInputTree(IsotopicVector FreshFuel, double ThisTime);//!<Create input tmva tree to be read by ExecuteTMVA - double ExecuteTMVA(TTree* theTree, string WeightPath, bool IsTimeDependant);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree + void UpdateInputComposition(IsotopicVector TheFreshfuel, double ThisTime ); + double ExecuteTMVA(IsotopicVector TheFreshfuel, double ThisTime, string TMVAWeightPath);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree //@} @@ -213,6 +216,10 @@ class EQM_MLP_Kinf : public EquivalenceModel double fBurnUpPrecision; //!< precision on Burnup double fPCMprecision; //!< precision on @f$\langle k \rangle@f$ prediction [pcm] + TMVA::Reader *reader; + vector<float> InputTMVA; + IsotopicVector IVInputTMVA; + float Time; }; diff --git a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.cxx b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.cxx index af3b7c820..82c64e0fc 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.cxx +++ b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.cxx @@ -11,7 +11,6 @@ #include <cassert> #include "TSystem.h" -#include "TMVA/Reader.h" #include "TMVA/Tools.h" #include "TMVA/MethodCuts.h" @@ -29,6 +28,18 @@ EQM_PWR_MLP_MOX::EQM_PWR_MLP_MOX(string TMVAWeightPath):EquivalenceModel(new CLA { fTMVAWeightPath = TMVAWeightPath; + reader = new TMVA::Reader( "Silent" ); + reader->BookMVA( "MLP Method", fTMVAWeightPath ); + reader->AddVariable( "BU" ,&BU ); + reader->AddVariable( "U5_enrichment",&U5_enrichment ); + reader->AddVariable( "Pu8" ,&Pu8 ); + reader->AddVariable( "Pu9" ,&Pu9 ); + reader->AddVariable( "Pu10" ,&Pu10); + reader->AddVariable( "Pu11" ,&Pu11); + reader->AddVariable( "Pu12" ,&Pu12); + reader->AddVariable( "Am1" ,&Am1 ); + + ZAI U8(92,238,0); ZAI U5(92,235,0); double U5_enrich = 0.0025; @@ -57,6 +68,19 @@ EQM_PWR_MLP_MOX::EQM_PWR_MLP_MOX(CLASSLogger* log, string TMVAWeightPath):Equiva { fTMVAWeightPath = TMVAWeightPath; + reader = new TMVA::Reader( "Silent" ); + reader->BookMVA( "MLP Method", fTMVAWeightPath ); + reader->AddVariable( "BU" ,&BU ); + reader->AddVariable( "U5_enrichment",&U5_enrichment ); + reader->AddVariable( "Pu8" ,&Pu8 ); + reader->AddVariable( "Pu9" ,&Pu9 ); + reader->AddVariable( "Pu10" ,&Pu10); + reader->AddVariable( "Pu11" ,&Pu11); + reader->AddVariable( "Pu12" ,&Pu12); + reader->AddVariable( "Am1" ,&Am1 ); + + + ZAI U8(92,238,0); ZAI U5(92,235,0); double U5_enrich = 0.0025; @@ -81,51 +105,33 @@ EQM_PWR_MLP_MOX::EQM_PWR_MLP_MOX(CLASSLogger* log, string TMVAWeightPath):Equiva } //________________________________________________________________________ -TTree* EQM_PWR_MLP_MOX::CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) +void EQM_PWR_MLP_MOX::UpdateInputComposition(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) { - TTree* InputTree = new TTree("EQTMP", "EQTMP"); - float Pu8 = 0; - float Pu9 = 0; - float Pu10 = 0; - float Pu11 = 0; - float Pu12 = 0; - float Am1 = 0; - float U5_enrichment = 0; - float BU = 0; - - InputTree->Branch( "Pu8" ,&Pu8 ,"Pu8/F" ); - InputTree->Branch( "Pu9" ,&Pu9 ,"Pu9/F" ); - InputTree->Branch( "Pu10" ,&Pu10 ,"Pu10/F" ); - InputTree->Branch( "Pu11" ,&Pu11 ,"Pu11/F" ); - InputTree->Branch( "Pu12" ,&Pu12 ,"Pu12/F" ); - InputTree->Branch( "Am1" ,&Am1 ,"Am1/F" ); - InputTree->Branch( "U5_enrichment" ,&U5_enrichment ,"U5_enrichment/F" ); - InputTree->Branch( "BU" ,&BU ,"BU/F" ); - - - float U8 = Fertil.GetZAIIsotopicQuantity(92,238,0); - float U5 = Fertil.GetZAIIsotopicQuantity(92,235,0); - float U4 = Fertil.GetZAIIsotopicQuantity(92,234,0); - - float UTOT = U8 + U5 + U4; - - Pu8 = Fissil.GetZAIIsotopicQuantity(94,238,0); - Pu9 = Fissil.GetZAIIsotopicQuantity(94,239,0); - Pu10 = Fissil.GetZAIIsotopicQuantity(94,240,0); - Pu11 = Fissil.GetZAIIsotopicQuantity(94,241,0); - Pu12 = Fissil.GetZAIIsotopicQuantity(94,242,0); - Am1 = Fissil.GetZAIIsotopicQuantity(95,241,0); - - double TOTPU = (Pu8+Pu9+Pu10+Pu11+Pu12+Am1); - - Pu8 = Pu8 / TOTPU; - Pu9 = Pu9 / TOTPU; - Pu10 = Pu10 / TOTPU; - Pu11 = Pu11 / TOTPU; - Pu12 = Pu12 / TOTPU; - Am1 = Am1 / TOTPU; - - U5_enrichment = U5 / UTOT; + + + float U8 = Fertil.GetZAIIsotopicQuantity(92,238,0); + float U5 = Fertil.GetZAIIsotopicQuantity(92,235,0); + float U4 = Fertil.GetZAIIsotopicQuantity(92,234,0); + + float UTOT = U8 + U5 + U4; + + Pu8 = Fissil.GetZAIIsotopicQuantity(94,238,0); + Pu9 = Fissil.GetZAIIsotopicQuantity(94,239,0); + Pu10 = Fissil.GetZAIIsotopicQuantity(94,240,0); + Pu11 = Fissil.GetZAIIsotopicQuantity(94,241,0); + Pu12 = Fissil.GetZAIIsotopicQuantity(94,242,0); + Am1 = Fissil.GetZAIIsotopicQuantity(95,241,0); + + double TOTPU = (Pu8+Pu9+Pu10+Pu11+Pu12+Am1); + + Pu8 = Pu8 / TOTPU; + Pu9 = Pu9 / TOTPU; + Pu10 = Pu10 / TOTPU; + Pu11 = Pu11 / TOTPU; + Pu12 = Pu12 / TOTPU; + Am1 = Am1 / TOTPU; + + U5_enrichment = U5 / UTOT; BU = BurnUp; if(Pu8 + Pu9 + Pu10 + Pu11 + Pu12 + Am1 > 1.00001 )//?????1.00001??? I don't know it! goes in condition if = 1 !! may be float/double issue ... @@ -133,53 +139,18 @@ TTree* EQM_PWR_MLP_MOX::CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector ERROR << Pu8 << " " << Pu9 << " " << Pu10 << " " << Pu11 << " " << Pu12 << " " << Am1 << endl; exit(0); } - // All value are molar (!weight) - - InputTree->Fill(); - return InputTree; } //________________________________________________________________________ -double EQM_PWR_MLP_MOX::ExecuteTMVA(TTree* theTree) +double EQM_PWR_MLP_MOX::ExecuteTMVA(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) { - // --- Create the Reader object - TMVA::Reader *reader = new TMVA::Reader( "Silent" ); - // Create a set of variables and declare them to the reader - // - the variable names MUST corresponds in name and type to those given in the weight file(s) used - Float_t Pu8,Pu9,Pu10,Pu11,Pu12,Am1,BU,U5_enrichment; - - reader->AddVariable( "BU" ,&BU ); - reader->AddVariable( "U5_enrichment",&U5_enrichment ); - reader->AddVariable( "Pu8" ,&Pu8 ); - reader->AddVariable( "Pu9" ,&Pu9 ); - reader->AddVariable( "Pu10" ,&Pu10); - reader->AddVariable( "Pu11" ,&Pu11); - reader->AddVariable( "Pu12" ,&Pu12); - reader->AddVariable( "Am1" ,&Am1 ); - - // --- Book the MVA methods - - // Book method MLP - TString methodName = "MLP method"; - reader->BookMVA( methodName, fTMVAWeightPath ); - theTree->SetBranchAddress( "BU" ,&BU ); - theTree->SetBranchAddress( "U5_enrichment" ,&U5_enrichment ) ; - theTree->SetBranchAddress( "Pu8" ,&Pu8 ); - theTree->SetBranchAddress( "Pu9" ,&Pu9 ); - theTree->SetBranchAddress( "Pu10" ,&Pu10 ); - theTree->SetBranchAddress( "Pu11" ,&Pu11 ); - theTree->SetBranchAddress( "Pu12" ,&Pu12 ); - theTree->SetBranchAddress( "Am1" ,&Am1 ); - theTree->GetEntry(0); - - Float_t val = (reader->EvaluateRegression( methodName ))[0]; - - delete reader; - delete theTree; - - return (double)val; //retourne teneur + UpdateInputComposition(Fissil, Fertil, BurnUp); + Float_t val = (reader->EvaluateRegression( "MLP method" ))[0]; + + return (double)val; //retourne teneur + } //________________________________________________________________________ double EQM_PWR_MLP_MOX::GetFissileMolarFraction(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) {DBGL - return ExecuteTMVA(CreateTMVAInputTree(Fissil,Fertil,BurnUp)); + return ExecuteTMVA( Fissil, Fertil, BurnUp); } diff --git a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.hxx b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.hxx index f0a9bae11..c59b624f9 100644 --- a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.hxx +++ b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX.hxx @@ -2,6 +2,7 @@ #define _EQM_PWR_MLP_MOX_HXX #include "EquivalenceModel.hxx" +#include "TMVA/Reader.h" #include "TTree.h" using namespace std; @@ -30,7 +31,7 @@ class EQM_PWR_MLP_MOX : public EquivalenceModel /// normal constructor /*! Create a EQM_PWR_MLP_MOX - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) */ EQM_PWR_MLP_MOX(string TMVAWeightPath); //} @@ -40,7 +41,7 @@ class EQM_PWR_MLP_MOX : public EquivalenceModel /*! Create a EQM_PWR_MLP_MOX \param log : use for log - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) */ EQM_PWR_MLP_MOX(CLASSLogger* log, string TMVAWeightPath); //} @@ -61,14 +62,24 @@ class EQM_PWR_MLP_MOX : public EquivalenceModel */ //@{ - TTree* CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp);//!<Create input tmva tree to be read by ExecuteTMVA - double ExecuteTMVA(TTree* theTree);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree + void UpdateInputComposition(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp); + double ExecuteTMVA(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree //@} private : + float Pu8; + float Pu9; + float Pu10; + float Pu11; + float Pu12; + float Am1; + float BU; + float U5_enrichment; + + TMVA::Reader *reader; string fTMVAWeightPath;;//!<The weight needed by TMVA to construct and execute the multilayer perceptron }; diff --git a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.cxx b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.cxx index d6e914c4a..eadf4a635 100755 --- a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.cxx +++ b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.cxx @@ -11,7 +11,6 @@ #include <cassert> #include "TSystem.h" -#include "TMVA/Reader.h" #include "TMVA/Tools.h" #include "TMVA/MethodCuts.h" @@ -29,6 +28,20 @@ EQM_PWR_MLP_MOX_AM::EQM_PWR_MLP_MOX_AM(string TMVAWeightPath):EquivalenceModel(n { fTMVAWeightPath = TMVAWeightPath; + reader = new TMVA::Reader( "Silent" ); + reader->BookMVA( "MLP Method", fTMVAWeightPath ); + reader->AddVariable( "Pu8" ,&Pu8 ); + reader->AddVariable( "Pu9" ,&Pu9 ); + reader->AddVariable( "Pu10" ,&Pu10); + reader->AddVariable( "Pu11" ,&Pu11); + reader->AddVariable( "Pu12" ,&Pu12); + reader->AddVariable( "Am1" ,&Am1 ); + reader->AddVariable( "Am2" ,&Am2 ); + reader->AddVariable( "Am3" ,&Am3 ); + reader->AddVariable( "BU" ,&BU ); + reader->AddVariable( "U5_enrichment",&U5_enrichment ); + + ZAI U8(92,238,0); ZAI U5(92,235,0); double U5_enrich = 0.0025; @@ -60,6 +73,19 @@ EQM_PWR_MLP_MOX_AM::EQM_PWR_MLP_MOX_AM(CLASSLogger* log, string TMVAWeightPath): { fTMVAWeightPath = TMVAWeightPath; + reader = new TMVA::Reader( "Silent" ); + reader->BookMVA( "MLP Method", fTMVAWeightPath ); + reader->AddVariable( "Pu8" ,&Pu8 ); + reader->AddVariable( "Pu9" ,&Pu9 ); + reader->AddVariable( "Pu10" ,&Pu10); + reader->AddVariable( "Pu11" ,&Pu11); + reader->AddVariable( "Pu12" ,&Pu12); + reader->AddVariable( "Am1" ,&Am1 ); + reader->AddVariable( "Am2" ,&Am2 ); + reader->AddVariable( "Am3" ,&Am3 ); + reader->AddVariable( "BU" ,&BU ); + reader->AddVariable( "U5_enrichment",&U5_enrichment ); + ZAI U8(92,238,0); ZAI U5(92,235,0); double U5_enrich = 0.0025; @@ -87,31 +113,8 @@ EQM_PWR_MLP_MOX_AM::EQM_PWR_MLP_MOX_AM(CLASSLogger* log, string TMVAWeightPath): } //________________________________________________________________________ -TTree* EQM_PWR_MLP_MOX_AM::CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) +void EQM_PWR_MLP_MOX_AM::UpdateInputComposition(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) { - TTree* InputTree = new TTree("EQTMP", "EQTMP"); - float Pu8 = 0; - float Pu9 = 0; - float Pu10 = 0; - float Pu11 = 0; - float Pu12 = 0; - float Am1 = 0; - float Am2 = 0; - float Am3 = 0; - float U5_enrichment = 0; - float BU = 0; - - InputTree->Branch( "Pu8" ,&Pu8 ,"Pu8/F" ); - InputTree->Branch( "Pu9" ,&Pu9 ,"Pu9/F" ); - InputTree->Branch( "Pu10" ,&Pu10 ,"Pu10/F" ); - InputTree->Branch( "Pu11" ,&Pu11 ,"Pu11/F" ); - InputTree->Branch( "Pu12" ,&Pu12 ,"Pu12/F" ); - InputTree->Branch( "Am1" ,&Am1 ,"Am1/F" ); - InputTree->Branch( "Am2" ,&Am2 ,"Am2/F" ); - InputTree->Branch( "Am3" ,&Am3 ,"Am3/F" ); - InputTree->Branch( "U5_enrichment" ,&U5_enrichment ,"U5_enrichment/F" ); - InputTree->Branch( "BU" ,&BU ,"BU/F" ); - float U8 = Fertil.GetZAIIsotopicQuantity(92,238,0); float U5 = Fertil.GetZAIIsotopicQuantity(92,235,0); @@ -149,55 +152,18 @@ TTree* EQM_PWR_MLP_MOX_AM::CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVec } // All value are molar (!weight) - InputTree->Fill(); - return InputTree; } //________________________________________________________________________ -double EQM_PWR_MLP_MOX_AM::ExecuteTMVA(TTree* theTree) +double EQM_PWR_MLP_MOX_AM::ExecuteTMVA(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) { - // --- Create the Reader object - TMVA::Reader *reader = new TMVA::Reader( "Silent" ); - // Create a set of variables and declare them to the reader - // - the variable names MUST corresponds in name and type to those given in the weight file(s) used - Float_t Pu8,Pu9,Pu10,Pu11,Pu12,Am1, Am2,Am3,BU,U5_enrichment; - - reader->AddVariable( "BU" ,&BU ); - reader->AddVariable( "U5_enrichment",&U5_enrichment ); - reader->AddVariable( "Pu8" ,&Pu8 ); - reader->AddVariable( "Pu9" ,&Pu9 ); - reader->AddVariable( "Pu10" ,&Pu10); - reader->AddVariable( "Pu11" ,&Pu11); - reader->AddVariable( "Pu12" ,&Pu12); - reader->AddVariable( "Am1" ,&Am1 ); - reader->AddVariable( "Am2" ,&Am2 ); - reader->AddVariable( "Am3" ,&Am3 ); - - // --- Book the MVA methods - - // Book method MLP - TString methodName = "MLP method"; - reader->BookMVA( methodName, fTMVAWeightPath ); - theTree->SetBranchAddress( "BU" ,&BU ); - theTree->SetBranchAddress( "U5_enrichment" ,&U5_enrichment ) ; - theTree->SetBranchAddress( "Pu8" ,&Pu8 ); - theTree->SetBranchAddress( "Pu9" ,&Pu9 ); - theTree->SetBranchAddress( "Pu10" ,&Pu10 ); - theTree->SetBranchAddress( "Pu11" ,&Pu11 ); - theTree->SetBranchAddress( "Pu12" ,&Pu12 ); - theTree->SetBranchAddress( "Am1" ,&Am1 ); - theTree->SetBranchAddress( "Am2" ,&Am2 ); - theTree->SetBranchAddress( "Am3" ,&Am3 ); - theTree->GetEntry(0); - - Float_t val = (reader->EvaluateRegression( methodName ))[0]; - - delete reader; - delete theTree; - - return (double)val; //retourne teneur + + UpdateInputComposition(Fissil, Fertil, BurnUp); + Float_t val = (reader->EvaluateRegression( "MLP method" ))[0]; + + return (double)val; //retourne teneur } //________________________________________________________________________ double EQM_PWR_MLP_MOX_AM::GetFissileMolarFraction(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp) {DBGL - return ExecuteTMVA(CreateTMVAInputTree(Fissil,Fertil,BurnUp)); + return ExecuteTMVA( Fissil, Fertil, BurnUp); } diff --git a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.hxx b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.hxx index f742c9220..d919a3e98 100755 --- a/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.hxx +++ b/source/branches/BaM/Model/Equivalence/EQM_PWR_MLP_MOX_Am.hxx @@ -2,6 +2,8 @@ #define _EQM_PWR_MLP_MOX_AM_HXX #include "EquivalenceModel.hxx" +#include "TMVA/Reader.h" + #include "TTree.h" using namespace std; @@ -30,7 +32,7 @@ class EQM_PWR_MLP_MOX_AM : public EquivalenceModel /// normal constructor /*! Create a EQM_PWR_MLP_MOX_AM - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) */ EQM_PWR_MLP_MOX_AM(string TMVAWeightPath); //} @@ -40,7 +42,7 @@ class EQM_PWR_MLP_MOX_AM : public EquivalenceModel /*! Create a EQM_PWR_MLP_MOX_AM \param log : use for log - \param TMVAWeightPath : PAth to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) + \param TMVAWeightPath : Path to the .xml file containing neural network informations : PATH/TMVAWeight.xml (total path to tmva weight) */ EQM_PWR_MLP_MOX_AM(CLASSLogger* log, string TMVAWeightPath); //} @@ -61,14 +63,26 @@ class EQM_PWR_MLP_MOX_AM : public EquivalenceModel */ //@{ - TTree* CreateTMVAInputTree(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp);//!<Create input tmva tree to be read by ExecuteTMVA - double ExecuteTMVA(TTree* theTree);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree + void UpdateInputComposition(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp);//!<Create input tmva tree to be read by ExecuteTMVA + double ExecuteTMVA(IsotopicVector Fissil,IsotopicVector Fertil,double BurnUp);//!<Execute the MLP according to the input tree created by CreateTMVAInputTree //@} private : - + float Pu8; + float Pu9; + float Pu10; + float Pu11; + float Pu12; + float Am1; + float Am2; + float Am3; + + float BU; + float U5_enrichment; + + TMVA::Reader *reader; string fTMVAWeightPath;;//!<The weight needed by TMVA to construct and execute the multilayer perceptron }; diff --git a/source/branches/BaM/include/PhysicsModels.hxx b/source/branches/BaM/include/PhysicsModels.hxx index 43bfb8201..a41d015ad 100644 --- a/source/branches/BaM/include/PhysicsModels.hxx +++ b/source/branches/BaM/include/PhysicsModels.hxx @@ -102,7 +102,9 @@ class PhysicsModels : public CLASSObject PhysicsModels* GetPhysicsModels() {return this;}//!< return the PhysicsModels - + void SetXSModel(XSModel* myXSModel) { fXSModel = myXSModel;} + void SetEquivlalenceModel(EquivalenceModel* myEqModel) { fEquivalenceModel = myEqModel;} + void SetIrradiationModel(IrradiationModel* myIRModel) { fIrradiationModel = myIRModel;} -- GitLab