vector<TLorentzVector> push_back segmentation violation

Dear support team,

I’m facing a problem where I get segmentation violation once I push_back a TLorentzVector in a vector variable with the following message:

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f3970bafa3c in waitpid () from /lib64/libc.so.6
#1  0x00007f3970b2dde2 in do_system () from /lib64/libc.so.6
#2  0x00007f39717241a4 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.6.16
#3  0x00007f3971725fec in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.6.16
#4  <signal handler called>
#5  0x00007f396422c504 in TVector3::PseudoRapidity() const () from /usr/lib64/root/libPhysics.so.6.16.00
#6  0x00007f3971d2a4b0 in ?? ()
#7  0x000000000507b350 in ?? ()
#8  0x0000000000000000 in ?? ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007f396422c504 in TVector3::PseudoRapidity() const () from /usr/lib64/root/libPhysics.so.6.16.00
#6  0x00007f3971d2a4b0 in ?? ()
#7  0x000000000507b350 in ?? ()
#8  0x0000000000000000 in ?? ()
===========================================================

The code reads ntuple files and the problem appears for specific files and specific particles.

The TLorentzVector parameter is set using SetPtEtaPhiE routine. If instead of the particle kinematics I define the TLorentzVector as SetPtEtaPhiE(0,0,0,0) the push_back problem disappears.

After printing out some particle kinematics to check if there is something funny going on, I see that there is nothing wrong there. All particle kinematics are Double_t and just to be on the safe side I’m checking if numbers are finite (isfinite routine). An example of pt-eta-phi-E values that the code breaks is the following:
84.3609 -1.14813 2.2105 146.346

I remember that handling a vector used to be an issue in precious root versions so I’m loading a .C file inside my macro with the following code but with no successful results

#include <vector>
#include "TLorentzVector.h"
#pragma link C++ class std::vector< std::vector >+; 
#pragma link C++ class std::vector< TLorentzVector >+;

The root version I’m using is v6-16-00.(lxplus)
Any idea what might be going wrong with this behavior?

Thanks for your time!

Best regards,
Yannis

Hi Yannis,

it is not clear to me what you are doing: can you share the minimal portion of the code reproducing the issue?
In addition, I think TLorentzVector is not to be used and ROOT::Math::LorentzVector is to be used instead: https://root.cern.ch/doc/master/classTLorentzVector.html

Cheers,
P

You don’t actually need those #pragma link C++ class std::vector< ... >+; lines; we support vector without. Also, vector is not a type, so std::vector<std::vector> Is missing a template argument for the inner vector.

And indeed we’ll need a minimal reproducing script / code…

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