Writing canvas,ntuple,tree with a multifunction script into a root file

Hi All,

I created a script as in the following one.
Data wasn’t written into “rootfile.root” ! What’s the problem here ?

void Analysis1() {
...
}
void Analysis2() {
...
}
void AnalysisMain() {

TFile *f1 = new TFile("rootfile.root","RECREATE");

Analysis1();
Analysis2();

f1->Write();

}

Thanks for your help,
Cheers,
Ersel

Hi Ersel,

impossible to say. Everything looks fine except we have no idea about what happened in the functions…
Did you try to close the file?

Cheers,
D

The script didn’t run because another TFile(*.root,“READ”) is inside the Analysis1() function, so it didn’t write into “rootfile.root”.I got an error due to that.
Then, I took it inside AnalysisMain() function ,and then tried to run it. it works now .

Thanks,
Cheers,
Ersel