Re: [ROOT] Plotting an stl vector

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jan 20 2004 - 18:06:24 MET


Hi Troy,

Currently the TreeViewer and the TTree::Draw machinery do not recognize
stl vectors of basic types or objects. We are working on improvements
in the query system supporting STL types.

Meanwhile, you can use a simple variable length array of ints with
instead of
  std::vector<int>  fArray;
declare
  int  fN;      //array length
  int* fArray;  //[fN]

In the Treeviewer, you will see the two members. Clicking on fArray will
histogram the array.

see examples in $ROOTSYS/test/Event.h

Rene Brun

Troy Straszheim wrote:
> 
> Hi roottalk-
> 
> I'm new to this, have what I hope is an easy question to answer:
> 
> I have a class that contains an stl vector of ints, and I use a TFile and a TTree to write it out to a file.  When I load up the file in an interactive session, I can see all the data, as expected, in my branches when I access them directly, e.g. branch->GetEntry(index).  However when I click the leave in the tree viewer, I get the message
> 
> Warning in <TSelectorDraw::ProcessFillObject>: Not implemented for vector<int,allocator<int> >
> 
> So I'm guessing that I need to somehow convert this vector into something that is plottable by root.  Can anyone suggest a techinque to do this?
> 
> I may have to repeat this process for a very large number of root files with stl vectors of various types...  the more generic the better.  Perhaps the idea is a file converter, from root-with-stl-nonplottables to root-with-plottables.
> 
> Any tips are gratefully accepted,
> 
> Thanks,
> 
> Troy Straszheim



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET