Find out /change current file

Hi! Is there a way to find the current file accessed and change it to a specified one in a compiled program which uses the root system? What I want to do is write a small piece of code inside gutrev() of TGeant3 to save some trees in a specific file. This used to work earlier when aliroot used only one file for everything but now that it uses many files my trees get saved in arbitrary files (I think that is the reason I can’t find them in the original file I used (galice.root)). I suppose gFile is not defined inside a compiled program, but only in cint? (Or not?) If it is, does it suffice to put a gFile->Cd() statement? If this is the case, is there a way to get the list of open TFiles inside a compiled program, since I can’t know the TFile pointer associated with a specific file in the routine of interest? Thanks!

To use gFile in a compiled program, you have to #include :TFile.h"
However, using gFile is not the solution to your problem.
You must know the pointer to the file where you want to store your object and do
myfile->cd();
before writing your object.
You can also get a pointer to the TFile knowing the file name
TFile *myfikle = gROOT->GetFile(“myfile.root”);

Rene