Basic operations on LorentzVector

Dear experts,

Is the following not expected to work (e.g. in the ROOT interpreter):

ROOT::Math::PxPyPzE4D<double> p1(0., 0., 1., 1.);
ROOT::Math::PxPyPzE4D<double> p2(0., 0., 1., 1.);
p1 + p2
ROOT_prompt_5:1:4: error: invalid operands to binary expression ('ROOT::Math::PxPyPzE4D<double>' and 'ROOT::Math::PxPyPzE4D<double>')
p1 + p2
~~ ^ ~~
/usr/local/Cellar/root/6.26.06_1/include/root/TString.h:521:1: note: candidate function template not viable: no known conversion from 'ROOT::Math::PxPyPzE4D<double>' to 'TString' for 1st argument
(...)

?

If not, why is that?

ROOT Version: 6.28/10
Built for linuxx8664gcc on Nov 27 2023, 21:04:13
From tags/v6-28-10@v6-28-10
Platform: AlmaLinux9
With cvmfs access, the environment can be retrieved with: source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh


In case it is useful for others, the following does work:

root [0] ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<Double32_t>> a(0,0,1,1)
(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<Double32_t> > &) (0,0,1,1)
root [1] ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<Double32_t>> b(0,0,-1,1)
(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<Double32_t> > &) (0,0,-1,1)
root [2] a+b
(ROOT::Math::LorentzVector) (0,0,0,2)

Hi Brieuc,

Thanks for the interesting post and welcome to the ROOT community!
The problem is that you are trying to sum two instances of a class describing a 4D cartesian coordinate system (momentum-energy coordinates). See here.

The class to use to represent 4-vectors in your case would indeed be ROOT::Math::PxPyPzEVector which is nothing but a typedef of LorentzVector<PxPyPzE4D<double> >

I hope this helps, if not feel free to come back with more questions.

Best,
D

Hi Danilo,

Thanks, it does help. It looks like I got confused with the coordinate system representation and actual vector instances. Sorry for the noise.

Best,
Brieuc