Break Segmentation violation with TMatrixD

Hi,

I am a relatively new ROOT user working on big data from ATLAS experiment. I have been putting effort in take some data from a tree. This tree has one branch with some leafs. I took the data from the leaf &sample and filled in a vector Short_t sample[4][[64][48][7]. But, I need to put the data from a specific location (i.e, sample[0][0][0][i] , 0<i<6) in a TMatrixD so that I can do some math with the data . The tree has 9258 entries. Unfortunately, the code below is not successful and show Break segmentation violation specifically on line 21. Why could I not assign it to the vector Double_t data ?

1. TFile f("mu50.root");
2. TTree *h2000 = (TTree*)f.Get("h2000");
3. Short_t sample[4][64][48][7];
4. h2000->SetBranchAddress("sample",&sample);
5. Long_t nentries = h2000->GetEntries();
6. Int_t par = 2; 
7. Int_t mod = 30;
8. Int_t ch = 21;
9. Double_t data[7];
10. Double_t dataLog[7];

11. TMatrixD tmp(nentries,7);

12. for(Long_t entry = 0; entry < nentries; entry++)
13. 	{
14. 	          h2000->GetEntry(entry);
15. 			
16. 			for(Int_t i = 0; i<7; i++)
17. 			{
18. 				data[i] = sample[par][mod][ch][i];
19. 				dataLog[i] = TMath::Log(sample[par][mod][ch][i]);
20. 			}

21. 		tmp.SetMatrixArray(data); 
22.    }

What does the SetMatrixArray method description say about the minimal size of the input parameter “data”?

ROOT User’s Guide -> Linear Algebra in ROOT

Sorry, I did not get what you mean. Is there a minimum limit to the vector size to be set to the TMatrixD with SetMatrixArray() method?
I have already checked this documentation. I am able to do that on the prompt with an arbitrary matrix but not with the code above…

I checked the documentation again. It seems to be an issue with the limits of the “data” array, as you suggested. But what do you think I could do in this case?
Is there another better method that I could use for this class TMatrixD?

Try: tmp[entry][i] = sample[par][mod][ch][i];

It seems to be working for now as the script is running without errors.
I will check it all for future problems with SetMatrixArray().

Thank you a lot