Drawing TBits object in a TTree

Hi,
I wanted to use the TBits facility given in the TTree documentation:

Below is the simple sample code. But, when I try to “draw” using T->Draw(“bits”), the code gives a seg. violation
I am using version 5.30/03 on ubuntu 32 bit. Am I missing something ?
Regards,
Samuel.
void test() {
TFile f(“test.root”,“recreate”);
TTree *T = new TTree(“T”,“test”);
TBits *bits = new TBits(32);
T->Branch(“bits”,“TBits”,&bits,32000,0);
for (Int_t i = 0; i < 25000; i++) {
if (i%1000 == 0) printf(“at entry: %d\n”,i);
bits->SetBitNumber(i%8);
T->Fill();
}
T->Print();
f.Write();
}

#12 0x00c20738 in TBits::GetNbits (this=0x31000000) at include/TBits.h:139
#13 0x0367ab9b in TSelectorDraw::ProcessFillObject (this=0xa62e800)
at /home/samuel/QtRoot02/root/tree/treeplayer/src/TSelectorDraw.cxx:1230
#14 0x0367a1ba in TSelectorDraw::ProcessFill (this=0xa62e800, entry=0)
at /home/samuel/QtRoot02/root/tree/treeplayer/src/TSelectorDraw.cxx:1103
#15 0x036b24e3 in TTreePlayer::Process (this=0xa62e780, selector=0xa62e800,
option=0x1833e38 “”, nentries=25000, firstentry=0)
at /home/samuel/QtRoot02/root/tree/treeplayer/src/TTreePlayer.cxx:2139
#16 0x036a9323 in TTreePlayer::DrawSelect (this=0xa62e780,
varexp0=0x9cb35b4 “bits”, selection=0x1833e38 “”, option=0x1833e38 “”,
nentries=1000000000, firstentry=0)
at /home/samuel/QtRoot02/root/tree/treeplayer/src/TTreePlayer.cxx:410
#17 0x017451a8 in TTree::Draw (this=0x99ac140, varexp=0x9cb35b4 “bits”,
selection=0x1833e38 “”, option=0x1833e38 “”, nentries=1000000000,
firstentry=0) at /home/samuel/QtRoot02/root/tree/tree/src/TTree.cxx:3836
#18 0x01723709 in TTree::Draw (this=0x99ac140, opt=0x9cb35b4 “bits”)
at include/TTree.h:341

Hi,

Thanks for reporting this problem. This is fixed in the trunk by revision 41686.

Cheers,
Philippe.

Hi,
Now I face a new problem with drawing TBits in a TTree. I made the skeleton class for my tree using MakeClass.
If I draw the TBits branch without calling the constructor of the skeleton class, it works fine. But, it crashes if the skeleton class constructor is called before drawing the TBits branch. The drawing of non-TBits branches do not show such a behavior. I use 5.32/00-rc1 in ubuntu. I am attaching the sample code along with the tree here. Compile with:
g++ -o test testClass.C test.C -I $ROOTSYS/include root-config --glibs
Am I missing something in my code or is this a bug?
Thanks,
Samuel.
Crash Output:

#10 0x0129ad2e in TBits::GetNbits (this=0x0) at include/TBits.h:139
#11 0x0275103b in TSelectorDraw::ProcessFillObject (this=0xa5d6500)
at /home/samuel/QtRoot04/root/tree/treeplayer/src/TSelectorDraw.cxx:1268
#12 0x0275051e in TSelectorDraw::ProcessFill (this=0xa5d6500, entry=0)
at /home/samuel/QtRoot04/root/tree/treeplayer/src/TSelectorDraw.cxx:1132
#13 0x02789267 in TTreePlayer::Process (this=0xa5b7c30, selector=0xa5d6500,
option=0x1c556c8 “”, nentries=8615, firstentry=0)
at /home/samuel/QtRoot04/root/tree/treeplayer/src/TTreePlayer.cxx:2172
#14 0x0277fbdf in TTreePlayer::DrawSelect (this=0xa5b7c30,
varexp0=0x804b74e “xstriphits_0”, selection=0x1c556c8 “”,
option=0x1c556c8 “”, nentries=1000000000, firstentry=0)
at /home/samuel/QtRoot04/root/tree/treeplayer/src/TTreePlayer.cxx:410
#15 0x01b60618 in TTree::Draw (this=0xa31e078,
varexp=0x804b74e “xstriphits_0”, selection=0x1c556c8 “”,
option=0x1c556c8 “”, nentries=1000000000, firstentry=0)
at /home/samuel/QtRoot04/root/tree/tree/src/TTree.cxx:3896
#16 0x01b3df05 in TTree::Draw (this=0xa31e078, opt=0x804b74e “xstriphits_0”)
at include/TTree.h:343
#17 0x0804b0f4 in main ()
root_test.tar.gz (1.43 MB)

Hi,

The SetMakeClass mode (aka the call to SetMakeClass(1)) explicitly does not support reading any objects (including TBits) out of the TTree. The purpose of SetMakeClass is to decompose the content of the TTree in its sub-components (ints, floats, etc).

Cheers,
Philippe.