Weird segmentation fault

Asked by Daniele Barducci on 2018-11-19

Hello,

I'm using MadAnalysis v.1.6 to do a simple parton level analysis in expert mode with some templates that I've been using for quite a while, but I find a strange error which I don't understand. I am studying p p > Wprime -> w+ h, w+ > e+ ve events and in my Execute part of the code I have the following

    if (event.mc()!=0){
 std::vector<const MCParticleFormat*> ep;
    cout << "---------------NEW EVENT-------------------" << endl;
    // Event weight
    double myWeight=1.;
    if (!Configuration().IsNoEventWeight()) myWeight=event.mc()->weight();

    // Initial state
    for (MAuint32 i=0;i<event.mc()->particles().size();i++){
     const MCParticleFormat* prt = &event.mc()->particles()[i];

  // Collect ep
     if(prt->statuscode()==1 && prt->pdgid() == -11 ){
       ep.push_back(prt);
     }
    } // end loop on particle
 cerr << "Number of positrons " << endl;
 cerr << ep.size() << endl;

which correctly prints "1" for each events. If I add the following lines however

 cerr << "Positron pT " << endl;
 cerr << ep[0]->pt() << endl;

I get the following output

Number of positrons
0
Positron pT

 *** Break *** segmentation violation
 Generating stack trace...
 0x00007fff6b8ed08d in start (in libdyld.dylib) + 1
 0x0000000000000002 in <unknown function>

I didn't manage to track down the error, it's funny that now I get a "0" length for the ep array. Is it something that have to due to my compilers? I have a Mac with macOS Mojave 10.14.1 and I have already noticed some strange behaviour in MadGraph after the update...

Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
MadAnalysis 5 Edit question
Assignee:
No assignee Edit question
Last query:
2018-11-19
Last reply:
2018-11-19
Benjamin Fuks (fuks) said : #1

Hi Daniele,

We havn't tested the code on Mojave yet (you are our first here ;) ). I will speak with Olivier about what is going on with MadGraph. Do you mind in the meantime sharing the code + maybe 10 events?

Cheers,

Benj

> On 19 Nov 2018, at 18:32 , Daniele Barducci <email address hidden> wrote:
>
> New question #676246 on MadAnalysis 5:
> https://answers.launchpad.net/madanalysis5/+question/676246
>
> Hello,
>
> I'm using MadAnalysis to do a simple parton level analysis in expert mode with some templates that I've been using for quite a while, but I find a strange error which I don't understand. I am studying p p > Wprime -> w+ h, w+ > e+ ve events and in my Execute part of the code I have the following
>
> if (event.mc()!=0){
> std::vector<const MCParticleFormat*> ep;
> cout << "---------------NEW EVENT-------------------" << endl;
> // Event weight
> double myWeight=1.;
> if (!Configuration().IsNoEventWeight()) myWeight=event.mc()->weight();
>
> // Initial state
> for (MAuint32 i=0;i<event.mc()->particles().size();i++){
> const MCParticleFormat* prt = &event.mc()->particles()[i];
>
> // Collect ep
> if(prt->statuscode()==1 && prt->pdgid() == -11 ){
> ep.push_back(prt);
> }
> } // end loop on particle
> cerr << "Number of positrons " << endl;
> cerr << ep.size() << endl;
>
>
> which correctly prints "1" for each events. If I add the following lines however
>
> cerr << "Positron pT " << endl;
> cerr << ep[0]->pt() << endl;
>
> I get the following output
>
> Number of positrons
> 0
> Positron pT
>
> *** Break *** segmentation violation
> Generating stack trace...
> 0x00007fff6b8ed08d in start (in libdyld.dylib) + 1
> 0x0000000000000002 in <unknown function>
>
> I didn't manage to track down the error, it's funny that now I get a "0" length for the ep array. Is it something that have to due to my compilers? I have a Mac with macOS Mojave 10.14.1 and I have already noticed some strange behaviour in MadGraph after the update...
>
> Thanks!
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Daniele Barducci (db3e11) said : #2

Hi Benjamin,

I'm the Guinea Pig then :-)

Sure, I can share the events and the code. Shall I send it to you via e-mail?
In the meanwhile I'm trying to figure out what's going on, since I cannot install ExRootAnalysis in MadGraph too, so it might be a problem related with the update

Cheers

Daniele

Daniele Barducci (db3e11) said : #3

I might have found the problem, but it seems unrelated to the compilers.

For some reason the positron in the first event is not read, this is why I get the segmentation fault when I try to print its transverse momentum... I don't know why I didn't notice this in previous works, but anyway all the events have a positron, its just that only 9 out of 10 events are correctly read with the code I have written... Maybe this is just related to the way I coded my analysis, I am not sure. I have sent the code and events to you anyway, but I apologize for the "false alarm"

Can you help with this problem?

Provide an answer of your own, or ask Daniele Barducci for more information if necessary.

To post a message you must log in.