[ROOT] Problem w/ TTree::MakeSelector code used stand-alone

From: Chris Roat (croat@SLAC.stanford.edu)
Date: Thu Oct 18 2001 - 00:13:02 MEST


Hi ROOTers,

I am having a problem using the code generated by TTree::MakeSelector in a
standalone application.  Below I show how I create a very basic tree with
one branch, "p", that is filled with three entries.  I then run
MakeSelector to generate an analysis skeleton.  I add ClassDef(test,1) and
ClassImp(testSel) macros to the resulting skeleton files.

Making an appropriate LinkDef file, I compile and run the simple main
program, also shown below.  It runs fine, but at this point the skeleton
is still empty - a sterile application.  I add the following simple line
to testSel::ProcessCut(),

b_p->GetEntry(entry);

which is, I think, supposed to fill the branch with the entry - based on
my experience on the command line.  The code compiles without hassle, but
then I get a seg fault when the new line runs.  The traceback is shown
below.

I am running on a linux box with g++-2.95.2, ROOT version 3.01/06.

Can someone point me to what I am doing wrong?  Thanks much,
Chris



// create a basic tree

hfile = new TFile("test.root","RECREATE");
tree = new TTree("test","A Tree");
Float_t p;
b = tree->Branch("p", &p, "p/F" );
p= 3.2; tree->Fill();
p= 2.1; tree->Fill();
p= 2.4; tree->Fill();
hfile->Write();
tree->MakeSelector("testSel")


// main program

#include <TTree.h>
#include <TFile.h>
#include "testSel.h"

int main() {

  TROOT myroot("myroot","Required TROOT object");
  TFile *f= new TFile("test.root");
  TTree *t= (TTree*)f->Get("test");
  testSel selector;
  t->Process(&selector);
  return 0;

}


// traceback

(gdb) where
#0  0x400d8204 in TBuffer::ReadFastArray () from
/afs/slac.stanford.edu/g/babar/package/root/3.01-06/Linux2/lib/libCore.so
#1  0x40a6d3b6 in TLeafF::ReadBasketExport () from
/afs/slac.stanford.edu/g/babar/package/root/3.01-06/Linux2/lib/libTree.so
#2  0x40a5c397 in TBranch::GetEntryExport () from
/afs/slac.stanford.edu/g/babar/package/root/3.01-06/Linux2/lib/libTree.so
#3  0x804b5e3 in testSel::ProcessCut (this=0xbfffeec0, entry=0) at
testSel.C:49
#4  0x40dafd4d in TTreePlayer::Process () from
/afs/slac.stanford.edu/g/babar/package/root/3.01-06/Linux2/lib/libTreePlayer.so
#5  0x40a766ab in TTree::Process () from
/afs/slac.stanford.edu/g/babar/package/root/3.01-06/Linux2/lib/libTree.so
#6  0x804b33f in main () at pid.C:11



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:03 MET