Please explain `isptr` usage in `TTree::SetBranchAddress`

I would like to understand some of ROOTs internal code (trying to debug our TTree usage).

I think, the TTree::SetBranchAddress(name, T*) overload will finally call this code:

Int_t TTree::SetBranchAddress(const char* bname, void* addr, TBranch** ptr, TClass* ptrClass, EDataType datatype, Bool_t isptr)
   Int_t res = CheckBranchAddressType(branch, ptrClass, datatype, isptr);

I think, it will be called with isptr=false.

I think, that isptr will be true for the T** interface. So this actually makes a difference.

All that said, I wonder why isptr is only passed to CheckBranchAddressType but not to SetBranchAddressImp?
And SetBranchAddressImp doesn’t look to me like it magically knows the difference.

Can someone please help me understand this code?

ROOT Version: Current master tree as on Github.

P.S.: I would have posted proper links to github, but it looks like new users can’t post any links.

Yes, this boolean full name is more akin 'user-passed-pointer-to-pointer-value`.

I wonder why isptr is only passed to CheckBranchAddressType

CheckBranchAddressType job is to indicates whether the value’s type is corresponding to the content of the branch. If it notices that the value of isptr is not (yet) supported for the type of the branch, it will ‘reject’ it.

And indeed currently the type of the branch dictates whether you need to pass a pointer to pointer (eg for branch holding objects) or a pointer to value (for branch holding numerical types).

1 Like