Hi Chris, I have no problem in running your simple test with TSelector in batch or interactive mode. I just tried the following simple main program: #include "TTree.h" #include "TFile.h" #include "testSel.h" int main() { TFile *f= new TFile("test.root"); TTree *t= (TTree*)f->Get("test"); testSel selector; t->Process(&selector); return 0; } Note that since 3.0, you do not need to call the TROOT constructor anymore. This is done automatically. I would need your complete program to understand what is happening. Instead a creating your own main program, it is better to use the standard Root main program and dynamically link your libs or use ACLIC. For example , you can do interactively root [0] TFile *f= new TFile("test.root"); root [1] TTree *t= (TTree*)f->Get("test"); root [2] t.Process("testSel.C++") p=3.200000 p=2.100000 p=2.400000 Rene Brun Chris Roat wrote: > > Hi Rene, > > I didn't have a problem in interactive usage either. My problem came > when I tried to use the code in a stand-alone application. > > I was able to get around the problem by just using SetBranchStatus in the > Notify() method. In this way, I only loaded in the Branches I needed. > This saved time, as there are a lot of branches in my scaled-up > application. Further time savings would result if I didn't read some > branches unless the cut was passed, but I am content. > > Chris > > *** Today, you (Rene Brun) wrote *** > > >Hi Chris, > > > >I do not see a problem with this basic example. Using your generator > >example, I created the two files testSel.h and testSel.C (in attachment). > >I modified testSel.C in ProcessCut, adding the two statements: > > b_p->GetEntry(entry); > > printf("p=%f\n",p); > > > >then, from an interactive ROOT session, I did > > > >root [0] TFile *f= new TFile("test.root"); > >root [1] TTree *t= (TTree*)f->Get("test"); > >root [2] .L testSel.C++ > >root [3] testSel selector; > >root [4] t->Process(&selector); > > > >This gives: > > > >p=3.200000 > >p=2.100000 > >p=2.400000 > > > > > >Rene Brun > > > >Chris Roat wrote: > >> > >> 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