Discussion:
Help with TTree::SetBranchAddress
Andrés Vargas
2013-03-16 21:34:42 UTC
Permalink
Hi,

I've read a TTree object from a root file, I can run things like
T->Scan("Parent1.Px:Parent2.Px:Parent3.Px") without problem (i.e I can
read the data for this variables), but when I ran
T->SetBranchAddres("Parent1.Px",&p1px) I obtained this error:

Error in <TTree::SetBranchAddress>: unknown branch -> Parent1.Px

when I ran T->GetListOfBranches()->FindObject("Parent1.Px"):
(const class TObject*)0x0
Bad!
when I ran T->GetListOfLeaves()->FindObject("Parent1.Px"):
(const class TObject*)0x0
Again Bad!
when I ran T->GetListOfBranches()->FindObject("Parent1");
(const class TObject*)0x24f4c00
it is right ok?
but, when I ran T->GetListOfLeaves()->FindObject("Px"):
(const class TObject*)0x24f5af0
what is this??

I have to read data from Parent1.Px, what can I do?

Thanks in advance,

Andrés,
J.P. Araque
2013-03-17 00:21:56 UTC
Permalink
Hello Andrés,

it seems that you TTree has TLorentzVectors as branches. You can set the
address to the branch but not to the method of one object of the branch.
For example, you can create a TLorentzVector p1 which will be the branch of
the tree and the call the Px method.

Youc an verify this see what branches you have inside the tree. Go into the
root interpreter openning the root file and use the MakeClass method in the
tree. If the TTree name is "tree" you can do tree->MakeClass(). It will
generate two files: tree.h tree.C. In the header file you will se all the
declaration it has for each tree and each type.

Cheers,
Juanpe.


On Sat, Mar 16, 2013 at 10:34 PM, Andrés Vargas <
Post by Andrés Vargas
Hi,
I've read a TTree object from a root file, I can run things like
T->Scan("Parent1.Px:Parent2.Px:Parent3.Px") without problem (i.e I can
read the data for this variables), but when I ran
Error in <TTree::SetBranchAddress>: unknown branch -> Parent1.Px
(const class TObject*)0x0
Bad!
(const class TObject*)0x0
Again Bad!
when I ran T->GetListOfBranches()->FindObject("Parent1");
(const class TObject*)0x24f4c00
it is right ok?
(const class TObject*)0x24f5af0
what is this??
I have to read data from Parent1.Px, what can I do?
Thanks in advance,
Andrés,
--
*Juan Pedro Araque Espinosa*
LIP-Minho
----------------------------------------------
TLF: +351-964640378
E-Mail: ***@cern.ch
Andrés Vargas
2013-03-17 00:57:53 UTC
Permalink
Hello Juanpe,

I have made T->MakeClass(), but it seems that there is no
TLorentzVectors as branches, look at this:

$cat T.h|grep TLorentzVetor
(Returns nothing)
But, $cat T.h|grep TBranches
returns (List of Branches):
TBranch *b_f_Parent1; //!
TBranch *b_f_Parent2; //!
TBranch *b_f_Parent3; //!
and, $cat t.h|grep Px
returns (Declaration of leaf types):
Float_t f_Parent1_Px;
Float_t f_Parent1_PxCor;
Float_t f_Parent2_Px;
Float_t f_Parent2_PxCor;
...

(please replace Parent1 by f_Parent1 in my previous message)

this is the output of T->GetListOfBranches()->Print():
https://pastee.org/t6b2a

Thank you,

Andrés,
Philippe Canal
2013-03-18 12:40:57 UTC
Permalink
Hi André,

What is the result on the screen of T->Print()

Philippe.
Post by Andrés Vargas
Hi,
I've read a TTree object from a root file, I can run things like
T->Scan("Parent1.Px:Parent2.Px:Parent3.Px") without problem (i.e I can
read the data for this variables), but when I ran
Error in <TTree::SetBranchAddress>: unknown branch -> Parent1.Px
(const class TObject*)0x0
Bad!
(const class TObject*)0x0
Again Bad!
when I ran T->GetListOfBranches()->FindObject("Parent1");
(const class TObject*)0x24f4c00
it is right ok?
(const class TObject*)0x24f5af0
what is this??
I have to read data from Parent1.Px, what can I do?
Thanks in advance,
Andrés,
Andrés,
2013-03-18 14:50:24 UTC
Permalink
Hi Philippe,

here is the output of T->Print():
https://pastee.org/4xqnu

Maybe this image can help:
Loading Image...

I've solved my problem with other method, but I'm still interested in
why I can not call T->SetBranchAddress("Parent.Px",&Px).

Thanks in Advance,
Andrés,
Philippe Canal
2013-03-18 15:12:45 UTC
Permalink
Hi Andrés,

The branches in this file have been created using a leaf list rather than objects (i.e. there
is *no* TLorentzVector per se.) When creating the branch as a leaf list, all the data from
each branch must be retrieved together and thus the address of the whole branch
(MakeClass achieve this by carefully reserving memory for all the element of the branch
and setting the branch address to the address of the first one).

Cheers,
Philippe.
Post by Andrés,
Hi Philippe,
https://pastee.org/4xqnu
http://picpaste.com/pics/Screenshot_from_2013-03-17_13_43_23-wxK6p4rc.1363618008.png
I've solved my problem with other method, but I'm still interested in
why I can not call T->SetBranchAddress("Parent.Px",&Px).
Thanks in Advance,
Andrés,
Loading...