40 branch =
tree->GetBranch((std::string(
name) +
'.').c_str());
48 if (branch && !leaf) {
73 if (branch->IsA() == TBranchElement::Class() || branch->IsA() == TBranchObject::Class()) {
109 if (leaf->IsA() == TLeafElement::Class() || leaf->IsA() == TLeafObject::Class())
125 if (!name_possibly_alias)
132 PyErr_SetString(PyExc_ReferenceError,
"attempt to access a null-pointer");
137 const char *
name =
tree->GetAlias(name_possibly_alias);
139 name = name_possibly_alias;
147 if (proxy !=
nullptr)
157 if (wrapper !=
nullptr)
162 PyErr_Format(PyExc_AttributeError,
"\'%s\' object has no attribute \'%s\'",
tree->IsA()->GetName(),
name);
176 PyObject *pyclass = PyTuple_GetItem(args, 0);
198 PyObject *treeObj =
nullptr, *
name =
nullptr, *address =
nullptr;
200 int argc = PyTuple_GET_SIZE(args);
203#if PY_VERSION_HEX < 0x03000000
204 auto argParseStr =
"OSO:SetBranchAddress";
206 auto argParseStr =
"OUO:SetBranchAddress";
208 if (argc == 3 && PyArg_ParseTuple(args,
const_cast<char *
>(argParseStr), &treeObj, &
name, &address)) {
214 PyErr_SetString(PyExc_TypeError,
215 "TTree::SetBranchAddress must be called with a TTree instance as first argument");
220 auto branch =
tree->GetBranch(branchName);
222 PyErr_SetString(PyExc_TypeError,
"TTree::SetBranchAddress must be called with a valid branch name");
226 bool isLeafList = branch->IsA() == TBranch::Class();
233 buf = (
void *)((
CPPInstance *)address)->GetObject();
235 buf = (
void *)&(((
CPPInstance *)address)->GetObjectRaw());
239 if (buf !=
nullptr) {
257 PyObject *
name =
nullptr, *address =
nullptr, *leaflist =
nullptr, *bufsize =
nullptr;
259 if (PyArg_ParseTuple(args,
const_cast<char *
>(
"OO!OO!|O!:Branch"),
264 &PyInt_Type, &bufsize)) {
269 PyErr_SetString(PyExc_TypeError,
"TTree::Branch must be called with a TTree instance as first argument");
275 buf = (
void *)((
CPPInstance *)address)->GetObject();
283 PyInt_AS_LONG(bufsize));
306 PyObject *
name =
nullptr, *clName =
nullptr, *address =
nullptr, *bufsize =
nullptr, *splitlevel =
nullptr;
308 auto bIsMatch =
false;
309 if (PyArg_ParseTuple(args,
const_cast<char *
>(
"OO!O!O|O!O!:Branch"),
314 &PyInt_Type, &bufsize,
315 &PyInt_Type, &splitlevel)) {
319 if (PyArg_ParseTuple(args,
const_cast<char *
>(
"OO!O|O!O!"),
323 &PyInt_Type, &bufsize,
324 &PyInt_Type, &splitlevel)) {
335 PyErr_SetString(PyExc_TypeError,
"TTree::Branch must be called with a TTree instance as first argument");
356 if (buf && !klName.empty()) {
360 }
else if (argc == 5) {
362 }
else if (argc == 6) {
364 PyInt_AS_LONG(splitlevel));
396 int argc = PyTuple_GET_SIZE(args);
400 if (branch != Py_None)
404 if (branch != Py_None)
#define CPyCppyy_PyText_AsString
#define CPyCppyy_PyText_Type
TClass * GetTClass(const CPyCppyy::CPPInstance *pyobj)
static TBranch * SearchForBranch(TTree *tree, const char *name)
static PyObject * BindBranchToProxy(TTree *tree, const char *name, TBranch *branch)
PyObject * TryBranchLeafListOverload(int argc, PyObject *args)
Try to match the arguments of TTree::Branch to the following overload:
PyObject * TryBranchPtrToPtrOverloads(int argc, PyObject *args)
Try to match the arguments of TTree::Branch to one of the following overloads:
static TLeaf * SearchForLeaf(TTree *tree, const char *name, TBranch *branch)
PyObject * GetAttr(CPPInstance *self, PyObject *pyname)
static PyObject * WrapLeaf(TLeaf *leaf)
virtual PyObject * FromMemory(void *address)
A Branch for the case of an object.
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
TClass * GetCurrentClass()
Return a pointer to the current type of the data member corresponding to branch element.
virtual TClass * GetTargetClass()
char * GetObject() const
Return a pointer to our object.
A TTree is a list of TBranches.
virtual TLeaf * GetLeaf(const char *name) const
Return pointer to the 1st Leaf named name in thisBranch.
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any.
virtual char * GetAddress() const
TObjArray * GetListOfLeaves()
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual void * GetValuePointer() const
virtual const char * GetTypeName() const
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
virtual Int_t GetNdata() const
TBranch * GetBranch() const
virtual Int_t GetLenStatic() const
Return the fixed length of this leaf.
virtual const char * GetName() const
Returns name of object.
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
TObject * First() const
Return the object in the first slot.
TObject * At(Int_t idx) const
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
TObjArray * GetElements() const
A TTree represents a columnar dataset.
Py_ssize_t GetBuffer(PyObject *pyobject, char tc, int size, void *&buf, bool check=true)
bool AddToClass(PyObject *pyclass, const char *label, PyCFunction cfunc, int flags=METH_VARARGS)
Set of helper functions that are invoked from the pythonizors, on the Python side.
PyObject * BindCppObjectNoCast(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
bool CPPInstance_Check(T *object)
PyObject * BindCppObject(Cppyy::TCppObject_t object, Cppyy::TCppType_t klass, const unsigned flags=0)
CPYCPPYY_EXTERN void DestroyConverter(Converter *p)
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, Py_ssize_t *dims=nullptr)
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
PyObject * SetBranchAddressPyz(PyObject *self, PyObject *args)
Add pythonization for TTree::SetBranchAddress.
PyObject * BranchPyz(PyObject *self, PyObject *args)
Add pythonization for TTree::Branch.
PyObject * AddBranchAttrSyntax(PyObject *self, PyObject *args)
Allow branches to be accessed as attributes of a tree.