Hi
I have recently switched code to SL5 and find that my tree manipulations stopped working and ended in a crash. I have reduced this to a simple(ish) example that demonstrates what I used to do but fails. However, the situation is very odd. If I write the tree on SL4 and read it on SL5 with v5_22 of root, this works. If I write the tree with the same code built on SL5 and try to read it on SL5 with v5_22 of root, this fails.
#include “TFile.h”
#include "TTree.h"
void test(std::string filename){
TFile _file0=new TFile(filename.c_str());
TFile f = new TFile(“testfile.root”,“recreate”);
TTree mytree=(TTree)_file0->Get(“NNInput”);
TTree* scopy=0;
scopy=mytree->CopyTree(“Target==1”);
TTree* bcopy=0;
bcopy=mytree->CopyTree(“Target==0”);
}
bash-3.2$ root
root [0] .L test.C+
Info in TUnixSystem::ACLiC: creating shared library /home/stdenis/aaasl5/./test_C.so
/home/stdenis/aaasl5/./test.C: In function ‘void test(std::string)’:
/home/stdenis/aaasl5/./test.C:5: warning: unused variable 'f’
root [1] test(“OldSL4.root”);
root [2] test(“NewSL5.root”);
*** Break *** segmentation violation
Attaching to program: /proc/1283/exe, process 1283
[Thread debugging using libthread_db enabled]
0xffffe405 in __kernel_vsyscall ()
#1 0x0047a5b3 in __waitpid_nocancel () from /lib/libc.so.6
#2 0x0041f07b in do_system () from /lib/libc.so.6
#3 0x0056dead in system () from /lib/libpthread.so.0
#4 0xf7a2621d in TUnixSystem::Exec(char const*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#5 0xf7a2ca75 in TUnixSystem::StackTrace() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#6 0xf7a28d59 in TUnixSystem::DispatchSignals(ESignals) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#7 0xf7a28e03 in SigHandler(ESignals) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#8 0xf7a27f1e in sighandler(int) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#9
#10 0xf631f016 in TBranch::Streamer(TBuffer&) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libTree.so
#11 0xf79e0061 in TClass::Streamer(void*, TBuffer&, TClass const*) const ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#12 0xf69967d6 in TBufferFile::ReadObjectAny(TClass const*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRIO.so
#13 0xf79cf407 in TObjArray::Streamer(TBuffer&) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#14 0xf6a57ee7 in int TStreamerInfo::ReadBuffer<char**>(TBuffer&, char** const&, int, int, int, int) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRIO.so
#15 0xf6998ac8 in TBufferFile::ReadClassBuffer(TClass const*, void*, int, unsigned int, unsigned int, TClass const*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRIO.so
#16 0xf6379d6a in TTree::Streamer(TBuffer&) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libTree.so
#17 0xf699ec7d in TDirectoryFile::CloneObject(TObject const*, bool) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRIO.so
#18 0xf795be6b in TObject::Clone(char const*) const ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#19 0xf795b04c in TNamed::Clone(char const*) const ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#20 0xf637267e in TTree::CloneTree(long long, char const*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libTree.so
#21 0xf53b2aa7 in TTreePlayer::CopyTree(char const*, char const*, long long, long long) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libTreePlayer.so
#22 0xf63762a3 in TTree::CopyTree(char const*, char const*, long long, long long) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libTree.so
#23 0xf6c36b84 in test(std::basic_string<char, std::char_traits, std::allocator >) () from /home/stdenis/aaasl5/./test_C.so
#24 0xf6c36c3e in G__test_C_ACLiC_dict__0_1557(G__value*, char const*, G__param*, int) () from /home/stdenis/aaasl5/./test_C.so
#25 0xf7048ab6 in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#26 0xf7100fdf in G__execute_call ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#27 0xf7101334 in G__call_cppfunc ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#28 0xf70df09b in G__interpret_func ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#29 0xf70cbdf6 in G__getfunction ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#30 0xf709dac7 in G__getitem ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#31 0xf70a2940 in G__getexpr ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#32 0xf713bdee in G__exec_statement ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#33 0xf7088434 in G__exec_tempfile_core ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#34 0xf7089ab6 in G__exec_tempfile_fp ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#35 0xf71455ca in G__process_cmd ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCint.so
#36 0xf7a0eb15 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#37 0xf79313fb in TApplication::ProcessLine(char const*, bool, int*) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#38 0xf6cb89ac in TRint::HandleTermInput() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRint.so
#39 0xf6cb6ba5 in TTermInputHandler::Notify() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRint.so
#40 0xf6cb9454 in TTermInputHandler::ReadNotify() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRint.so
#41 0xf7a248b9 in TUnixSystem::CheckDescriptors() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#42 0xf7a294b4 in TUnixSystem::DispatchOneEvent(bool) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#43 0xf799359e in TSystem::InnerLoop() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#44 0xf79933a9 in TSystem::Run() ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#45 0xf7931577 in TApplication::Run(bool) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libCore.so
#46 0xf6cb7549 in TRint::Run(bool) ()
from /home/cdfsoft/products/root/v5_22_00-GCC_3_4_3/Linux+2.6/lib/libRint.so
#47 0x08048de1 in main ()
A debugging session is active.
Inferior 1 [process 1283] will be detached.
Quit anyway? (y or n) [answered Y; input not from terminal]
Detaching from program: /proc/1283/exe, process 1283
Root >
I have tried a number of things such as setting directories before doing the copy, and also doing a TreeClone or a Clone first and the a copy with care taken with directories. None of this works.
So back to the fundamental question which is given a Tree, how can I manipulate it to extract portions
where I really dont want to know any details of the branches and leaves other than a few needed to do the selections?
Thanks
Rick