Re: Problem reading class tree branch

From: James Jackson <james.jackson_at_cern.ch>
Date: Fri, 29 Aug 2008 12:11:04 +0100


Hi Rene,

Aha works a treat now. Thank you!

Regards,
James.

On 29 Aug 2008, at 11:17, Rene Brun wrote:

> Hi James,
>
> In test.c comment the two includes
> //#include "JJEvent.h"
> //#include "Process.h"
>
> because of alignment problems between the interpreted class and the
> compiled class you get crap.
>
> Rene Brun
>
> James Jackson wrote:
>> Hi,
>>
>> Following on from previous problems with "a/D:b/I:c/D" branch
>> ordering, I have re-written my code to store a C++ class. I again
>> have the same problem: I can read the data just fine in a TBrowser
>> (including plotting the result of class member functions, namely
>> one which calls TClonesArray::GetLast() ), however when I try and
>> read the data in a script I just get jargon.
>>
>> Compile libraries / dictionaries:
>>
>> james-jacksons-macbook-pro:RootLibs jamesjackson$ root -l
>> root [0] .L Process.cc+
>> Info in <TUnixSystem::ACLiC>: creating shared library /Users/
>> jamesjackson/Documents/Development/TracklessQuickTest/RootLibs/./
>> Process_cc.so
>> root [1] .L JJSuperCluster.cc+
>> Info in <TUnixSystem::ACLiC>: creating shared library /Users/
>> jamesjackson/Documents/Development/TracklessQuickTest/RootLibs/./
>> JJSuperCluster_cc.so
>> root [2] .L JJEvent.cc+
>> Info in <TUnixSystem::ACLiC>: creating shared library /Users/
>> jamesjackson/Documents/Development/TracklessQuickTest/RootLibs/./
>> JJEvent_cc.so
>> /Users/jamesjackson/Documents/Development/TracklessQuickTest/
>> RootLibs/./JJEvent.cc:42: warning: unused parameter ‘sc’
>> /Users/jamesjackson/Documents/Development/TracklessQuickTest/
>> RootLibs/./JJEvent.cc:42: warning: unused parameter ‘cutResults’
>>
>> Attempt to read data:
>>
>> <code>
>> #include "JJEvent.h"
>> #include "Process.h"
>>
>> #include <iostream>
>>
>> void test()
>> {
>> // Load data libraries
>> gSystem->Load("Process_cc.so");
>> gSystem->Load("JJSuperCluster_cc.so");
>> gSystem->Load("JJEvent_cc.so");
>>
>> // Open file and get trees
>> TFile f("clusterHistos.root");
>> TDirectory *d = (TDirectory*)f.Get("diEmAnalysis");
>> TTree *eventTree = (TTree*)d->Get("Events");
>> TTree *processTree = (TTree*)d->Get("Process");
>>
>> // Attach data members
>> JJEvent *event = 0;
>> Process *process = 0;
>> eventTree->SetBranchAddress("Events", &event);
>> processTree->SetBranchAddress("Process", &process);
>>
>> // Read event tree
>> UInt_t numEvents = eventTree->GetEntries();
>> for(UInt_t i = 0; i < numEvents; ++i)
>> {
>> // Get current event
>> eventTree->GetEntry(i);
>>
>> // Print the number of superclusters
>> std::cout << event->EventNumber << std::endl;
>> std::cout << " " << event->GetNumberOfSuperClusters() <<
>> std::endl;
>> }
>> }
>> </code>
>>
>> This just spits out garbage:
>>
>> <output>
>> 0
>> 44717842
>> 1
>> 44717842
>> 2
>> 44717842
>> 0
>> 44717842
>> 3
>> 44717842
>> </output>
>>
>> where clearly the event number should be monotonically increasing
>> (confirmed by plotting from TBrowser), and the count is clearly
>> wrong.
>>
>> I would appreciate any advice on how to solve this, I am (still)
>> very confused. An example root file, the class definitions and the
>> above test script are available from:
>>
>> /afs/cern.ch/user/j/jacksonj/public/RootTest-29082008.tgz
>>
>> Running this code on a different machine results in a segmentation
>> violation and a stack trace:
>>
>> *** Break *** segmentation violation
>> (no debugging symbols found)
>> Using host libthread_db library "/lib/tls/libthread_db.so.1".
>> Attaching to program: /proc/3939/exe, process 3939
>> (no debugging symbols found)...done.
>> (no debugging symbols found)...done.
>> [Thread debugging using libthread_db enabled]
>> [New Thread -1208297792 (LWP 3939)]
>> 0x009d07a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
>> #1 0x0690eff3 in __waitpid_nocancel () from /lib/tls/libc.so.6
>> #2 0x068b9469 in do_system () from /lib/tls/libc.so.6
>> #3 0x04e3884d in system () from /lib/tls/libpthread.so.0
>> #4 0x003d2df5 in TUnixSystem::Exec () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
>> #5 0x003d32b9 in TUnixSystem::StackTrace ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCore.so
>> #6 0x003d1064 in TUnixSystem::DispatchSignals ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCore.so
>> #7 0x003cee64 in SigHandler () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
>> #8 0x003d5c6c in sighandler () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
>> #9 <signal handler called>
>> #10 0x07d5b2a1 in TBranchElement::ReadLeaves ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libTree.so
>> #11 0x07d4b414 in TBranch::GetEntry () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
>> #12 0x07d58042 in TBranchElement::GetEntry ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libTree.so
>> #13 0x07d580aa in TBranchElement::GetEntry ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libTree.so
>> #14 0x07d8fd2b in TTree::GetEntry () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
>> #15 0x07db7442 in G__G__Tree_131_0_62 () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libTree.so
>> #16 0x00a2d051 in Cint::G__ExceptionWrapper ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCint.so
>> #17 0x00b0efb4 in G__call_cppfunc () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #18 0x00afa87a in G__interpret_func () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #19 0x00ade1e2 in G__getfunction () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #20 0x00b90803 in G__getstructmem () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #21 0x00b869e1 in G__getvariable () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #22 0x00ad02f9 in G__getitem () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #23 0x00acdc49 in G__getexpr () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #24 0x00b2d326 in G__exec_function () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #25 0x00b37fd5 in G__exec_statement () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #26 0x00b324f5 in G__exec_loop () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #27 0x00b32eee in G__exec_for () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #28 0x00b37c0c in G__exec_statement () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #29 0x00afc6ae in G__interpret_func () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #30 0x00adeb7c in G__getfunction () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #31 0x00ad041c in G__getitem () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #32 0x00acdc49 in G__getexpr () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #33 0x00abeaa1 in G__calc_internal () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #34 0x00b3f08f in G__process_cmd () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCint.so
>> #35 0x00324de3 in TCint::ProcessLine () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libCore.so
>> #36 0x00324f7d in TCint::ProcessLineSynch ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCore.so
>> #37 0x00246fff in TApplication::ProcessFile ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCore.so
>> #38 0x00246824 in TApplication::ProcessLine ()
>> from /raid/expt-sw/SL4/cms/slc4_ia32_gcc345/lcg/root/5.14.00f-
>> CMS3q//lib/libCore.so
>> #39 0x04067812 in TRint::Run () from /raid/expt-sw/SL4/cms/
>> slc4_ia32_gcc345/lcg/root/5.14.00f-CMS3q//lib/libRint.so
>> #40 0x08048d81 in main ()
>> Root > Function test() busy flag cleared
>>
>> Regards,
>> James.
>
Received on Fri Aug 29 2008 - 13:11:10 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 29 2008 - 17:50:01 CEST