JuliaHEP / UpROOT.jl

Julia package to access CERN ROOT files, wraps Python package uproot
Other
15 stars 3 forks source link

tree[:,:] vs tree[:,propertynames(tree)] #12

Closed mmikhasenko closed 3 years ago

mmikhasenko commented 4 years ago

image

also asked on discourse https://discourse.julialang.org/t/tables-jl-uproot-jl-and-the-speed/44737/4

oschulz commented 4 years ago

Could you make that data file available?

oschulz commented 4 years ago

In general, this happens when iterating over a TTree serially, entry by entry - that's slow with UpROOT, due to the way Python uproot works. However, you're doing a multi-entry getindex in both cases. I'd really like to have a similar file to test with.

mmikhasenko commented 4 years ago

Thanks for looking at it.

#include "TString.h"
#include "TFile.h"
#include "TTree.h"

#include <string>
#include "stdlib.h"

int create_file() {

  TFile *f = new TFile("test_tree.root", "recreate");
  TTree *t = new TTree("mytree", "mytree");

  auto app = "EXYZ";
  const uint Np = 4;
  std::string names[Np] = {"pBeam", "pPim", "pEta", "pRecoil"};

  //
  double v[Np][4];
  for (uint n=0; n<Np; n++)
    for (uint i=0; i<4; i++)
      t->Branch(TString::Format("%s_%c",names[n].c_str(), app[i]), &v[n][i]);

  const int Nev = 300000;

  for (uint i=0; i <= Nev; i++) {
    for (uint n=0; n<Np; n++)
      for (uint i=0; i<4; i++)
    v[n][i] = (rand() % 100) / 100.0;
    //
    t->Fill();
  }

  t->Write();
  f->Close();

  return 0;
}
oschulz commented 4 years ago

Why did you close the issue - is this resolved?

mmikhasenko commented 4 years ago

Ha, by mistake, I did not notice. Perhaps, the cat walked on the keyboard

oschulz commented 4 years ago

Hehe, Ok, I'll take a look then.

mmikhasenko commented 4 years ago

I will be showing Julia to the CERN students on Friday. Nervous as introducing a new girlfriend to parents

oschulz commented 4 years ago

Oh, nice! Anything you need for that, last-minute, that I can help with?

mmikhasenko commented 4 years ago

thanks! the uproot part works nicely. Enjoy the vacation!

mmikhasenko commented 3 years ago

wrong place for posting. I was making a similar example for investigation in UnROOT. I think this issue can be closed.

oschulz commented 3 years ago

Thanks!