# Spectator variables in correlation matrix

**URL:** <https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735>\
**Category:** TMVA\
**Created:** [February 9, 2022, 4:18pm UTC](https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735 "2022-02-09T16:18:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffedericaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ffedericaa/32/26818_2.png) [@ffedericaa](https://root-forum.cern.ch/u/ffedericaa)\
**Post date:** [February 9, 2022, 4:18pm UTC](https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735/1 "2022-02-09T16:18:12Z")

</div>

Hi all, is there a way to insert the spectator variables inside the correlation matrix for signal and background?Thanks in advance!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 10, 2022, 2:03pm UTC](https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735/2 "2022-02-10T14:03:31Z")

</div>

@moneta can help I guess.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [February 10, 2022, 5:18pm UTC](https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735/3 "2022-02-10T17:18:57Z")

</div>

Hi,

Do you mean adding the spectator variables for the computation of the overall correlation matrix that is performed at the beginning in TMVA when building the internal data set ?  
There it is not possible to use the spectator, the correlation is computed using only the standard variables.  
You can however compute yourself the correlation/.covariance matrix with some code, either from the TNVA DataSet, see for example:  
[https://root.cern/doc/master/DataSetFactory\_8cxx\_source.html#l00579](https://root.cern/doc/master/DataSetFactory_8cxx_source.html#l00579)  
Or if you have the input data in an array you can also use the [TPrincipal](https://root.cern/doc/master/classTPrincipal.html) class and TPrincipal::GetCovarianceMatrix.

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![ffedericaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ffedericaa/32/26818_2.png) [@ffedericaa](https://root-forum.cern.ch/u/ffedericaa)\
**Post date:** [February 10, 2022, 5:47pm UTC](https://root-forum.cern.ch/t/spectator-variables-in-correlation-matrix/48735/4 "2022-02-10T17:47:02Z")

</div>

Thanks a lot for the response! The fastest way I found so far is plotting the correlation plots from the TrainTree using the className flag to select Signal and Background.
