Load TTree from file and store in different file

Hi
thanks again. I tried the GetTree() method but it returns a null-pointer.

void TestTree2(){
    TChain* c = new TChain("MyTree","MyTree");
    c->Add("TEST.root/MyTree");
    c->GetUserInfo()->Print();
    if (c->GetTree()== 0){cout << "NULL" << endl;}
    c->GetTree()->Print();
    c->GetTree()->GetUserInfo()->Print();
    MyTree* t = new MyTree(c);
}

running this code results in…

root [4] TestTree2()
Collection name='UserInfo', class='TList', size=0
NULL
Error: illegal pointer to class object GetTree() 0x0 3016  C:\[...]\MyTreeRun.c(14)
*** Interpreter error recovered ***

I am sure that the tree in the file is “ok” as I get the correct output when calling the constructor with the TTree (as in TestTree3()). I added the “/MyTree” to the filename when adding the file to the chain but also this didnt help.