Error in calculation of DeltaPhi distribution


I want to plot DeltaPhi (for -pi to +pi) histogram for two particles in a process. A small part of code is given as,

TLorentzVector vecve, vecj;
double Dphi = vecve.DeltaPhi(vecj);

But I’m getting error,
Error in TROOT::TVector2::Phi_mpi_pi: function called with NaN

How to get rid of this error?


std::cout << vecve.Phi() << " : " << vecj.Phi() << "\n"

Yes, It is not complaining about any error.
I should also mention that vector “vecve” is for neutrino which I get by sum of all remaining outgoing particles shown as,
vecve = vecb1+vecb2+vecj;

What values do you get from my “cout” line right before you try to call “DeltaPhi”?

I’m getting value of phi (for ve and jet) in each event ranging from -pi to +pi. For a particular event it is
3.008150024488533 : 1.408106209432529

Do you get the “NaN” error for this “particular event”?

No, I didn’t get that error in any event.

So what’s your problem?

Sorry, I took some time to find out some events out of one million (in my case) which show this error. Output for one event sample is,

Error in TROOT::TVector2::Phi_mpi_pi: function called with NaN
-nan : -0.06986190212198219

As you can see, for this event the “vecve” is bad. You need to find out why. Try, e.g.:

if (!TMath::Finite(vecve.Phi())) {
  vecve.Print(); // note: vecve = vecb1 + vecb2 + vecj

Thanks, I found the problem. It is vecb2 for which four momenta are undefined. I will try to resolve that.

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