I have a macro for extracting data from TTrees in two different root files (outputs from GENIE).
I have two different machines I want to run this on, one uses root 5.34 and one with root 6.12. It runs fine on root 5.34 but seg faults on 6.12.
//opens a genie summary tree file and a corresponding rew
//file and generates histograms
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
void Extract_Rew(){
TFile *f1 = TFile::Open("outputreal.root");
TFile *f2 = TFile::Open("outputrew.root");
if ((!f1) || f1->IsZombie()) { delete f1; return; } // just a precaution
TTree *t1;
f1->GetObject("gst", t1);
if (!t1) { delete f1; return; } // just a precaution
t1->SetMakeClass(1); // tree in MakeClass mode
t1->SetBranchStatus("*", 0); // disable all branches
if ((!f2) || f2->IsZombie()) { delete f2; return; } // just a precaution
TTree *t2;
//label needs to match rew param
f2->GetObject("MaCCQE", t2);
if (!t2) { delete f2; return; } // just a precaution
t2->SetMakeClass(1); // tree in MakeClass mode
t2->SetBranchStatus("*", 0); // disable all branches
/////////////////////////////////////
// Open the branches in the files ///
////////////////////////////////////
double Q2;
double weight0;
TArrayF* weight1;
t1->SetBranchStatus("Q2",1);
t1->SetBranchAddress("Q2",&Q2);
t1->SetBranchStatus("wght",1);
t1->SetBranchAddress("wght",&weight0);
t2->SetBranchStatus("weights",1);
t2->SetBranchAddress("weights",&weight1);
Long64_t n1 = t1->GetEntries();
Long64_t n2 = t2->GetEntries();
//std::cout << n1 << " " << n2 << std::endl;
for (Long64_t i = 0; i < n1; i++) {
t1->GetEntry(i);
t2->GetEntry(i);
std::cout << weight1->At(0) << std::endl;
}
// t->ResetBranchAddresses(); // disconnect from local variables
delete f1; // automatically deletes "t", too
delete f2;
}
I have attached the two root files that I’m trying to open.
outputreal.root (218.7 KB) outputrew.root (17.8 KB)
Here is the seg fault information:
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f715d0d8bbc in waitpid () from /lib64/libc.so.6
#1 0x00007f715d056ea2 in do_system () from /lib64/libc.so.6
#2 0x00007f715dc4d1a4 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.16
#3 0x00007f715dc4efec in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.16
#4 <signal handler called>
#5 0x0000000000000000 in ?? ()
#6 0x00007f715db9fa9c in TArrayF::Streamer(TBuffer&) () from /usr/lib64/root/libCore.so.6.16
#7 0x00007f715029c749 in TBranchElement::ReadLeavesMakeClass(TBuffer&) () from /usr/lib64/root/libTree.so.6.16.00
#8 0x00007f715028e6f6 in TBranch::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#9 0x00007f715029d110 in TBranchElement::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#10 0x00007f71502efc17 in TTree::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#11 0x00007f715e393bc2 in ?? ()
#12 0x00007f715d8fd320 in ?? () from /lib64/libstdc++.so.6
#13 0x00007fffe63a9f87 in ?? ()
#14 0x00007fffe63aa230 in ?? ()
#15 0x00007f71582a8cd0 in llvm::RuntimeDyldImpl::~RuntimeDyldImpl() () from /usr/lib64/root/libCling.so
#16 0x0000000003392ee0 in ?? ()
#17 0x00000000023c16f0 in ?? ()
#18 0x0000000002d8ea88 in ?? ()
#19 0x000000000339a650 in ?? ()
#20 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#21 0x00000000023c16f0 in ?? ()
#22 0x0000000002d8e840 in ?? ()
#23 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#24 0x00000000023c16f0 in ?? ()
#25 0x0000000300000000 in ?? ()
#26 0x0000000002d8e690 in ?? ()
#27 0x000000000339a650 in ?? ()
#28 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#29 0x00007f715e393d60 in ?? ()
#30 0x0000000000000000 in ?? ()
===========================================================
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x0000000000000000 in ?? ()
#6 0x00007f715db9fa9c in TArrayF::Streamer(TBuffer&) () from /usr/lib64/root/libCore.so.6.16
#7 0x00007f715029c749 in TBranchElement::ReadLeavesMakeClass(TBuffer&) () from /usr/lib64/root/libTree.so.6.16.00
#8 0x00007f715028e6f6 in TBranch::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#9 0x00007f715029d110 in TBranchElement::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#10 0x00007f71502efc17 in TTree::GetEntry(long long, int) () from /usr/lib64/root/libTree.so.6.16.00
#11 0x00007f715e393bc2 in ?? ()
#12 0x00007f715d8fd320 in ?? () from /lib64/libstdc++.so.6
#13 0x00007fffe63a9f87 in ?? ()
#14 0x00007fffe63aa230 in ?? ()
#15 0x00007f71582a8cd0 in llvm::RuntimeDyldImpl::~RuntimeDyldImpl() () from /usr/lib64/root/libCling.so
#16 0x0000000003392ee0 in ?? ()
#17 0x00000000023c16f0 in ?? ()
#18 0x0000000002d8ea88 in ?? ()
#19 0x000000000339a650 in ?? ()
#20 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#21 0x00000000023c16f0 in ?? ()
#22 0x0000000002d8e840 in ?? ()
#23 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#24 0x00000000023c16f0 in ?? ()
#25 0x0000000300000000 in ?? ()
#26 0x0000000002d8e690 in ?? ()
#27 0x000000000339a650 in ?? ()
#28 0x00007f7157be43e0 in ?? () from /usr/lib64/root/libCling.so
#29 0x00007f715e393d60 in ?? ()
#30 0x0000000000000000 in ?? ()
===========================================================
Any help is appreciated.
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided