GetObject member function for TFile


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Here on pages 321-322 there are explained how write and read Columnar data in ROOT.
atomfizika.elte.hu/nehezion/ROOT_Basic_Course.pdf

When I just copy the code and try to launch it there was shown error that “no matching member function for call to ‘GetObject’”. How then this function was used in mentioned tutorial ?

I see no problem with this code (using hsimple.root from the $ROOTSYS/tutorials/ directory:

TH1F *read_ntuple()
{
   TFile f("hsimple.root");
   TNtuple *myntuple = nullptr;
   f.GetObject("ntuple", myntuple);
   TH1F *h = new TH1F("h", "h", 64, -10, 10);
   h->SetDirectory(nullptr);
   for (auto ievt: ROOT::TSeqI(myntuple->GetEntries())) {
      myntuple->GetEntry(ievt);
      auto xyzt = myntuple->GetArgs(); // Get a row
      if (xyzt[2] > 0) h->Fill(xyzt[0] * xyzt[1]);
   }
   h->Draw();
   return h;
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.