Re: [ROOT] CINT problem with std::vector

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jan 09 2002 - 11:52:29 MET


Hi Sean,

As I already reported yesterday to roottalk in the discussion about STL,
ROOT needs the compiled class in case of STL members.
I would like to include the possibility to support simple cases like
  vector<int>
  vector<myclass>
such that the compiled class is not required to read the original file.
Meanwhile, you can use ACLIC as a nice substitute.
To use ACLIC in your case, I have modified the file run_readback.C as follow;

#include "TTree.h"
#include "read_back.h"

void readback() {
  read_back t;
  t.GetEntry(1);
  t.Show();
  t.Loop();
}

then in a ROOT session
root > .L run_readback.C+
root > readback()

Rene Brun


Sean Kelly wrote:
> 
> Dear ROOT'ers
> 
> I have followed a few STL ROOT I/O threads on the web
> but didn't see a clear answer to the following type
> problem.  I am running  3.02/06 redhat release
> 2.2.19-6.2.1smp.
> 
> I have defined a simple class that has an STL vector
> as a data memeber.  In compiled code it is possible
> to write and then read back the object without any
> problems with a split level that puts the stl vector
> in its own branch.
> 
> I have noticed the following.
> 
> 1) MakeClass does not generated the necessary member
>    declarations and Branch calls for the vector.
> 
> 2) I put these in by hand and everything works fine
>    in compiled code
> 
> 3) CINT chokes on the vector member functions
> 
> I have tarred up my test project and one can reproduce
> the successfull (failure) mode by typing.
> 
> make
> ./run_test
> ./run_readback
> root
> root [0] .L run_readback.C
> root [1] main()
> 
> The output from the failed mode is shown below.
> 
> ======> EVENT:1
>  x               = 1.000000
>  y               = 10.000000
>  z               = 100.000000
>  q               = 1000.000000
>  stl_vector      = printing kStreamer case (500)
> Error: Can't call vector<int,__malloc_alloc_template<0> >::size() in
> current scope FILE:read_back.h LINE:142
> Possible candidates are...
> filename       line:size busy function type and name  (in
> vector<int,__malloc_alloc_template<0> >)
> Error: << Illegal operator for pointer 3 FILE:read_back.h LINE:142
> *** Interpreter error recovered ***
> 
> thanks for any help
> 
> Sean
> 
> +-------------------------------------------------------------------------+
> || Sean Kelly                    EMAIL:  kelly@nevis.columbia.edu        ||
> || Columbia University           WWW:    www.nevis.columbia.edu/~kelly   ||
> ||                               PHONE: (914) 591 - 2840 (NEVIS)         ||
> ||                               PHONE: (212) 854 - 5275 (CAMPUS)        ||
> ||                               PHONE: (646) 281 - 5282 (MOBILE)        ||
> ||                               FAX:   (212) 854 - 3379                 ||
> +-------------------------------------------------------------------------+
> 
>   --------------------------------------------------------------------------------
> 
>                              Name: test_root_io.tar.gz
>    test_root_io.tar.gz       Type: Unix Tape Archive (application/x-tar)
>                          Encoding: BASE64



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET