Current dir not associated with a file, TTree not written

Hi,

I am encountering problems while trying to fill a TTree set as a global variable.

Actually I have to benchmark a third-party framework in C++/python, so I chose the quick & dirty option, that is to create custom header and source files including all the variables I need to fill, them being set as global variables. Amongst those variables are some histograms, a TTree, and the file where they are to be stored.

The filling and writing works fine for the histograms, but for the TTree I am experiencing the following issue at runtime :

Below is the way things are defined. I tried a few variations without any success for now, hence the welcoming of any suggestion.

[…] extern TFile* watchfile; extern TTree zetree; […]

[code][…]
TFile *watchfile = new TFile(“essailogbis.root”,“recreate”);
TTree zetree(“zetree”,“zetree”);
ZeFit zefit = {0};

int initialize()
{
// watchfile->cd();
zetree.SetDirectory(watchfile);
zetree.Branch(“zefit”,&zefit,“evt/I:time/F:lambda:theta:phi:dist:theta_true:phi_true:dist_true:is3D/O”);
initdone = true;
return 0;
};
[…][/code]

Thanks.

Actually, despite the error, the TTree is written…

Hi,

Somewhere in your code you have: zetree.Write();replace this by watchfile->Write();orzetree->GetCurrentFile()->Write();

Cheers,
Philippe.

Actually I had both lines, which explains why the tree was written anyway. Thanks !