Break with segmentation error

Dear Developers,

I am running a script but it crashes and gives a segmentation error.
Please help me to resolve this issue.

Nab (12.1 KB)

We cannot try your macro, the data file is missing :

Error in <TFile::TFile>: file /eos/cms/store/user/aahmad/Jul12/MCs/1fab0e5/MC13TeV_DY50toInf_nlo/MergedMiniEvents_28.root does not exist

Can this be related?

Dear Wile,

These files exit at that path. They are at eos.

Dear Wile,

I have downloaded the related file from eos. You may use it.


Try to run your code using valgrind (and carefully study messages that appear in the beginning of the output):

valgrind --tool=memcheck --leak-check=full --suppressions=`root-config --etcdir`/valgrind-root.supp `root-config --bindir`/root.exe -l -q ''


What is the command for valgrind.

Simply copy / paste (into a terminal window) the full line that I gave you in my previous post.

This file is not in you public folder:

$ ls /afs/  lat_0MergedMiniEvents_0.root  May26_2.root

is it lat_0MergedMiniEvents_0.root ?

I have copied the same command but it gives me

[nmajeed@lxplus035 new_sirra]$ valgrind --tool=memcheck --leak-check=full --suppressions=root-config --etcdir/valgrind-root.supp root-config --bindir/root.exe -l -q ‘’
==13058== Memcheck, a memory error detector
==13058== Copyright © 2002-2012, and GNU GPL’d, by Julian Seward et al.
==13058== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==13058== Command: /usr/bin/root.exe -l -q
==13058== FATAL: can’t open suppressions file “/usr/share/root/valgrind-root.supp”

sorry couet, I have moved it.
Please check it now.

I start looking at your code. I tried to make it more readable by indenting it properly and removing useless lines. I found out it is very very hard to read because of that lack of indention. I think there is even some logical mistakes because of that. It would be good if you can spend a bit of time cleaning it … Doing this exercise you may even find the mistake yourself…

1 Like

Yes couet I am already trying to make it in a reasonable condition. Could you please specify some lines which are causing this error if possible.

No, not before you have properly indented it … the code you sent is completely wrong with that respect. I think you did some logical mistake because of that … I do not know where. My editor (which is able to match bracket) is lost … that’s a very bad sign. Once you’ll have cleaned and indented properly your code I am willing to look again at it if it still crash … but please do this clean up before !

Here is a properly indented version of your macro. It still crashes but it is more readable. (9.8 KB)

After This clean up I see that that you do the following code at the end for the LOOP OVER EVENTS

      TFile *ff = new TFile("dg6.root","RECREATE");


which means you will recreate the file dg6.root 1877399 times (nentries). is it what you really want to do ?

In your macro, If I comment the loop selected muons then it does not crash. So you should try to find the mistake in this code I think:

         // selected muons
         for (int m=0; m<nMu;m++) {
            TLorentzVector tmp(0,0,0,0);
            bool passTightKin(Mu_pt[m]>=10 && fabs(Mu_eta[m])<2.5); // I made selected muons as a loose to make it equal to veto muons by changing cuts
            float relIso(Mu_relIso[m]);
            bool passIso(relIso<0.5);
            tmp.SetPtEtaPhiM(Mu_pt[m], Mu_eta[m], Mu_phi[m], Mu_mass[m]);
            if (passTightKin ) { //&& passSIP3d)
               if (passIso) {

No I donot want to create it nentries time. If I take it out of the loop, the problem still persists.

locate valgrind-root.supp
and if you get nothing (in principle, this file should be in the subdirectory returned by “root-config --etcdir”), you should talk to the one who installed your ROOT version.

Basically, I think your problem is that, in lines 289 to 293 of your original macro (from the first post here), you access mu_isTight, mu_ismuon, mu_iso and selectedMuons vectors, but you do not check that the indices m_i and m_ii are valid for these vectors. So you should prepend these lines with something like:

if ( (m_i < 0) || (m_ii < 0) ||
     (mu_isTight.size() <= (unsigned)m_i) || (mu_isTight.size() <= (unsigned)m_ii) ||
     (mu_ismuon.size() <= (unsigned)m_i) || (mu_ismuon.size() <= (unsigned)m_ii) ||
     (mu_iso.size() <= (unsigned)m_i) || (mu_iso.size() <= (unsigned)m_ii) ||
     (selectedMuons.size() <= (unsigned)m_i) || (selectedMuons.size() <= (unsigned)m_ii) )
1 Like

Thank you Wile_E_Coyote. I was doing a mistake in cuts, indicated by you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.