I was hoping someone might be able to answer a problem I’ve been having. I’m making some selections on a physics tree in my data, and copying out a subset of that tree to my output file. My problem is that I also want to copy the trigger configuration tree “physicsMeta/TrigConfTree” to the output file… this should be straightforward of course, the snippet of my code is
<once I attach m_TrigTChain to my input files.....>
TFile *copyFile = new TFile("SelectedEvents.root","Recreate");
TTree* newTree = m_TrigTChain->CloneTree();
copyFile->Write();
but this generates a segfault on the call to CloneTree.
I’m under the impression from your example(http://root.cern.ch/root/html/tutorials/tree/copytree.C.html) I need to call SetBranchAddress on the original tree, before calling CloneTree… I’m not clear what arguments I need to supply in this case. I tried using some dummy TObject I create there like so
but this also segfaults in the same way (stacktrace below). I also tried using CloneTree(-1,“fast”), but this causes a “double free or corruption” error as my program terminates (but appears to properly save what I want in my SelectEvents.root), I am guessing for similar reasons. All I want to do is copy that entire chain, m_TrigTChain into this new file SelectedEvents.root.
Sorry for the probably trivial question, and thanks for your help.
stacktrace:
There was a crash (#7 0xf4972ced in SigHandler(ESignals) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so).
This is the entire stack trace of all threads:
#0 0xffffe410 in __kernel_vsyscall () #1 0xf3d95cb3 in __waitpid_nocancel () from /lib/libc.so.6 #2 0xf3d3a62b in do_system () from /lib/libc.so.6 #3 0xf3e6bf3d in system () from /lib/libpthread.so.0 #4 0xf496d6ed in TUnixSystem::Exec(char const*) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so #5 0xf4973377 in TUnixSystem::StackTrace() () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so #6 0xf4972bdf in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so #7 0xf4972ced in SigHandler(ESignals) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so #8 0xf4969f12 in sighandler(int) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libCore.so #9 #10 0xf5cae6f0 in std::_Rb_tree<std::basic_string<char, std::char_traits, std::allocator >, std::pair<std::basic_string<char, std::char_traits, std::allocator > const, int>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, int> >, std::less<std::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, int> > >::_M_erase(std::_Rb_tree_node<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, int> >) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libMathMore.so #11 0xf59695dc in ROOT::TCollectionProxyInfo::Type<std::map<std::basic_string<char, std::char_traits, std::allocator >, int, std::less<std::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::basic_string<char, std::char_traits, std::allocator > const, int> > > >::clear(void) () from /afs/cern.ch/user/g/gcree/public/Analysis/H4lAnalysis/RootCore/lib/libTrigRootAnalysis.so #12 0xf59f6f65 in TGenCollectionProxy::Allocate(unsigned int, bool) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libRIO.so #13 0xf79e6d99 in TBranchElement::ReadLeavesCollection(TBuffer&) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #14 0xf79d7291 in TBranch::GetEntry(long long, int) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #15 0xf79dec40 in TBranchElement::GetEntry(long long, int) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #16 0xf7a32a3c in TTree::GetEntry(long long, int) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #17 0xf79fa5d2 in TChain::GetEntry(long long, int) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #18 0xf7a39701 in TTree::CopyEntries(TTree*, long long, char const*) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #19 0xf7a3c2f6 in TTree::CloneTree(long long, char const*) () from /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.3/GAUDI/v22r1p8-lcg61e/InstallArea/i686-slc5-gcc43-opt/lib/libTree.so #20 0xf58bd181 in HZZAnalysis::runCutFlow (this=AttributeError: ‘module’ object has no attribute ‘objfile_hook’ #21 0x0804dc25 in main (argc=1, argv=0xff80d214) at …/util/H4lAnalysis.cxx:52