Adding tree branches problem

Hi ROOT Family,

It is me again. I saved my data to a tree with two branches x1 and x2. And I copied my x2 branch to an array c[ ] (with the amount of 48777 data). I used the “unique” function to delete the duplicate data, and I only needed the non-duplicate data, so I saved all my non-duplicate data to another array d[ ] (with the amount of 20000 data). Then, I would like to copy the data from d[ ] to x2_new which is a new branch. Now, the x2_new branch only has the non-duplicate data, and the amount is 20000. I would like to keep the x1 the corresponding data only, i.e. the data which corresponds to the 20000 non-duplicate x2 data. So, I defined a new branch x11, and filled the tree. But, my result was wrong. None of my x2_new nor x11 branch saved the data I needed. I saw there were 48777 data in both of them, but not 20000 as desired. Could anyone help with my problems? I must made a mistake by defining these two new branches, but I could not figure it out. Thanks so much for any helps.

double x11;
    TBranch* branch_x1 = tree->Branch("x11", &x11, "x11/D");
double x2_new;
    TBranch* branch_x2 = tree->Branch("x2_new", &x2_new, "x2_new/D");    


for (int i5 = 0; i5 < n; i5++) {
        tree->GetEntry(i5);
        x2_new = d[i5];
        branch_x2->Fill();
        branch_x1->Fill(); // Fill "x1" with corresponding values
    }

daya_1.C (2.5 KB)
cross_dmp.txt (2.3 MB)

Hi Rene, could you please tell a little bit more about the compression algorithm or just give a short example? I only want to keep the tree with the non-duplicate data, but I do not know how to delete the original x1 and x2 branches, so I added two new branches x11 and x2_new to my tree, and this step may cause trouble. Thanks so much for your time!

Hi Rene, could you please tell a little bit more about the compression algorithm or just give a short example? I only want to keep the tree with the non-duplicate data, but I do not know how to delete the original x1 and x2 branches, so I added two new branches x11 and x2_new to my tree, and this step may cause trouble. Thanks so much for your time!

A quick note that the variable x11 seems to never be assigned any values.

Yes. But I don’t know why x11 did not get any data

In the code snippet I saw, x11 is never assigned a value nor attached to a branch being read. One of the two would be necessary for it to have any kind of information loaded into it.

Yes, thank you. I will check it. I did not assign anything to he x11 branch.

Yes, thank you. I will check it. I did not assign anything to he x11 branch. Thanks so much for your help.