# Native way to get correlation matrix of branches of a tree

**URL:** <https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467>\
**Category:** TMVA\
**Created:** [May 25, 2024, 4:27pm UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467 "2024-05-25T16:27:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorsedh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gorsedh/32/25831_2.png) [@gorsedh](https://root-forum.cern.ch/u/gorsedh)\
**Post date:** [May 25, 2024, 4:27pm UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/1 "2024-05-25T16:27:47Z")

</div>

Hello,  
I was looking at some code for doing correlation matrices for different variables in a tree and i started wondering if there is a native way to do so. Something like  
tree-\>getCorrMatrix(“branch1&&branch2&&…”,“weightBranch”);  
and already draws it (maybe)  
where branch1,2… are the branches with the variables i want to get the correlation matrix of, and weightBranch may be a branch containing the weight of each event. Would also be interesting to have formulas relating the different branches (“(branch1+branch2)&&branch3…”)

I’m sorry if it already exists, I was looking for it but i was not able to find it.  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [May 25, 2024, 8:39pm UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/2 "2024-05-25T20:39:43Z")

</div>

Hi,

Not that I am aware of. Adding experts in the loop in case I am missing something (@moneta @pcanal ).

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![gorsedh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gorsedh/32/25831_2.png) [@gorsedh](https://root-forum.cern.ch/u/gorsedh)\
**Post date:** [June 3, 2024, 12:45pm UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/3 "2024-06-03T12:45:42Z")

</div>

If it’s not there maybe it could be useful to implement in the future(?).  
In any case thanks again for your response, cheers!

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 20, 2024, 6:31am UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/4 "2024-06-20T06:31:30Z")

</div>

Hi,

Apologies for the delay. It could be useful but presently we do not have resources to put this on the program of work. Are you interested in giving it a try?

Best,  
Danilo

---

<div class="post-metadata">

**Author:** ![gorsedh](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gorsedh/32/25831_2.png) [@gorsedh](https://root-forum.cern.ch/u/gorsedh)\
**Post date:** [June 20, 2024, 7:31am UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/5 "2024-06-20T07:31:29Z")

</div>

Hello,  
Sounds good, maybe we can discuss it at the end of next month? (If it’s not an issue)  
MC

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 21, 2024, 4:41am UTC](https://root-forum.cern.ch/t/native-way-to-get-correlation-matrix-of-branches-of-a-tree/59467/6 "2024-06-21T04:41:46Z")

</div>

Sure! Talk to you at the end of July. The best way to proceed, I think, could be to submit a PR to [GitHub - root-project/root: The official repository for ROOT: analyzing, storing and visualizing big data, scientifically](https://github.com/root-project/root) and take it from there.

Thanks a lot!

Cheers,  
Danilo
