Hello,
I have a multidimensional array dynamically declared as arrays of pointers. Is there a way to store such a thing in a TTree? Following script gives improper values in the stored array…
int main()
{
TFile *f = new TFile("test.root", "RECREATE");
TTree *t = new TTree("t", "t");
unsigned char ***arr = new (unsigned char **[2]);
for(int i=0; i<2; ++i)
{
arr[i] = new (unsigned char*[2]);
for(int j=0; j<2; ++j)
{
arr[i][j] = new unsigned char[2];
for(int k=0; k<2; ++k)
{
arr[i][j][k] = k;
cout << i << " " << j << " " << k << " " << (int)arr[i][j][k] << endl;
}
}
}
vector< vector<int> > v;
t->Branch("one", arr, "one[2][2][2]/b");
t->Fill();
t->Write();
f->Close();
return 9;
}