Outputting large (>2 GB) files

Hi,

I’m creating large (> 2 GB) output root-tuples with a piece of code that looks like this:

  TFile * my_file = new TFile("myoutput.root","RECREATE");
  TTree * my_tree = new TTree("tree", " root-tuple description");
  my_tree->SetDirectory(my_file);
   Event * event = new Event; // output root-tuple structure
  TBranch * my_branch = my_tree->Branch("my_branch", "Event", 
                     &event, 8000, 1);

  for (Int_t jentry = 0; jentry != nentries; ++jentry)
  { // loop over events
    // do something
   my_tree->Fill();
   } // loop over events

  my_file->cd();
  my_tree->Write();
  my_file->Close();

When the 2 GB-limit is reached, file myoutput.root closes as expected, a new one (named myoutput_1.root) is created and life goes on. The problem is at the end of the event loop, when I try to cd/write/close a file that is already closed (myoutput.root).

What is the proper way of doing this?

Thanks

–Christos

PS Using /D0/ups/root/Linux-2-4/v3_05_07aKCC_4_0-exception-opt-thread/bin/root (I think there are some backwards-combatibility issues with v4_00_03a ?

The end should be:

my_file = my_tree->GetCurrentFile(); my_file->cd(); my_tree->Write(); my_file->Close();
See TTree::ChangeFile
Cheers,
Philippe

Thanks Philippe!

–C