Access TTree from dataframe after Snapshot method

Dear all,

I am (again) trying to switch my analysis codes to Root dataframes, since I have seen that Proof is going to disappear. It’s a very basic question, but after writing my dataframe to TTree using Snapshot, I would like to access the TTree pointer to Print its content.

Is there a direct way to access the TTree after Snapshot without opening the TFile and getting the TTree ? Or is there an equivalent to TTree::Print() with the dataframe ? I have seen the Display method but which seems more like a TTree::Scan

Thanks in advance

Jérémie

Hello @dudouet,

there is two options:

  • You know already that you can open the file yourself, so I won’t give details.
  • The other option is the Snapshot action itself (see documentation here). It returns a new RDataFrame, which is connected to the snapshotted tree. So you could write:
  auto snapshotResult = myRDF.Snapshot(...);
  snapshotResult->Describe()->Print();
  // or
  for (auto const & columnName : snapshotResult->GetColumnNames()) {
    std::cout << columnName << "\n";
  }
  // or
  auto d1 = snapshotResult->Display("");
  d1->Print();

Thanks, snapshotResult->Describe()->Print(); is what I wanted to do.

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