Hello all,
I experience a strange problem in merging 3 trees. These trees contain the same branches, essentially values recorded by sensors at different times. The point is, some of the sensors stopped working during the measurement, so the 3rd file has the same branches as the other 2, but some of the branches are empty. Now, when I merge the 3 files, the branches for which the sensor got broken are completely empty, i.e. the values from the first 2 files were not copied in the merged tree. Of course when I only merge the first 2 files it’s fine.
In other words, I do this:
root -l file1.root
HV_Mon->Draw(“H_METEOMK1_85121:time”) -> fine
root -l file2.root
HV_Mon->Draw(“H_METEOMK1_85121:time”) -> fine
root -l file3.root
HV_Mon->Draw(“H_METEOMK1_85121:time”) -> empty draw
hadd -f5 merge.root file1.root file2.root file3.root
root -l merge.root
HV_Mon->Draw(“H_METEOMK1_85121:time”) -> empty draw
hadd -f5 merge.root file1.root file2.root
root -l merge.root
HV_Mon->Draw(“H_METEOMK1_85121:time”) -> fine
I also tried with TChain and TList, but with same results.
Of course you’ll ask me why I want to merge an empty file, but actually file3 contains some other branches with other working sensors… For them the merging goes fine btw.
I used root 5.34/36 and 6.19/01 on Linux Ubuntu, with again no difference.
Update: in fact it is a problem with the Draw! If I use the command as in my post, the Draw creates a histogram between -1 and 1 in vertical axis, which turns out to be outside the range of values of this variable (Usually it scales automatically to the proper range, but in this case it fails, no idea why). If I define a histogram and then plot it here, then it works, which means the values are indeed in the merged file…
Seb
Where in the merged-bad.root you can see that the 2nd branche values associated with the times of the first files ends up being associated with the times of the 2nd files …
To solve the problem, the best is to always merged files where the branch have always the sames number of entries. To do so you need to have a way to tell that even-though the branch has the value it is ‘invalid’. This can be done either by adding a column b2_valid or by replacing the branches by vector of size 0 or 1.