Calculating covariance matrices in a PROOF job


I am trying to build a covariance matrix of N variables from a TTree, previously I used a simple home-made class for this, and stored the output in a TMatrix. But after porting my analysis to TSelector (via SFrame) I no longer have a trivial way of getting my combined covariance estimate.

I tried to store my temporary matrices for each event in a new output TTree, as TMatrix and TVector types (then I could do the normalization part before plotting), but it doesn’t look like the merger likes these types?

I have attached my old single-threaded implementation, to give an idea about what I did before.

For now I’m simply histogramming every variable combination using TH2, but its too slow for more then a few variables.


[Update] I ended up running over the data without PROOF, using the attached method, in the end it’s properly faster just to hardcode the covariance matrix into my analysis anyway :slight_smile:
CovarianceMatrix.h (4.3 KB)

Only the classes that have a Merge function are merged by PROOF. TMatrix does not have a Merge function as in general this does not make sense.