Where to open TFile when using TTree Write?

Thank you, that works. At the end of the code before doing the Write, I will have to “cd” back to the “aFile” directory, right? Like this:

    TFile aFile("TEST.root", "RECREATE");
    TTree* tt_myTree = new TTree("myTree", "TEST");
    gROOT->cd();
    .... // do histogram stuff
    aFile.cd();
    tt_myTree->Write();