Adding class as *.so

ROOT 3.05/02 on RH7.2
Hello
I’m trying to add my classes (ALL inheriting from TObject) as shared library.
Everything compiles without problem and I load them before running script
with root[0].L libTApvMode.so …etc
I have one (TRecord) wich has another (TApvMode) as datamember.
If I try filling a tree with TApvMode all is fine but I get a segviol if I fill
the tree with TRecord object. I suspect about some streaming problem
but I can’t get out of it. Anyone can help me?
Thank you very much in advance
davide

*** Break *** segmentation violation
Generating stack trace…
0x401b88df in TUnixSystem::StackTrace(void) + 0x25b from /usr/local/ROOT/lib/root/libCore.so.3.05
0x401b74d6 in TUnixSystem::DispatchSignals(ESignals) + 0xb2 from /usr/local/ROOT/lib/root/libCore.so.3.05
0x401b66a3 in from /usr/local/ROOT/lib/root/libCore.so.3.05
0x401ba1a9 in from /usr/local/ROOT/lib/root/libCore.so.3.05
0x40c87a65 in from /lib/i686/libpthread.so.0
0x40d28958 in from /lib/i686/libc.so.6
0x40b290fb in TBranchElement::FillLeaves(TBuffer &) + 0x34b from /usr/local/ROOT/lib/root/libTree.so.3.05
0x40b2392c in TBranch::Fill(void) + 0x214 from /usr/local/ROOT/lib/root/libTree.so.3.05
0x40b28d3b in TBranchElement::Fill(void) + 0x117 from /usr/local/ROOT/lib/root/libTree.so.3.05

------------------- test.C --------------------------------
#include “TPedestal.h”
#include “TNoise.h”
#include “TApvMode.h”
#include “TRecord.h”

void test ()
{
TApvMode *myApvM;
TRecord *myRec;
TTree *tree = new TTree (“T”, “An example of a ROOT tree”);
// tree->Branch (“Record.”, “TRecord”, &myRec);
tree->Branch(“ApvMode.”,“TApvMode”,&myApvM);
for (int i = 0; i < 10; i++)
{
cout<<"Loop "<<i<<endl;
myApvM = new TApvMode();
myRec = new TRecord();
tree->Fill();
} //end loop on records

//tree->Draw(“ApvMode.aPed.pPedestal->Integral() / 512”);
cout<<endl;

}
try.tar (30 KB)

Hi,

It is important to pass initialized value to tree->Branch. Try replacing:

TApvMode *myApvM; TRecord *myRec; with

TApvMode *myApvM=0; TRecord *myRec=0;

Cheers,
Philippe

Hi
thanks for your reply; I tried to do this but it still doesn’t work.
Anyway vales passed to TTree are already initialized since I call
default constructors.

Take the tar file in teh download button.
I have modified some of your files.
Execute the “go” script to build the lib.
To run, do
root > gSystem->Load(“libA”);
root > .L test.C+
root > test()

you should see the following output:

Loop 0
Loop 1
Loop 2
Loop 3
Loop 4
Loop 5
Loop 6
Loop 7
Loop 8
Loop 9
TCanvas::MakeDefCanvas: created default TCanvas with name c1

Rene
try.tar.gz (3.11 KB)

Hello Rene
thank you very much for your reply.
I tried to do as you said; it compiles without any
problems but it gives the same error as before when
running:

[cms@tob10xl tryReply]$ ./go
[cms@tob10xl tryReply]$ root
.................................................
root [0] gSystem->Load("libA")
root [1]  .class TRecord 
....  TRecord is really loaded and known.....  
root [2] .L test.C+
root [3] test()
Loop 0

 *** Break *** segmentation violation
 Generating stack trace...
 0x401b88df in TUnixSystem::StackTrace(void) + 0x25b from /usr/local/ROOT/lib/root/libCore.so.3.05
 0x401b74d6 in TUnixSystem::DispatchSignals(ESignals) + 0xb2 from /usr/local/ROOT/lib/root/libCore.so.3.05
 0x401b66a3 in <unknown> from /usr/local/ROOT/lib/root/libCore.so.3.05
 0x401ba1a9 in <unknown> from /usr/local/ROOT/lib/root/libCore.so.3.05
 0x40c87a65 in <unknown> from /lib/i686/libpthread.so.0
 0x40d28958 in <unknown> from /lib/i686/libc.so.6
 0x40b290fb in TBranchElement::FillLeaves(TBuffer &) + 0x34b from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x40b2392c in TBranch::Fill(void) + 0x214 from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x40b28d3b in TBranchElement::Fill(void) + 0x117 from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x40b28d1d in TBranchElement::Fill(void) + 0xf9 from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x40b28d1d in TBranchElement::Fill(void) + 0xf9 from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x40b3d650 in TTree::Fill(void) + 0x80 from /usr/local/ROOT/lib/root/libTree.so.3.05
 0x4142251b in test(void) + 0x14b from /home/cms/gerbaudo/TPedestal/tryReply/./test_C.so
 0x414226f7 in <unknown> from /home/cms/gerbaudo/TPedestal/tryReply/./test_C.so
 0x4057fefd in G__call_cppfunc + 0x281 from /usr/local/ROOT/lib/root/libCint.so.3.05

Do you have any idea about where I’m wrong ?
Thanks,
davide

Did you run my test unmodified?

Rene

Hello Rene
Yes, I just set the include path

instead of

-I$ROOTSYS/include
in ‘go’ to get it compiling.
Anyway it works if I try putting TNoise and TPedestal
objects as data member of TRecord; I think the problem
could be in TApvMode streaming…
but actually I can fill a tree with TApvMode objects as ‘standalone’…
Thankyou very much, best regards
Davide

Hello Rene
I tried the code you sent on my home pc (RH9, ROOT 3.10/01) and everything is fine… probably
something is misconfigured on the other one.
Thank you very very much,
best regards
Davide