TEventList segfault

Dear ROOT experts!

(ROOT 6.10.08)
I’m getting segfault error during the call to GetN() or GetEntry(i) of TEventList created via TTree::Draw.

Whereas TEventList::Print(“all”) works fine and shows correct information about entries.

The following trace appears (test script is attached)

Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
TH1.Print Name  = h1, Entries= 285, Total sum= 285

 *** Break *** segmentation violation
N =  Generating stack trace...
 0x00007eff5ee2909c in <unknown> from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff5ee2b8c9 in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 0x1d9 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff5ee2bb30 in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) + 0x140 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff5eec3d28 in cling::MetaProcessor::readInputFromFile(llvm::StringRef, cling::Value*, unsigned long, bool) + 0xdb8 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff5edafbe8 in <unknown> from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff5eda2b0d in <unknown> from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCling.so
 0x00007eff63eb19cc in TApplication::ExecuteFile(char const*, int*, bool) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/base/src/TApplication.cxx:1131 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff63eb379d in TApplication::ProcessLine(char const*, bool, int*) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/base/src/TApplication.cxx:982 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff64305662 in TRint::ProcessLineNr(char const*, char const*, int*) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/rint/src/TRint.cxx:757 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libRint.so
 0x00007eff64305a54 in TRint::HandleTermInput() at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/rint/src/TRint.cxx:608 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libRint.so
 0x00007eff63fd2e30 in TUnixSystem::CheckDescriptors() at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/unix/src/TUnixSystem.cxx:1321 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff63fd4678 in TUnixSystem::DispatchOneEvent(bool) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/unix/src/TUnixSystem.cxx:1077 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff63f17de4 in TSystem::InnerLoop() at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/base/src/TSystem.cxx:411 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff63f1690f in TSystem::Run() at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/base/src/TSystem.cxx:361 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff63eafb5f in TApplication::Run(bool) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/base/src/TApplication.cxx:1154 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libCore.so
 0x00007eff64306f3b in TRint::Run(bool) at /home/eugene/ROOT/root_v6.10.08/root-6.10.08.src/core/rint/src/TRint.cxx:458 from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/lib/libRint.so
 0x00005619473c4e0c in <unknown> from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/bin/root.exe
 0x00007eff62e46f6a in __libc_start_main + 0xea from /usr/lib/libc.so.6
 0x00005619473c4e6a in _start + 0x2a from /home/eugene/ROOT/root_v6.10.08/root-6.10.08.build/bin/root.exe

TEventListTest.C (341 Bytes)

Find input root file here

You cannot blindly cast a TH1F* into a TEventList*. That’s just undefined behavior. A histogram is not an event list!
To create a TEntryList, use Draw(">>el", your_cuts, "entrylist");

General advice: use type safe operations only.

What exactly do you want to do with DTEvent.fNumberOfTracks?
Try this:

{
    TString dataFile = "026690x000.DataTree.root";
    TFile ff(dataFile.Data());
    TTree* tree; ff.GetObject("DataTree", tree);
    if (tree == nullptr) { throw runtime_error("No such tree in the file"); }
    tree->Draw(">>el", "", "entrylist");
    auto evlist = dynamic_cast<TEntryList*>(gDirectory->Get("el"));
    if ( evlist != nullptr ) {
        evlist->Print();
        std::cout << "N = " << evlist->GetN() << std::endl;
    } else {
        std::cout << "that was not a TEntryList!\n";
    }
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.