I have managed to simplify the source code and the problem I have. See Simultaneous writing and reading of a TTree .