AliRoot Core  ee782a0 (ee782a0)
AliNDFunctionInterface Namespace Reference

Interface to Ndimension functional representations (THn and TMVA) More...

Functions

template<typename T >
vector< T > add_to_vector (vector< T > &z, T v)
 generic variadic function - to get it from boost in the future More...
 
template<typename T , typename... Args>
vector< T > add_to_vector (vector< T > &z, T v, Args...args)
 
template<typename T , typename... Args>
vector< T > make_vector (T v, Args...args)
 Variadic function to create an vector (boost implementation ) More...
 
Double_t GetInterpolationLinear (THn *his, Double_t *xyz, Int_t verbose)
 Linear interpolation of the bin content. More...
 
Double_t GetDeltaInterpolationLinear (THn *his, Double_t *xyz, Int_t dIndex, Int_t verbose)
 Linear interpolation of the numerical derivative dV/dx (V(i+1)-V(i-1))/(2(delta) More...
 
Double_t GetInterpolationLinear (Int_t index, Double_t *xyz, Int_t verbose)
 
Double_t GetDeltaInterpolationLinear (Int_t index, Double_t *xyz, Int_t dIndex, Int_t verbose)
 
Double_t GetInterpolationLinear (const char *name, Double_t *xyz, Int_t verbose)
 
template<typename T , typename... Args>
EvalTHnLinear (int id, T v, Args...args)
 
void registerDefaultMVAMethods ()
 map of registered TMVA regression methods More...
 
void registerMethod (std::string method, std::string content, TMVA::Types::EMVA id)
 example registering default methods () More...
 
Int_t FitMVA (TTree *tree, const char *varFit, TCut cut, const char *variableList, const char *methodList, const char *weights=NULL, Int_t index=-1)
 
TMVA::MethodBase * LoadMVAReader (Int_t id, const char *inputFile, const char *method, const char *dir)
 MVA regression. More...
 
Int_t LoadMVAReaderArray (Int_t id, const char *inputFile, const char *methodMask, const char *dirMask)
 
Int_t AppendMethodToArray (Int_t index, TMVA::MethodBase *method)
 Register TMVA method to the array at index Not assumed to be used by users. More...
 
Double_t EvalMVAStatArray (int id, int statType, vector< float > point)
 Append method into array of methods - used e.g for bootstrap statistics. More...
 
template<typename T , typename... Args>
EvalMVA (int id, T v, Args...args)
 Evaluate statistic. More...
 
template<typename T , typename... Args>
EvalMVAStat (int id, int statType, T v, Args...args)
 variadic function evaluating MVA More...
 

Variables

Int_t fVerbose =0
 
std::map< int, THn * > hnMapArrayInt
 
std::map< std::string, THn * > hnMapArrayName
 
map< int, TMVA::MethodBase * > readerMethodBase
 TMVA interface. More...
 
map< int, TObjArray * > readerMethodBaseArray
 map of registered TMVA::MethodBase More...
 
map< std::string, std::string > regressionMethodSetting
 map of registered array of TMVA::MethodBase - used to define TMVA statistics (Mean, Median, RMS, quantiles) More...
 
map< std::string, TMVA::Types::EMVA > regressionMethodID
 map of registered TMVA regression methods More...
 

Detailed Description

Interface to Ndimension functional representations (THn and TMVA)

Authors
Marian Ivanov maria.nosp@m.n.iv.nosp@m.anov@.nosp@m.cern.nosp@m..ch see example usage in

Function Documentation

template<typename T >
vector< T > AliNDFunctionInterface::add_to_vector ( vector< T > &  z,
v 
)

generic variadic function - to get it from boost in the future

Helper function to create std vector in variadic function.

verbosity

Definition at line 55 of file AliNDFunctionInterface.h.

template<typename T , typename... Args>
vector< T > AliNDFunctionInterface::add_to_vector ( vector< T > &  z,
v,
Args...  args 
)

Definition at line 56 of file AliNDFunctionInterface.h.

Int_t AliNDFunctionInterface::AppendMethodToArray ( Int_t  index,
TMVA::MethodBase *  method 
)

Register TMVA method to the array at index Not assumed to be used by users.

Parameters
index- registered array index
method- pointer to the method
Returns

Definition at line 337 of file AliNDFunctionInterface.cxx.

Referenced by LoadMVAReaderArray(), and registerMethod().

template<typename T , typename... Args>
T AliNDFunctionInterface::EvalMVA ( int  id,
v,
Args...  args 
)

Evaluate statistic.

Variadic function to evaluate MVA regression method registered using method ID.

Template Parameters
T
Args
Parameters
id
v
args
Returns

Example usage:

  • usage in TTreeFormula. e.g calculate and visualize second derivative of regression
    MVAInput->Draw("AliNDFunctionInterface::EvalMVA(0,fraction,Z,0)-(AliNDFunctionInterface::EvalMVA(0,fraction,Z-1,0)+AliNDFunctionInterface::EvalMVA(0,fraction,Z+1,0))*0.5:Z","Z>2&&fraction>5","");

some optional verbosity needed

Definition at line 111 of file AliNDFunctionInterface.h.

Referenced by registerMethod().

template<typename T , typename... Args>
T AliNDFunctionInterface::EvalMVAStat ( int  id,
int  statType,
v,
Args...  args 
)

variadic function evaluating MVA

Templated variadic function - Evaluate statistic on top of array (readerMethodBaseArray;) of MVA methods To use the method - array o TMVA methods should be registered before using LoadMVAReaderArray or AppendMethodToArray

Template Parameters
T- template type - be default float
Args-
Parameters
id- id of the registered array to evaluate
statType- type of statistic (0-mean, 1-median, 2-rms)
v-
args
Returns

Example usage:

  • compare mean and median statistic of array 2
    MVAInput->Draw("AliNDFunctionInterface::EvalMVAStat(2,0,interactionRate, bz0, qmaxQASum, qmaxQASumR):AliNDFunctionInterface::EvalMVAStat(2,1,interactionRate, bz0, qmaxQASum, qmaxQASumR)","run==QA.EVS.run","");

variadic function evaluating MVA array stat

Definition at line 136 of file AliNDFunctionInterface.h.

Referenced by registerMethod().

Double_t AliNDFunctionInterface::EvalMVAStatArray ( int  id,
int  statType,
vector< float >  point 
)

Append method into array of methods - used e.g for bootstrap statistics.

Return statistic variable using array of MVA methods

Parameters
id- id of the TMVA method array
statType- type of the statistic (mean, median, rms, TODO cumulant)
point- point to evaluate
Returns
- requested statistic

TODO:

TODO - for the moment in evaluation we assume only one variable

  • using the DNN or MLP we should start to support vectors TODO - extend statistic

some optional verbosity needed

Definition at line 357 of file AliNDFunctionInterface.cxx.

Referenced by EvalMVAStat(), and registerMethod().

template<typename T , typename... Args>
T AliNDFunctionInterface::EvalTHnLinear ( int  id,
v,
Args...  args 
)

Variadic function to linearly interpolate THn

Template Parameters
T
Args
Parameters
id
v
args
Returns
interpolated value

Example usage:

Definition at line 88 of file AliNDFunctionInterface.h.

Referenced by GetInterpolationLinear().

Int_t AliNDFunctionInterface::FitMVA ( TTree *  tree,
const char *  varFit,
TCut  cut,
const char *  variables,
const char *  methods,
const char *  weights = NULL,
Int_t  index = -1 
)

Fit MVA regression

Parameters
tree- input tree (or chain)
varFit- colon separated variable string
cut- selection (TTree cut)
variables- colon separated explanatory variable list
methods- colon separated method list - only registered methods can be used (using registerMethod(std::string method, std::string content, TMVA::Types::EMVA id))
Returns
- status weights are saved in the root file

##Example usage in test macro ( QAtrendingFitExample.C function makeMVAFits() and makeMVABootstrapMI() ), e.g: ###

for (Int_t iBoot=0; iBoot<10; iBoot++) {
AliNDFunctionInterface::FitMVA(treeCache, "resolutionMIP", "interactionRate>0", "interactionRate:bz0:qmaxQASum:qmaxQASumR", "BDTRF25_8:BDTRF12_16:KNN", 0, iBoot);
}

TODOs:

  • TODO - user defined splitting training/test
  • TODO - Error handling: file output currently in UPDATE mode - in case of existing entries - regression fail

    Algorithm:

  • 1.) Declare DataLoader
  • 2.) Add the feature variables from the variables list and target variable(s)
  • 4.) Book regression methods from the methods list
  • 5.) Train all methods
  • 6.) Write ascii weight files to root file

