Hi,
1 . I am having
Class MFocalBunch:public TObject {
Simple data members no pointers
ClassDef()
}
2. I have another
class MFocalImage:public TObject {
friend class MReflector ;
…
…
TClonesArray* ptrFocalBunch ; //-> TClonesArray pointer to hold array of MFocalBunch
ClassDef()
}
Above classes are declared in Header1.h and implemented in SRC1.cxx
3. I Have another
class MReflector: public TObject {
// Transient data members…
MFocalImage * focalimage ; //->
void BuildFocalImage() ; // Method that constructs one FocalImage i.e. reset and create ptrFocalBunch of focalimage
ClassDef()
}
This class is in Header2.h and SRC2.cxx
This code is compiled with generated dictionary file and then linked with main, where MReflector object is put on branch of TTree and written to it by building events in loop.
Code compiles and runs fine. root file is written and Tree saved to it. However when I try to read it, things hang
and i am unable to read it. (Sometimes it works. I think when file is opened first time it works. then onwards it doesn’t)
What is problem ?
Not to zero.
Default constructor of MFocalImage is
{
ptrPEBunch->new TClonesArray(“MFocalBunch”,1000) ;
}
There is another private constructor in MFocalImage, called by default constructor of MReflector. They are as follows.
MFocalImage::MFocalImage(Int_t tel, Int_t size)
{
itel = tel ;
ptrPEBunch -> new TClonesArray(“MFocalBunch”,size) ;
}
in MReflector default constructor is
{
focalimage->new MFocalImage(tel, size) ; // focalimage is data member of type MFocalImage*
}
in main() ,
MFocalImage is not created. (The idea is MFocalImage should not generally be created outside MReflector. It’s creation, management and destruction should be done by MReflector only. I can’t make MFocalImage abstract as eventually thats what I want to be written.) Only MReflector is instantiated and set to TTree branch. TTree is then written. MFocalImage *focalimage is only non-transient member of MReflector.
[quote]and i am unable to read it. (Sometimes it works. I think when file is opened first time it works. then onwards it doesn’t)
What is problem ?[/quote]It depends how you read it (with or without the original shared library, how do you set the addresses,etc …).
One good way to narrow the problem is probably to run you failing example in valgrind with the option --suppressions=$ROOTSYS/etc/valgrind-root.supp.
Hi,
Following sequence of lines on root terminal gives an error :
.L ../lib/libMSimIO.so
TFile f("Demo.root")
TTree* tree = (TTree*)f.Get("EvTree")
tree->Print()
Error is :
====>Rebuilding TStreamerInfo for class: MReflector, version: 1
/home/chinmay/ROOTv5.34/root/bin/root.exe: symbol lookup error: /home/chinmay/MaceSIM/bin/./…/lib/libMSimIO.so: undefined symbol: _ZN7TH2PolyC1Ev
[chinmay@localhost bin]$
On the other hand if I open the file in TBrowser things work fine. Also following code works fine:
.L ../lib/libMSimIO.so
TFile f("Demo.root")
TTree* tree = (TTree*)f.Get("EvTree")
tree -> Draw("focalimage.bunches")
tree -> Print()
Why it is happening. It seems there is some problem in loading libraries. But I can’t figure out where i