list of unique values from a TTree

From: Rob Mahurin <rob_at_jlab.org>
Date: Fri, 25 May 2012 09:08:52 -0400


Hi ROOT,

I have some TTrees with a handful of branches and a few million entries each. One of the branches ("scandata1") is a label for different phases of a measurement and takes on only about a dozen unique values. I want to make a list of these unique values that I can iterate over.

If I move over into PyROOT, I can do this in a line:

In [33]: { tree.scandata1 for x in range(0, tree.GetEntries()) if tree.GetEntry(x) } Out[33]: set([40.0, 5.0, 70.0, 95.0])

My questions are:

  1. Is there an easy-to-write pattern for doing this without switching over to Python? I can't see a way without mucking around with branch addresses and repeating myself a lot.
  2. Why is this (and the equivalent GetEntry loop called from CINT) so much slower that tree.Draw("scandata1")?

Thanks,
Rob

-- 
Rob Mahurin
University of Manitoba, Department of Physics
and Thomas Jefferson National Accelerator Facility
12000 Jefferson Avenue Suite 6, Newport News, VA 23606
office 757-269-6510; elsewhere 865-207-2594; rob_at_jlab.org
Received on Fri May 25 2012 - 15:09:09 CEST

This archive was generated by hypermail 2.2.0 : Fri May 25 2012 - 23:50:02 CEST