0. Declare Factory

1.) Declare DataLoader

TODO check existence - validity of variable - in case of error - exit with error message

3.) Setup DataSet

4.) Book regression methods from the methods list

5.) Train all methods

6.) Write ascii weight files to root file

Definition at line 157 of file AliNDFunctionInterface.cxx.

Referenced by makeMVABootstrapMI(), makeMVAFits(), and registerMethod().

Double_t AliNDFunctionInterface::GetDeltaInterpolationLinear ( THn *  his,
Double_t *  xyz,
Int_t  dIndex,
Int_t  verbose 
)

Linear interpolation of the numerical derivative dV/dx (V(i+1)-V(i-1))/(2(delta)

Parameters
his
xyz
dIndex
verbose
Returns

Definition at line 85 of file AliNDFunctionInterface.cxx.

Referenced by GetDeltaInterpolationLinear().

Double_t AliNDFunctionInterface::GetDeltaInterpolationLinear ( Int_t  index,
Double_t *  xyz,
Int_t  dIndex,
Int_t  verbose 
)

Definition at line 31 of file AliNDFunctionInterface.h.

Double_t AliNDFunctionInterface::GetInterpolationLinear ( THn *  his,
Double_t *  xyz,
Int_t  verbose 
)

Linear interpolation of the bin content.

Parameters
his- input Ndimensional histogram to iterpolate
xyz- NDimensional point where to interpolate
verbose- verbosity flag
Returns

Definition at line 52 of file AliNDFunctionInterface.cxx.

Referenced by EvalTHnLinear(), and GetInterpolationLinear().

Double_t AliNDFunctionInterface::GetInterpolationLinear ( Int_t  index,
Double_t *  xyz,
Int_t  verbose 
)

Definition at line 30 of file AliNDFunctionInterface.h.

Double_t AliNDFunctionInterface::GetInterpolationLinear ( const char *  name,
Double_t *  xyz,
Int_t  verbose 
)

Definition at line 34 of file AliNDFunctionInterface.h.

TMVA::MethodBase * AliNDFunctionInterface::LoadMVAReader ( Int_t  id,
const char *  inputFile,
const char *  method,
const char *  dir 
)

MVA regression.

Current ION of TMVA does not allow standard persistence in root file Way around: Writing - ASCII files are stored as TSting in the root file Reading - String written as ASCII file and read back by TMVA::Reader

Parameters
id- regression method ID (using e.g. hash value)
inputFile- input file (e.g TMVA_RegressionOutput.root)
method- method name (e.g MLP)
dir- directory usually coding regression variable with dir_ prefix (e.g. dir_meanMIPele)
Returns
- error code

TODOs:

  • TODO - ASK TMVA team to implement standard IO
  • TODO - ASK TMVA team to disable requirement to set variable addresses or find switch to make it

Example parameters (see also QAtrendingFitExample.C loadMVAreaders())

AliNDFunctionInterface::LoadMVAReader(0,"TMVA_RegressionOutput.root","MLP","dir_resolutionMIP");
AliNDFunctionInterface::LoadMVAReader(1,"TMVA_RegressionOutput.root","KNN","dir_resolutionMIP");
AliNDFunctionInterface::LoadMVAReader(2,"TMVA_RegressionOutput.root","BDTRF25_8","dir_resolutionMIP");
AliNDFunctionInterface::LoadMVAReader(3,"TMVA_RegressionOutput.root","BDTRF12_16","dir_resolutionMIP");
Int_t id=0; const char * inputFile="TMVA_RegressionOutput.root"; const char *method="MLP"; const char *dir="dir_resolutionMIP"

dummy booking it is not used - TODO - ask TMVA to remove requirement

write weight from the root file to txt files as it is expected by reader

Definition at line 240 of file AliNDFunctionInterface.cxx.

Referenced by LoadMVAReaderArray(), loadMVAreaders(), and registerMethod().

Int_t AliNDFunctionInterface::LoadMVAReaderArray ( Int_t  id,
const char *  inputFile,
const char *  methodMask,
const char *  dirMask 
)

Load array of the MVA reader and register it in the AliNDFunctionInterface method array maps ( readerMethodBaseArray) Method arrays could be later use for the TMVA array evaluation ()

Parameters
id
inputFile
methodMask
dirMask
Returns
error code - 0 mean OK

Example usage in (see also QAtrendingFitExample.C loadMVAreadersBootstrap())

AliNDFunctionInterface::LoadMVAReaderArray(0,"TMVA_RegressionOutput.root","BDTRF12_16",".*resolutionMIP");
AliNDFunctionInterface::LoadMVAReaderArray(1,"TMVA_RegressionOutput.root","BDTRF25_8",".*resolutionMIP");
AliNDFunctionInterface::LoadMVAReaderArray(2,"TMVA_RegressionOutput.root","KNN",".*resolutionMIP");
}

