Hi Daniela,
I have assumed that you use 3.04/02 or newer. Please always indicate
which version of ROOT you use.
In case you use an older version, add the line
fChain->LoadTree(0);
before
TTree *newTree = (TTree*)fChain->GetTree()->CloneTree(0);
Rene Brun
Daniela Kaefer wrote:
>
> Hi Rene,
>
> well, I did it exactly as you wrote in your email, but... it didn't work.
> It compiles, but then it crashes with:
>
> [...]
> Initializing wtreeTopData...
> Program running on host aragorn-clued0
> booking stuff
> ...wtreeTopData initialized successfully
> Starting event loop...
>
> *** Break *** segmentation violation
> Abort
>
> before it even reaches the first event. I started it in gdb and got the
> following "error"-message:
>
> [kaefer@aragorn-clued0] ~/analysis/p13.06.01/diem/wtree > gdb runTopData
> GNU gdb 5.0 [...]
> (gdb) run /work/aragorn-clued0/kaefer/top_analyze/diemroot/
> Starting program: /home/kaefer/analysis/p13.06.01/diem/wtree/runTopData
> /work/aragorn-clued0/kaefer/top_analyze/diemroot/
> [New Thread 1024 (LWP 21346)]
> Reading file names from directory
> /work/aragorn-clued0/kaefer/top_analyze/diemroot/
> Adding files to TChain
> FILE: /work/aragorn-clued0/kaefer/top_analyze/diemroot//out_partab.root
> added to TChain
> FILE: /work/aragorn-clued0/kaefer/top_analyze/diemroot//out_partac.root
> added to TChain
> FILE: /work/aragorn-clued0/kaefer/top_analyze/diemroot//out_partad.root
> added to TChain
> FILE: /work/aragorn-clued0/kaefer/top_analyze/diemroot//out_partae.root
> added to TChain
> FILE: /work/aragorn-clued0/kaefer/top_analyze/diemroot//out_partaf.root
> added to TChain
> [...]
> Initializing wtreeTopData...
> Program running on host aragorn-clued0
> booking stuff
> ...wtreeTopData initialized successfully
> Starting event loop...
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1024 (LWP 21346)]
> 0x804f2c8 in wtreeTopData::Loop (this=0x8621e48) at wtreeTopData.C:111
> 111 TTree *newTree = (TTree*)fChain->GetTree()->CloneTree(0);
> (gdb)
>
> It seems as if it cannot find the original tree in the fChain, but there
> is one, it's called TopTree and it looks like in the Header-file I send in
> the previous email... Please, if you have any idea on what could possibly
> be wrong, let me know. Thanks a lot for your help, at least it finally
> compiles!
>
> Best,
> Daniela
>
> +-----------------------------------------------------------+
> | Daniela Kaefer | email: kaefer@physik.rwth-aachen.de |
> | Fermilab, MS 357 | kaefer@fnal.gov \_L_/ |
> | Batavia, IL 60510 | /* *\/ |
> | | \_*_/\ |
> | U.S.A. | phone: +1-630-840-5439 / | \ |
> +-----------------------------------------------------------+
>
> ======================================================================
> On Fri, 21 Feb 2003, Rene Brun wrote:
>
> > Hi Daniela,
> >
> > In your Loop function, you should not call BranchOld. CloneTree will
> > recreate an identical Tree header.
> > Below, you will find an example of Loop code to copy a subset of
> > a Tree (TChain) to a new Tree.
> >
> > Rene Brun
> >
> >
> > TFile f("newTree.root","recreate");
> > TTree *newTree = fChain->GetTree()->CloneTree(0);
> >
> > Int_t nentries = Int_t(fChain->GetEntriesFast());
> > for (Int_t jentry=0; jentry<nentries;jentry++) {
> > Int_t ientry = LoadTree(jentry);
> > if (ientry < 0) break;
> > fChain->GetEntry(jentry);
> > // if event is rejected continue
> > newTree->Fill();
> > }
> > newTree->AutoSave();
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET