I am trying to create a new array-type branch for TTree (tree). When I just declare an array-type branch, and then run the code, and then draw the branch or access the branch in TBrowser, I get segmentation error. If I just declare a normal branch (without array), it is normal.
This is the file test.C generated by tree->MakeClass(“test”). I just add two lines to make an empty branch.
#define test_cxx
#include "test.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void test::Loop()
{
// In a ROOT session, you can do:
// root> .L test.C
// root> test t
// root> t.GetEntry(12); // Fill t data members with entry number 12
// root> t.Show(); // Show values of entry 12
// root> t.Show(16); // Read and show values of entry 16
// root> t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Double_t p1[64]; fChain->Branch("p1",&p1,"p1[64]/D"); //!!!!! added
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=23; jentry<24;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
fChain->Fill(); //!!!! added
}
}
This is the seg error message.
root [2] test m
(test &) @0x7f2998bfd000
root [3] m.Loop()
root [4] TBrowser gg
(TBrowser &) Name: Browser Title: ROOT Object Browser
root [5]
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f29aee894fc in waitpid () from /lib64/libc.so.6
#1 0x00007f29aee06fb2 in do_system () from /lib64/libc.so.6
#2 0x00007f29aff49404 in TUnixSystem::StackTrace() () from /home/daq/root_v6.22.08_gcc48/lib/libCore.so.6.22
#3 0x00007f29aff4b09a in TUnixSystem::DispatchSignals(ESignals) () from /home/daq/root_v6.22.08_gcc48/lib/libCore.so.6.22
#4 <signal handler called>
#5 0x0000000000000578 in ?? ()
#6 0x0000000005abcca8 in ?? ()
#7 0x0000000000000012 in ?? ()
#8 0x00007fff3faa4c40 in ?? ()
#9 0x00007fff3faa4d00 in ?? ()
#10 0x00007fff3faa4c30 in ?? ()
#11 0x0000000005a5cab0 in ?? ()
#12 0x0000000005ab7bf8 in ?? ()
#13 0x0000000000000025 in ?? ()
#14 0x00000000011cd938 in ?? ()
#15 0x0000000005ab3410 in ?? ()
#16 0x0000000005abd939 in ?? ()
#17 0x00007fff3faa4b1f in ?? ()
#18 0x00007fff3faa4b20 in ?? ()
#19 0x0000000005787110 in ?? ()
#20 0x0000000000000010 in ?? ()
#21 0x00007f29af96b0e5 in operator new(unsigned long) () at ../../.././libstdc++-v3/libsupc++/new_op.cc:50
#22 0x00007f29ab617c94 in cling::IncrementalJIT::getSymbolAddressWithoutMangling(std::string const&, bool) () from /home/daq/root_v6.22.08_gcc48/lib/libCling.so
#23 0x00007fff3faa4f30 in ?? ()
#24 0x0000000000000000 in ?? ()
===========================================================
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://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 0x0000000000000578 in ?? ()
#6 0x0000000005abcca8 in ?? ()
#7 0x0000000000000012 in ?? ()
#8 0x00007fff3faa4c40 in ?? ()
#9 0x00007fff3faa4d00 in ?? ()
#10 0x00007fff3faa4c30 in ?? ()
#11 0x0000000005a5cab0 in ?? ()
#12 0x0000000005ab7bf8 in ?? ()
#13 0x0000000000000025 in ?? ()
#14 0x00000000011cd938 in ?? ()
#15 0x0000000005ab3410 in ?? ()
#16 0x0000000005abd939 in ?? ()
#17 0x00007fff3faa4b1f in ?? ()
#18 0x00007fff3faa4b20 in ?? ()
#19 0x0000000005787110 in ?? ()
#20 0x0000000000000010 in ?? ()
#21 0x00007f29af96b0e5 in operator new(unsigned long) () at ../../.././libstdc++-v3/libsupc++/new_op.cc:50
#22 0x00007f29ab617c94 in cling::IncrementalJIT::getSymbolAddressWithoutMangling(std::string const&, bool) () from /home/daq/root_v6.22.08_gcc48/lib/libCling.so
#23 0x00007fff3faa4f30 in ?? ()
#24 0x0000000000000000 in ?? ()
===========================================================
Thank you,
Marco
ROOT Version: 6.22/08
Platform: centos 7
Compiler: aclic