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

**URL:** <https://root-forum.cern.ch/t/please-explain-isptr-usage-in-ttree-setbranchaddress/53571>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [February 10, 2023, 2:56pm UTC](https://root-forum.cern.ch/t/please-explain-isptr-usage-in-ttree-setbranchaddress/53571 "2023-02-10T14:56:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctacke](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ctacke/32/32430_2.png) [@ctacke](https://root-forum.cern.ch/u/ctacke)\
**Post date:** [February 10, 2023, 2:56pm UTC](https://root-forum.cern.ch/t/please-explain-isptr-usage-in-ttree-setbranchaddress/53571/1 "2023-02-10T14:56:16Z")

</div>

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:

```cpp
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);
…
      SetBranchAddressImp(branch,addr,ptr);

```

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.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [February 10, 2023, 5:03pm UTC](https://root-forum.cern.ch/t/please-explain-isptr-usage-in-ttree-setbranchaddress/53571/2 "2023-02-10T17:03:52Z")

</div>

> [@ctacke](#):
>
> I think, it will be called with `isptr=false`.

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).
