[ROOT] STL, split trees and TTree::Draw() -- part 2
From: Walter F.J. Mueller (W.F.J.Mueller@gsi.de)
Date: Sun Apr 20 2003 - 18:24:44 MEST
Dear ROOTer's using 3.05/03
after STL vectors of elementary type I tried to use an STL vector
containing a class type. The example code is derived from the
EventSTL example attached again. A
root -q -l STLw.C
root -q -l STLr.C
works just fine when using split level 0 or 1. With a
mytree->Branch("abc","EventSTL",&CC,16000,2);
the STLw.C gives the informal message
will split this STL vector: hits of Hit
and produces a tree as one might expect (meaning that the
output of T->Print() looks reasonable). However reading the
split tree gives improper results, one gets
Size=0; nhit=3; hit[]=
Size=0; nhit=4; hit[]=
Size=0; nhit=0; hit[]=
Size=0; nhit=1; hit[]=
rather than the expected
Size=3; nhit=3; hit[]=(18,0,18)(18,1,19)(18,2,20)
Size=4; nhit=4; hit[]=(19,0,19)(19,1,20)(19,2,21)(19,3,22)
Size=0; nhit=0; hit[]=
Size=1; nhit=1; hit[]=(21,0,21)
which indicates that the vector isn't actually stored at all.
Using TTree::Draw() on such a split level 2 tree
file = new TFile("STL.root");
T->Draw("nhit");
T->Draw("hits.px");
gives the correct histogram for 'nhit' but a histogram with 40
entries at 0 for 'hits.px'.
Even more confusing is that a session
gSystem->Load("EventSTL");
file = new TFile("STL.root");
T->Draw("nhit");
T->Draw("hits.px");
gives a (wrong) result as above, but that a session
gSystem->Load("EventSTL");
file = new TFile("STL.root");
T->Draw("hits.px");
simply crashes ROOT, giving the attached traceback.
So I wonder whether split trees with STL vectors are supported
or whether I'm making a trivial mistake somewhere.
Cheers and happy Easter,
Walter
- text/x-csrc attachment: STLw.C
- text/x-csrc attachment: STLr.C
/home/walter/c/tests/root/tree_stl/exam03 $ root
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 3.05/03 29 March 2003 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for linuxdeb with thread support.
CINT/ROOT C/C++ Interpreter version 5.15.78, Mar 3 2003
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] gSystem->Load("EventSTL");
root [1] file = new TFile("STL.root");
root [2] T->Draw("hits.px");
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
*** Break *** segmentation violation
Generating stack trace...
0x401d50a5 in TUnixSystem::StackTrace(void) + 0x2a1 from /home/fsware/root-3.05.03/lib/libCore.so
0x401d3a7f in TUnixSystem::DispatchSignals(ESignals) + 0xbf from /home/fsware/root-3.05.03/lib/libCore.so
0x401d2c0b in <unknown> from /home/fsware/root-3.05.03/lib/libCore.so
0x401d6927 in <unknown> from /home/fsware/root-3.05.03/lib/libCore.so
0x40decf54 in <unknown> from /lib/libpthread.so.0
0x40e8b6b8 in <unknown> from /lib/libc.so.6
0x40c61f0e in TBranchElement::GetValue(int, int, bool) const + 0x172 from /home/fsware/root-3.05.03/lib/libTree.so
0x40c6fa72 in TLeafElement::GetValue(int) const + 0x2a from /home/fsware/root-3.05.03/lib/libTree.so
0x416354dc in TTreeFormula::EvalInstance(int) + 0x37c from /home/fsware/root-3.05.03/lib/libTreePlayer.so
0x4162760e in TSelectorDraw::ProcessFill(int) + 0xf6 from /home/fsware/root-3.05.03/lib/libTreePlayer.so
0x41644209 in TTreePlayer::Process(TSelector *, char const *, int, int) + 0x25d from /home/fsware/root-3.05.03/lib/libTreePlayer.so
0x4163e4ef in TTreePlayer::DrawSelect(char const *, char const *, char const *, int, int) + 0x12f from /home/fsware/root-3.05.03/lib/libTreePlayer.so
0x40c78f94 in TTree::Draw(char const *, char const *, char const *, int, int) + 0x58 from /home/fsware/root-3.05.03/lib/libTree.so
0x40c7e44f in TTree::Draw(char const *) + 0x37 from /home/fsware/root-3.05.03/lib/libTree.so
0x40c92dc6 in <unknown> from /home/fsware/root-3.05.03/lib/libTree.so
0x40634b9b in G__call_cppfunc + 0x287 from /home/fsware/root-3.05.03/lib/libCint.so
0x4062411b in G__interpret_func + 0x7df from /home/fsware/root-3.05.03/lib/libCint.so
0x4060add9 in G__getfunction + 0x1481 from /home/fsware/root-3.05.03/lib/libCint.so
0x40696cb6 in G__getstructmem + 0x7ca from /home/fsware/root-3.05.03/lib/libCint.so
0x4068ff90 in G__getvariable + 0x658 from /home/fsware/root-3.05.03/lib/libCint.so
0x40602c9d in G__getitem + 0x4ed from /home/fsware/root-3.05.03/lib/libCint.so
0x40602e62 in G__getitem + 0x6b2 from /home/fsware/root-3.05.03/lib/libCint.so
0x40601583 in G__getexpr + 0x8c27 from /home/fsware/root-3.05.03/lib/libCint.so
0x4064be38 in G__exec_function + 0x13c from /home/fsware/root-3.05.03/lib/libCint.so
0x40652f42 in G__exec_statement + 0x2b92 from /home/fsware/root-3.05.03/lib/libCint.so
0x405e8ca6 in G__exec_tempfile_core + 0x2a2 from /home/fsware/root-3.05.03/lib/libCint.so
0x405e8e4d in G__exec_tempfile_fp + 0x25 from /home/fsware/root-3.05.03/lib/libCint.so
0x4065b807 in G__process_cmd + 0x4f13 from /home/fsware/root-3.05.03/lib/libCint.so
0x4018742e in TCint::ProcessLine(char const *, TInterpreter::EErrorCode *) + 0x9e from /home/fsware/root-3.05.03/lib/libCore.so
0x40107ca0 in TApplication::ProcessLine(char const *, bool, int *) + 0x5a4 from /home/fsware/root-3.05.03/lib/libCore.so
0x40db8269 in TRint::HandleTermInput(void) + 0x139 from /home/fsware/root-3.05.03/lib/libRint.so
0x40db73d6 in TTermInputHandler::Notify(void) + 0x2a from /home/fsware/root-3.05.03/lib/libRint.so
0x40db8895 in TTermInputHandler::ReadNotify(void) + 0x25 from /home/fsware/root-3.05.03/lib/libRint.so
0x401d3e4e in TUnixSystem::CheckDescriptors(void) + 0xfa from /home/fsware/root-3.05.03/lib/libCore.so
0x401d3593 in TUnixSystem::DispatchOneEvent(bool) + 0x10b from /home/fsware/root-3.05.03/lib/libCore.so
0x40158986 in TSystem::InnerLoop(void) + 0x32 from /home/fsware/root-3.05.03/lib/libCore.so
0x401588fd in TSystem::Run(void) + 0x75 from /home/fsware/root-3.05.03/lib/libCore.so
0x401086a3 in TApplication::Run(bool) + 0x33 from /home/fsware/root-3.05.03/lib/libCore.so
0x40db7d2b in TRint::Run(bool) + 0x2eb from /home/fsware/root-3.05.03/lib/libRint.so
0x080487d7 in main + 0x87 from /home/fsware/root-3.05.03/bin/root.exe
0x40e7b14f in __libc_start_main + 0xbb from /lib/libc.so.6
0x08048691 in __register_frame_info + 0x39 from /home/fsware/root-3.05.03/bin/root.exe
Root >
This archive was generated by hypermail 2b29
: Thu Jan 01 2004 - 17:50:11 MET