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.

Cheers,
Nab

jet1.cc (12.1 KB)

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

Processing jet1.cc...
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.

/afs/cern.ch/user/n/nmajeed/public/MergedMiniEvents_6.root

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 'jet1.cc++g'

Hi,

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/cern.ch/user/n/nmajeed/public/
fake_ratio.cc  lat_0MergedMiniEvents_0.root  May26_2.root  new_macro.cc  
ReadTree.cc  TOP-16-006.cc.txt  try1_data.cc

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 ‘jet1.cc++g’
==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 jet1.cc++g
==13058==
==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.
jet1.cc (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");
      Z_Inv_mass->Write();
      z_pt->Write();
      W_Tran_mass->Write();

      ff->Close();

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) {
                  selectedMuons.push_back(tmp);
                  mu_charge.push_back(Mu_charge[m]);
               }
            }
         }

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

Try:
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 jet1.cc 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) )
  continue;
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.