Stupid problem, Tree Filling, Reading basket Size Error

Hello Root supporters,

again I have a strange behaviour which I cannot figure out where it comes from, neither can it google, or find the solution here.

I create a TTree, Set Branches with single variables and array (i.e. very simple objects), do some Reconstruction, fill it within a counting loop.



After this fucntion I can Print the Tree (it has only 1800 entries)I can Scan it in batch mode, everything looks correct.
Then I create a new Tree with Clone() of the old one. Then I open a file (already created before) and write the old Tree in there.

The new cloned Tree is then used for Drawing, but as soon as I wand to draw i get these error messages…

Error in <TFile::ReadBuffer>: error reading all requested bytes from file ShowRecEff__PADI_0_BTPA_0_BGTP_0_ALTP_2_FP_1_MP_4_NP_31_LT_0_MC_1__ParaSet_0_To_0.txt.root, got 50086 of 114571
Error in <TBranch::GetBasket>: File: ShowRecEff__PADI_0_BTPA_0_BGTP_0_ALTP_2_FP_1_MP_4_NP_31_LT_0_MC_1__ParaSet_0_To_0.txt.root at byte:0, branch:xb, entry:-1, badread=-1]
Warning in <TBasket::ReadBasketBuffers>: basket: has fNevBuf=0 but fEntryOffset=0, pos=230761, len=19408, fNbytes=0, fObjlen=0, trying to repair

Followed when calling (tree)->Draw(“xb:yb”) with a nice terminate called after throwing an instance of ‘std::bad_alloc’ what(): std::bad_alloc Aborted error message :slight_smile:.

I have no idea what could go wrong in my code, so it would help me a lot if you give me hints where the problem could be located.
If you need more code to understend this in detail i can give you…

Best regards and many thanks,

You should use TTree::CloneTree to clone a tree with its content (not Clone). See examples in tutorials/tree/copytree2,3.C
If you still have problems, post the shortest possible RUNNING script reproducing your problem.