Definition at line 302 of file AliNDFunctionInterface.cxx.

Referenced by loadMVAreadersBootstrap(), and registerMethod().

template<typename T , typename... Args>
vector< T > AliNDFunctionInterface::make_vector ( v,
Args...  args 
)

Variadic function to create an vector (boost implementation )

Template Parameters
T
Args
Parameters
v
args
Returns

Example usage: to create vector of integers to create vector with 3 integers

auto a = AliNDFunctionInterface::make_vector<int>(1, 1, 3);

Definition at line 70 of file AliNDFunctionInterface.h.

void AliNDFunctionInterface::registerDefaultMVAMethods ( )

map of registered TMVA regression methods

Register example MVA methods.

Definition at line 376 of file AliNDFunctionInterface.cxx.

void AliNDFunctionInterface::registerMethod ( std::string  method,
std::string  content,
TMVA::Types::EMVA  id 
)

example registering default methods ()

Definition at line 42 of file AliNDFunctionInterface.h.

Referenced by registerDefaultMVAMethods(), and RegisterFitters().

Variable Documentation

Int_t AliNDFunctionInterface::fVerbose =0
std::map<int, THn*> AliNDFunctionInterface::hnMapArrayInt

Definition at line 24 of file AliNDFunctionInterface.h.

Referenced by EvalTHnLinear().

std::map<std::string, THn*> AliNDFunctionInterface::hnMapArrayName

Definition at line 25 of file AliNDFunctionInterface.h.

map<int, TMVA::MethodBase *> AliNDFunctionInterface::readerMethodBase

TMVA interface.

variadic function evaluating THn

Definition at line 37 of file AliNDFunctionInterface.h.

Referenced by EvalMVA(), GetInterpolationLinear(), and LoadMVAReader().

map<int, TObjArray* > AliNDFunctionInterface::readerMethodBaseArray

map of registered TMVA::MethodBase

Definition at line 38 of file AliNDFunctionInterface.h.

Referenced by AppendMethodToArray(), and EvalMVAStatArray().

map<std::string, TMVA::Types::EMVA> AliNDFunctionInterface::regressionMethodID

map of registered TMVA regression methods

Definition at line 40 of file AliNDFunctionInterface.h.

Referenced by FitMVA().

map<std::string, std::string> AliNDFunctionInterface::regressionMethodSetting

map of registered array of TMVA::MethodBase - used to define TMVA statistics (Mean, Median, RMS, quantiles)

Definition at line 39 of file AliNDFunctionInterface.h.

Referenced by FitMVA().