Strange error when trying to oben a Branch

Dear friends of root

I have a strange problem with a root tree.

In my C++ Program I created a tree and branch (I use the “modern” Bronch method) and then fill the branch with data do the Write() and the Close() and after my C++ program finishes I have a root file.
(no errors warnings what so ever at this point)
Now I start the root interpreter to look at my Branch.
I can open the file:
TFile* myfile = TFile::Open(“statisticaltestsData.root”); //works
I open the tree:
TTree* mytree = (TTree*)gDirectory->Get(“m_statDataTreePtr”); //this line also executes with no error
then I do anything with the mytree pointer like
and I get this:
root [5] mytree.Print()
Error: illegal pointer to class object mytree 0x0 2855 (tmpfile):1:
*** Interpreter error recovered ***

Interestingly the root file as different sizes if I loop over a different amount of tracks in my main program so it evens seems that the data is written to file but just not accessible.

Also my code once worked (before Xmas) and I could access the Branch and the data in it was the one I waned to have there.
I did not change anything consciously and now it does not work anymore.

Does anybody have any idea in at what kind of error this behaviour hints?

thanks in advance and kind regards

Moritz Nadler

The problem is solved. I was caused by my framework also writing into other root files and I had to ad a ->cd() before the ->Write() that the 2 root files did not get into each others way.