I’m trying to write a script to compare arbitrary root files and determine if the objects within are equivalent, apart from the timestamps and I am thinking about compare the objects’ buffer in root file. I have tried two different methods to access the buffer of objects, but none of them works.
TFile f1("f1");
TFile f2("f2");
TIter next_1(f1.GetListOfKeys());
TIter next_2(f2.GetListOfKeys());
TKey *k_1;
TKey *k_2;
k_1=(TKey*)next_1();
k_2=(TKey*)next_2();
Long64_t f1_seek_key = k_1->GetSeekKey();
Long64_t f2_seek_key = k_2->GetSeekKey();
Int_t nbytes_1 = k_1->GetNbytes();
Int_t nbytes_2 = k_2->GetNbytes();
char *buf_1 = new char[nbytes_1];
char *buf_2 = new char[nbytes_2];
f1.ReadBuffer(buf_1, f1_seek_key, nbytes_1);
f2.ReadBuffer(buf_2, f2_seek_key, nbytes_2);
buf_1 and buf_2 arrays are empty after calling ReadBuffer()
TFile f1("f1");
TFile f2("f2");
TIter next_1(f1.GetListOfKeys());
TIter next_2(f2.GetListOfKeys());
TKey *k_1;
TKey *k_2;
k_1=(TKey*)next_1();
k_2=(TKey*)next_2();
char *buf_1 = k_1->GetBuffer();
char *buf_2 = k_2->GetBuffer();
The program was crashed when I tried to access contents in buf_1 and buf_2 and I got error message
segmentation violation.
What is the right way to read buffer of object from root file?