memory resident ntuples

From: Ulrich Jost (jost@evalo1.ific.uv.es)
Date: Mon May 24 1999 - 17:37:38 MEST


Hi,

in a program I load an ntuple from a file into memory like this:

  static Float_t br[6];
  int i=0;

	TFile rfile("bla", "read");
	if (rfile.IsOpen()){
	  MeasurementData *md = new MeasurementData();
	  md->name = (TObjString*) rfile.Get("name");
	  md->annotation = (TPaveText*) rfile.Get("annotation");
	  md->factors = (TObjString*) rfile.Get("factors");
	  md->titles = (TObjString*) rfile.Get("titles");
	  TNtuple *nt = (TNtuple*) rfile.Get("ntuple");
	  nt->SetBranchStatus("*", 1);
	  TObjArray *array = nt->GetListOfBranches();
	  for (TBranch *branch = (TBranch*) array->First(); branch != 0; 
	       branch = (TBranch*) array->After(branch))
	    nt->GetBranch(branch->GetTitle())->SetAddress(&br[i++]);

	  gDirectory = gROOT;  // change current dir to memory
	  md->ntuple = (TNtuple*) nt->CloneTree();
	  rfile.Close();   // deletes nt
	  gProbe->mlist->append(md);
	  md->ntuple->Print();

Does not crash and Print() looks okay, but when I read this ntuple with
    for (Int_t i=0; i<(Int_t) md->ntuple->GetEntries(); i++){
      md->ntuple->GetEvent(i);
      cout<<i<<" "<<md->ntuple->GetArgs()[ix]<<"  "
	  <<md->ntuple->GetArgs()[iy]<<endl;
    }
which works fine if I use it for ntuples created in memory and not read
from a file, it seems all entries are 0, or at least GetArgs() only
returns 0.

Any idea?

Thanks, Ulrich



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:33 MET