PyRoot problems with TPair and TDSetElement

Hi,

I am trying to run some python code with proof and I started to play around with datasets. Now I am stuck on the following problem:

I need access the input element “PROOF_CurrentElement” for proof to know which dataset I am working at and in the proof documentation it says to use the following code within a TSelector class:

if (fInput && (elemPair = dynamic_cast<TPair *>(fInput->FindObject("PROOF_CurrentElement")))) { TDSetElement *fCurrent = dynamic_cast<TDSetElement *>(elemPair->Value()); if (fCurrent) { if (fCurrent->TestBit(TDSetElement::kNewRun)) { Info(fCurrent->GetDataSet()); } if (fCurrent->TestBit(TDSetElement::kNewPacket)) { Info(fCurrent->GetName()); } }

which I translated into python (within the a class inherited from TPySelector class) as:

if self.fInput: elemPair=self.fInput.FindObject("PROOF_CurrentElement") if elemPair != None: fCurrent = elemPair.Value() if fCurrent.TestBit(TDSetElement.kNewRun): print fCurrent.GetDataSet() if fCurrent.TestBit(TDSetElement.kNewPacket): print fCurrent.GetName()

Unfortunately I get a crash at the line “fCurrent = elemPair.Value()” and the crash looks like this:

[code]Thread 2 (Thread 0x417e8940 (LWP 4183522)):
#0 0x0000003dbe2cad26 in poll () from /lib64/libc.so.6
#1 0x00002b18756ed286 in XrdClientSock::RecvRaw (this=0x18935ef0,
buffer=0x19262460, length=8, substreamid=-1,
usedsubstreamid=)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/XrdClientSock.cc:133
#2 0x00002b1875708422 in XrdClientPhyConnection::ReadRaw (this=0x189345e0,
buf=0x19262460, len=8, substreamid=-1, usedsubstreamid=0x417e7d9c)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/XrdClientPhyConnection.cc:359
#3 0x00002b187570b528 in XrdClientMessage::ReadRaw (this=0x19262420,
phy=0x189345e0)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/XrdClientMessage.cc:152
#4 0x00002b1875707bdc in XrdClientPhyConnection::BuildMessage (
this=0x189345e0, IgnoreTimeouts=true, Enqueue=true)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/XrdClientPhyConnection.cc:440
#5 0x00002b1875708212 in SocketReaderThread (arg=0x189345e0,
thr=)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdClient/XrdClientPhyConnection.cc:57
#6 0x00002b187548713f in XrdSysThread_Xeq (myargs=)
at /afs/slac/public/software/scalla/releases/v3.2.7/xrootd-3.2.7/src/XrdSys/XrdSysPthread.cc:67
#7 0x0000003dbea0677d in start_thread () from /lib64/libpthread.so.0
#8 0x0000003dbe2d3c1d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x2b187362e2f0 (LWP 4183509)):
#0 0x0000003dbe2997ef in waitpid () from /lib64/libc.so.6
#1 0x0000003dbe23c761 in do_system () from /lib64/libc.so.6
#2 0x0000003dbe23cab7 in system () from /lib64/libc.so.6
#3 0x00002b1871d653c6 in TUnixSystem::StackTrace() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#4 0x00002b1871d64c9c in TUnixSystem::DispatchSignals(ESignals) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#5
#6 0x00002b1871f4584b in TInstrumentedIsAProxy::operator()(void const*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#7 0x00002b1871d2c044 in TClass::GetActualClass(void const*) const ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#8 0x00002aaab10a6afb in PyROOT::BindRootObject(void*, TClass*, bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#9 0x00002aaab1091021 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe(void*, bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#10 0x00002aaab1092e97 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute(void*, bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#11 0x00002aaab108f450 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator()(PyROOT::ObjectProxy*, _object*, _object*, long, bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#12 0x00002aaab1094aa0 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#13 0x00002aaab1334848 in PyObject_Call (func=0x18e9efd0, arg=0x2aaaac4b5050,
kw=0x0) at Objects/abstract.c:2492
#14 0x00002aaab13dace2 in do_call (f=0x191c8b00,
throwflag=) at Python/ceval.c:3968
#15 call_function (f=0x191c8b00, throwflag=)
at Python/ceval.c:3773
#16 PyEval_EvalFrameEx (f=0x191c8b00, throwflag=)
at Python/ceval.c:2412
#17 0x00002aaab13dd637 in fast_function (f=0x19221220,
throwflag=) at Python/ceval.c:3836
#18 call_function (f=0x19221220, throwflag=)
at Python/ceval.c:3771
#19 PyEval_EvalFrameEx (f=0x19221220, throwflag=)
at Python/ceval.c:2412
#20 0x00002aaab13de847 in PyEval_EvalCodeEx (co=0x2aaaac6bb6c0,
globals=, locals=,
args=0x2aaaac6bcf98, argcount=2, kws=0x0, kwcount=0, defs=0x0, defcount=0,
closure=0x0) at Python/ceval.c:3000
#21 0x00002aaab13633ad in function_call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/funcobject.c:524
#22 0x00002aaab1334848 in PyObject_Call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/abstract.c:2492
#23 0x00002aaab1345630 in instancemethod_call (func=0x2aaaac651e60,
arg=0x2aaaac6bcf80, kw=0x0) at Objects/classobject.c:2579
#24 0x00002aaab1334848 in PyObject_Call (func=0x18f2f320, arg=0x2aaaac68a610,
kw=0x0) at Objects/abstract.c:2492
#25 0x00002aaab133700e in call_function_tail (callable=0x18f2f320,
format=) at Objects/abstract.c:2524
#26 PyObject_CallFunction (callable=0x18f2f320, format=)
at Objects/abstract.c:2548
#27 0x00002aaab10afc82 in TPySelector::CallSelf(char const*, _object*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#28 0x00002aaab10afea1 in TPySelector::Init(TTree*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libPyROOT.so
#29 0x00002aaaab6b8bae in TEventIterTree::GetNextPacket(long long&, long long&, TEntryList**, TEventList**) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProofPlayer.so
#30 0x00002aaaab6f515d in TProofPlayer::Process(TDSet*, char const*, char const*, long long, long long) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProofPlayer.so
#31 0x00002b1874ebe795 in TProofServ::HandleProcess(TMessage*, TString*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProof.so
#32 0x00002b1874ec08d6 in TProofServ::HandleSocketInput(TMessage*, bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProof.so
#33 0x00002b1874eb5181 in TProofServ::HandleSocketInput() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProof.so
#34 0x00002b1875222fc9 in TXProofServ::HandleInput(void const*) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProofx.so
#35 0x00002b18752336bd in TXSocketHandler::Notify() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libProofx.so
#36 0x00002b1871d632f4 in TUnixSystem::CheckDescriptors() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#37 0x00002b1871d63911 in TUnixSystem::DispatchOneEvent(bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#38 0x00002b1871cd7476 in TSystem::InnerLoop() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#39 0x00002b1871cd973c in TSystem::Run() ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#40 0x00002b1871c6baef in TApplication::Run(bool) ()
from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.10-x86_64-slc5-gcc4.3/lib/libCore.so
#41 0x0000000000401c55 in main ()
===========================================================[/code]

Does it mean that python as problems converting the TObject* in the value of TPair object into its actual class (TDSetElement)? Any workaround for this case?

Sorry I forgot to mention, I am using root ROOT 5.34/10 “heads/v5-34-00-patches@v5-34-10-5-g0e8bac8” straight from CVMFS (this is setup while I setup Proof On Demand from CVMFS).

Cheers
Duc

Duc,

what is a “TPair” for an object? The typical reason for GetActualClass() to fail, is for virtual inheritance. Is there any?

Also, I’m no fan of “if elemPair != None:” as it may be yield unexpected behavior if the C++ class defines operator!= and/or operator==. Does TPair do that?

Cheers,
Wim