[ROOT] Re: root trees

From: j.rademacker1@physics.ox.ac.uk
Date: Thu Nov 11 2004 - 20:58:28 MET


I have more problems with root trees. I want to save templated class. I
wrote a little test program that works fine with a normal class, but
when I add a template I get the following error message:
Processing doTestio.C...
Info in <TUnixSystem::ACLiC>: creating shared library
dlopen error:
efined symbol: _ZN8testTempIiE11ShowMembersER16TMemberInspectorPc
Load Error: Failed to load Dynamic link library
g++: stdfunc.dll: No such file or directory
*** Interpreter error recovered ***
Error: Function testio() is not defined in current scope
FILE:doTestio.C LINE:9
Possible candidates are...
filename       line:size busy function type and name
*** Interpreter error recovered ***

This is the program that caused the error message:
#include "TObject.h"
#include "TFile.h"
#include "../UHTFitter/UHTPolyWithBool.h"

#include <iostream>
using namespace std;

template<class T> class testTemp : public TObject{
  T p;
  ClassDef(testTemp, 1)

void testio(){
  testTemp<int> tc;
  cout << "p before" << tc.p << endl;

  TFile fout("test.root", "RECREATE");
  fout.WriteObject(&tc, "tfitter", "");

  TFile fin("test.root");
  testTemp<int>* tc2Ptr;
  fin.GetObject("tfitter", tc2Ptr);
  cout << "p after " << tc2Ptr->p << endl;

I have no idea how to solve this - any help would be much appreciated.

Thanks a lot!


On Thu, 11 Nov 2004 j.rademacker1@physics.ox.ac.uk wrote:

> Hi
> I'm trying to write an object I have to a root file, from within root. I
> compile my code with the + option and then run it in batch mode.
> In my class header, I have the ClassDef macro, and in my .C file the
> correspondig ClassImp macro. I have that for all classes involved, and
> the class I want to save inherits from TObject (other classes that are
> members of this one don't inherit from TObject, but I guess that doesn't
> matter?). Everything compiles fine. My program even produces a non-empty
> output file. But when I want to read it back in, I get the following
> run-time error:
> ==========================================================
> Warning in <TStreamerInfo::BuildOld>: Cannot convert
> UHTDecay::stableParts from type:vector<
> UHTTrack> to type:UHTTrkListType, skip element
> ==========================================================
> Now UHTTrkListType is just a typedef for std::vector<UHTTrack>. So there
> is no conversion to be done. What am I doing wrong? Can I use typedefs
> at all? And vectors? If so, how do I get root to know about them?
> Thanks a lot!
> Jonas
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>  Jonas Rademacker, Denys Wilkinson Bldg, Keble Road, Oxford OX1 3RH, UK
>          Tel: +44-1865-273410     Fax: +44-1865-273418

 Jonas Rademacker, Denys Wilkinson Bldg, Keble Road, Oxford OX1 3RH, UK
         Tel: +44-1865-273410     Fax: +44-1865-273418

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