*** Break *** segmentation violation

Hi,

I have problem reading the data from a Hijing generated file. I can’t upload the root file, because its too big…

I am using mac version 10.10, root version:5.34/30.

The script to read the root file:

[code]
#ifndef CINT
#include “TROOT.h”
#include “TParticle.h”
#include “TParticlePDG.h”
#include “TFile.h”
#include “TTree.h”
#include “TClonesArray.h”
#include “TMath.h”
#include
#else
class TParticlePDG; // Auto-load
class TParticle; // Auto-load
#endif

struct Header {
unsigned int run;
unsigned int event;
unsigned int ntgt;
unsigned int nproj;
unsigned int nbin;
unsigned int type;
double ipx;
double ipy;
double ipz;
double b;
double c;
double phir;
unsigned nsnp;
unsigned nsnt;
unsigned nspp;
unsigned nspt;
};

int foo() {

TFile *f = TFile::Open("Hijing.root" ,"READ");
TTree *t = static_cast<TTree*>(f->Get("T"));

Header*       h = new Header;
TClonesArray* p = new TClonesArray("TParticle");
t->SetBranchAddress("header",    &(h->run));
t->SetBranchAddress("particles", &p);
for (int i = 0; i < t->GetEntries(); i++) {
    t->GetEntry(i);
           if (h->event <= 30) {
        for (int j = 0; j < (p->GetEntriesFast()); j++) {
            TParticle* q = static_cast<TParticle*>(p->At(j));
            std::cout<< " Mass: "<<q->GetMass()<< std::endl;

        }
    }
}

}[/code]

The error message:

[code]Mass: 0.78265
Mass: 0.13957
Mass: 0.13957
Mass: 0.134977
Mass: 0.896
Mass: 1.11568
Mass: 0.938272
Mass: 0.13957
Mass: 0.896
Mass: 1.31486

*** Break *** segmentation violation
Mass: Generating stack trace…
0x00000001106f70b4 in G__foo_cpp_ACLiC_dict__0_2180(G__value*, char const*, G__param*, int) (in foo_cpp.so) + 36
0x0000000108b244a6 in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) (in libCint.5.so) (Api.cxx:393)
0x0000000108c722a2 in G__execute_call (in libCint.5.so) (newlink.cxx:2413)
0x0000000108c72bc4 in G__call_cppfunc (in libCint.5.so) (newlink.cxx:2612)
0x0000000108c2c0af in G__interpret_func (in libCint.5.so) (ifunc.cxx:5791)
0x0000000108c0c8c7 in G__getfunction (in libCint.5.so) (func.cxx:2901)
0x0000000108bf9e0b in G__getitem (in libCint.5.so) (expr.cxx:1918)
0x0000000108bf85ed in G__getexpr (in libCint.5.so) (expr.cxx:1488)
0x0000000108be3150 in G__calc_internal (in libCint.5.so) (expr.cxx:1071)
0x0000000108cd8154 in G__process_cmd (in libCint.5.so) (pause.cxx:2331)
0x00000001081fbaf4 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) (in libCore.5.so) (TCint.cxx:549)
0x00000001081fbe69 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (in libCore.5.so) (TCint.cxx:628)
0x0000000108157b8a in TApplication::ExecuteFile(char const*, int*, bool) (in libCore.5.so) (TApplication.cxx:1111)
0x00000001081ffa45 in TCint::ExecuteMacro(char const*, TInterpreter::EErrorCode*) (in libCore.5.so) (TCint.cxx:1496)
0x000000010819bb08 in TROOT::Macro(char const*, int*, bool) (in libCore.5.so) (TROOT.cxx:1716)
0x0000000108464e3f in G__G__Base2_296_0_105(G__value*, char const*, G__param*, int) (in libCore.5.so) (G__Base2.cxx:18433)
0x0000000108b244a6 in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__param*, int), G__value*, char*, G__param*, int) (in libCint.5.so) (Api.cxx:393)
0x0000000108c722a2 in G__execute_call (in libCint.5.so) (newlink.cxx:2413)
0x0000000108c72bc4 in G__call_cppfunc (in libCint.5.so) (newlink.cxx:2612)
0x0000000108c2c0af in G__interpret_func (in libCint.5.so) (ifunc.cxx:5791)
0x0000000108c0b8fd in G__getfunction (in libCint.5.so) (func.cxx:2660)
0x0000000108dbcc59 in G__getstructmem(int, G__FastAllocString&, char*, int, char*, int*, G__var_array*, int) (in libCint.5.so) (var.cxx:6821)
0x0000000108daae6c in G__getvariable (in libCint.5.so) (var.cxx:5405)
0x0000000108bf9d22 in G__getitem (in libCint.5.so) (expr.cxx:1906)
0x0000000108bf85ed in G__getexpr (in libCint.5.so) (expr.cxx:1488)
0x0000000108ccc5cb in G__exec_function(G__FastAllocString&, int*, int*, int*, G__value*) (in libCint.5.so) (parse.cxx:645)
0x0000000108cc1166 in G__exec_statement (in libCint.5.so) (parse.cxx:7371)
0x0000000108c2f8fd in G__interpret_func (in libCint.5.so) (ifunc.cxx:6710)
0x0000000108c0c8c7 in G__getfunction (in libCint.5.so) (func.cxx:2901)
0x0000000108bf9e0b in G__getitem (in libCint.5.so) (expr.cxx:1918)
0x0000000108bf85ed in G__getexpr (in libCint.5.so) (expr.cxx:1488)
0x0000000108be3150 in G__calc_internal (in libCint.5.so) (expr.cxx:1071)
0x0000000108cd8154 in G__process_cmd (in libCint.5.so) (pause.cxx:2331)
0x00000001081fbaf4 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) (in libCore.5.so) (TCint.cxx:549)
0x00000001081fbe69 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (in libCore.5.so) (TCint.cxx:628)
0x0000000108157b8a in TApplication::ExecuteFile(char const*, int*, bool) (in libCore.5.so) (TApplication.cxx:1111)
0x000000010941dfbe in TRint::Run(bool) (in libRint.5.so) (TRint.cxx:417)
0x000000010814ce2f in main (in root.exe) (rmain.cxx:31)
0x00007fff96b5a5c9 in start (in libdyld.dylib) + 1
0x0000000000000004 in
Root > Function Load() busy flag cleared[/code]

Hope someone can help.

Thanks.

May be you can generate a subset of the big file in order to post it here ?
Or provide a download address for it ?
Have you tried a more recent ROOT version ? ROOT 5.34 is now 5.34/36
There is also ROOT 6.06…

I have actually no idea how to generate a subset of it. But I have uploaded the file and it can be downloaded from here: filedropper.com/hijing

I will update my root right now :slight_smile:

If breaks when it meets a particle with PDG codes “3124” or “-3124”, because:
root [0] TDatabasePDG::Instance()->GetParticle(3124)
(const class TParticlePDG*)0x0
root [1] TDatabasePDG::Instance()->GetParticle(-3124)
(const class TParticlePDG*)0x0
This happens in both ROOT 5.34/36 and 6.06/02.
Don’t forget to report this problem in JIRA (this problems appears, for example, for ±3124, ±3126 and ±3128, but not for ±3122).

For the moment, you can try a “brutal fix” … right before “std::cout”, add:
if (TMath::Abs(q->GetPdgCode()) == 3124) continue;

I have just updated my ROOT and I have some minor problem, before I can implement your suggestion.
But thank you so much!! :smiley:

It works right now!

Once again thanks! :smiley:

The problem with PDG codes ±3124 has been solved in the “master”, 5.34 and 6.06 branches.