Express a quantity as a function of an index

Hi All,
Three quantities called X, Y, and I are stored in leaves of the same tree.
I is an index, i.e I={1, 10, 3, 51,…}. X and Y are functions of I, namely X=X(I) and Y=Y(I).
I would like to write a root macro which translates the following commands

for ( i ∈ I )
if( X(i) > a )
draw( Y(i) )

where a is a real number.
I am new in root, and it is not so clear to me how too access and manipulate quantities stored in a root file.
If file.root is my root file, how should I proceed?
Thank you for your help!

Hi Mark,
in C++, how about

#include <ROOT/RDataFrame.hxx> // until v6.12, ROOT/TDataFrame.hxx

int main()
{
  TApplication app("app", nullptr, nullptr); // to keep program alive after you draw a canvas

  // until v6.12, ROOT::Experimental::TDataFrame
  ROOT::RDataFrame df("treeename", "file.root");
  auto histoy = df.Filter("x > 0").Histo1D("y");
  histoy->Draw();

  app.Run(); // keep program alive after drawing canvas
  return 0;
}

See this answer for an overview of the different available interfaces to access data stored in ROOT trees.

Cheers,
Enrico