传递TLorentzVector成员函数

时间:2017-05-05 15:28:00

标签: histogrammar

我正在尝试使用一些函数来遍历一组TLorentzVectors,并使用此处列出的函数绘制每个喷气机横向动量的直方图:

https://github.com/FNALLPC/scientific-python-hats/blob/master/histogrammar/functional-playground.ipynb

我的根树有一个std :: vector分支。我可以使用flatmap获取喷气机列表并执行

jets = events.flatmap(lambda ev : ev.Jets).take(100)

这些对象根据dir(jets [0])确实有一个方法Pt():

dir(jets[0])
['AbstractMethod', 'Angle', 'AppendPad', 'Beta', 'Boost', 'BoostVector', 'Browse', 'Class', 'ClassName', 'Class_Name', 'Class_Version', 'Clear', 'Clone', 'Compare', 'Copy', 'CosTheta', 'DeclFileLine', 'DeclFileName', 'Delete', 'DeltaPhi', 'DeltaR', 'Dictionary', 'DistancetoPrimitive', 'Dot', 'DrEtaPhi', 'Draw', 'DrawClass', 'DrawClone', 'Dump', 'E', 'Energy', 'Error', 'Et', 'Et2', 'Eta', 'EtaPhiVector', 'Execute', 'ExecuteEvent', 'Fatal', 'FindObject', 'Gamma', 'GetDrawOption', 'GetDtorOnly', 'GetIconName', 'GetName', 'GetObjectInfo', 'GetObjectStat', 'GetOption', 'GetTitle', 'GetUniqueID', 'GetXYZT', 'HandleTimer', 'Hash', 'ImplFileLine', 'ImplFileName', 'Info', 'InheritsFrom', 'Inspect', 'InvertBit', 'IsA', 'IsEqual', 'IsFolder', 'IsOnHeap', 'IsSortable', 'IsZombie', 'M', 'M2', 'Mag', 'Mag2', 'MayNotUse', 'Minus', 'Mt', 'Mt2', 'Notify', 'Obsolete', 'P', 'Paint', 'Perp', 'Perp2', 'Phi', 'Plus', 'Pop', 'Print', 'PseudoRapidity', 'Pt', 'Px', 'Py', 'Pz', 'Rapidity', 'Read', 'RecursiveRemove', 'ResetBit', 'Rho', 'Rotate', 'RotateUz', 'RotateX', 'RotateY', 'RotateZ', 'SaveAs', 'SavePrimitive', 'SetBit', 'SetDrawOption', 'SetDtorOnly', 'SetE', 'SetObjectStat', 'SetPerp', 'SetPhi', 'SetPtEtaPhiE', 'SetPtEtaPhiM', 'SetPx', 'SetPxPyPzE', 'SetPy', 'SetPz', 'SetRho', 'SetT', 'SetTheta', 'SetUniqueID', 'SetVect', 'SetVectM', 'SetVectMag', 'SetX', 'SetXYZM', 'SetXYZT', 'SetY', 'SetZ', 'ShowMembers', 'Streamer', 'StreamerNVirtual', 'SysError', 'T', 'TestBit', 'TestBits', 'Theta', 'Transform', 'UseCurrentStyle', 'Vect', 'Warning', 'Write', 'X', 'Y', 'Z', '_TObject__DoError', '_TObject__MakeZombie', '__add__', '__assign__', '__bool__', '__call__', '__class__', '__cmp__', '__contains__', '__cpp_eq__', '__cpp_ne__', '__cppname__', '__delattr__', '__destruct__', '__dict__', '__dispatch__', '__div__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__isub__', '__le__', '__lt__', '__module__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__radd__', '__rdiv__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__rsub__', '__scope__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__weakref__', '_get_smart_ptr', 'kBitMask', 'kCanDelete', 'kCannotPick', 'kHasUUID', 'kInvalidObject', 'kIsOnHeap', 'kIsReferenced', 'kMustCleanup', 'kNUM_COORDINATES', 'kNoContextMenu', 'kNotDeleted', 'kObjInCanvas', 'kOverwrite', 'kSIZE', 'kSingleKey', 'kT', 'kWriteDelete', 'kX', 'kY', 'kZ', 'kZombie', 'ls', 'operator delete', 'operator delete[]', 'operator new', 'operator new[]']

现在,我想把pt打起来,但是:

jets.Bin(100,0,2000,lambda j : j.Pt())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "functionals.py", line 303, in hargs
    h.fill(x)
  File "/cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/histogrammar/1.0.5-oenich4/lib/python2.7/site-packages/histogrammar-1.0.5-py2.7.egg/histogrammar/util.py", line 51, in __call__
    return self.fill(*args, **kwds)
  File "/cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/histogrammar/1.0.5-oenich4/lib/python2.7/site-packages/histogrammar-1.0.5-py2.7.egg/histogrammar/primitives/bin.py", line 256, in fill
    q = self.quantity(datum)
  File "/cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/histogrammar/1.0.5-oenich4/lib/python2.7/site-packages/histogrammar-1.0.5-py2.7.egg/histogrammar/util.py", line 325, in __call__
    return self.fcn(*args, **kwds)
  File "<stdin>", line 1, in <lambda>
AttributeError: 'PyROOT_NoneType' object has no attribute 'Pt'

我在这里使用的语法是否正确?

0 个答案:

没有答案