Pregunta

I'm currently trying to access Math functions such as DeltaR from rootpy, but I'm not sure how this is done. I've seen nothing in the documentation or in any examples. The C++ equivalent would be something like:

double dR = ROOT::Math::VectorUtil::DeltaR((jets)[i],(partons)[i]);

But I'm unable to find a rootpy or even pyroot equivalent that'll work. If I try in pyroot with

import ROOT as r
r.Math.VectorUtil.DeltaR(jets[i],partons[i])

I get the error:

AttributeError: type object 'ROOT::Math' has no attribute 'VectorUtil'

When it quite clearly should, unless I don't understand correctly what it means by 'Attribute'. Anyway, I don't want to ask pyroot questions here :) I just put this down to a quirk in the way that pyroot handles such things, which is why I thought I'd give rootpy a try. I'm not sure if this is possible however.

Cheers, Joseph

¿Fue útil?

Solución

The functions from ROOT::Math::VectorUtil are in libGenVector which is loaded automatically in neither CINT nor PyROOT. Manually loading it (like you probably do in your root_logon.C) makes the functions available, e.g.

import ROOT as r
r.gSystem.Load('libGenVector')

# ...

r.Math.VectorUtil.DeltaR(jets[i],partons[i])

Otros consejos

If jets and partons are TLorentzVectors then you should be able to do:

from ROOT import *
dR = jet.DeltaR(parton)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top