I am running into a segmentation fault at the line p16sim->GetEntry(i); The error happens at the second iteration of the loop (at i=1). Below is my code:
`TFile *f = new TFile("root_files/hor_scan_2.5_0.0_2GeV.root");
TTree *p16sim = (TTree*)f->Get("p16sim");
Double_t edepTrue=0;
Double_t edep;
Int_t crystal_xindex, crystal_yindex, i, j, k=0;
const Int_t NX=5, NY=5;
char hname[20];
p16sim->SetBranchAddress("edepTrue",&edepTrue);
// p16sim->SetBranchAddress("EP16",&EP16);
// create histograms
TH1F *hedep1d[NX][NY];
for (j=0;j<NX;j++) {
for (i=0;i<NY;i++) {
sprintf(hname,"h%d_%d",i,j);
hedep1d[i][j] = new TH1F(hname,"edep",200,0,2000);
}
}
//read all entries and fill the histograms
Int_t nentries = (Int_t)p16sim->GetEntries();
for (i=0; i<nentries; i++) {
p16sim->GetEntry(i);
crystal_xindex = floor(i/2);
crystal_yindex = i%5;
hedep1d[crystal_xindex][crystal_yindex]->Fill(edepTrue);
}`
And here is the first snippet of the error message I am getting:
`#0 0x00007f72f927c457 in __GI___waitpid (pid=4925, stat_loc=stat_loc
entry=0x7fff43ccba58, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1 0x00007f72f91e7177 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:149
#2 0x00007f72f9e21e83 in TUnixSystem::StackTrace() () from /home/patrick/root/lib/libCore.so
#3 0x00007f72f45564a8 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /home/patrick/root/lib/libCling.so
#4 0x00007f72f4555df3 in cling_runtime_internal_throwIfInvalidPointer () from /home/patrick/root/lib/libCling.so
#5 0x00007f72fa6b94ae in ?? ()
#6 0x0000000000000000 in ?? ()
*** Break *** segmentation violation
Hi @phm5024 ,
I can’t say what the problem is either. Can you maybe share a complete (but minimal) reproducer and an example input file so that we can debug on our side?