njeong
February 20, 2017, 1:58pm
1
Hello, ROOT Team
Now I am trying to read the variable like this.
{
TChain chain("CollectionTree");
chain.Add("2.root");
TChain* ch;
ch = &chain;
Int_t entries=ch->GetEntries();
cout<<endl;
cout <<"entries: " << entries << endl;
Float_t px;
ch->SetBranchAddress("m_px",&px);
}
However I receive
entries: 2000
Error in <TChain::SetBranchAddress>: unknown branch -> m_px
I mean, I can receive the result “entries” but I can not receive the “px” value.
Help me
Thank you
-Nam
Danilo
February 20, 2017, 2:49pm
2
Hi Nam,
does the tree have a branch called “m_px”?
Cheers,
Danilo
njeong
February 20, 2017, 3:37pm
3
Dear Danilo
Please refer to the image. Could you help me?
-Nam
Danilo
February 20, 2017, 3:46pm
4
Hi,
the branch is then m_genParticles.m_px.
Did you consider using TTreeReader for analysing your chain?
root.cern.ch/doc/master/classTTreeReader.html
Cheers,
D
njeong
February 20, 2017, 4:34pm
5
Dear Danilo
Thank you for your reply.
However it is not working, I received same error:
entries: 2000
Error in <TChain::SetBranchAddress>: unknown branch -> m_genParticles.m_px
Do you have any idea?
-Nam
Danilo
February 20, 2017, 9:35pm
6
Before proceeding, why not moving to TTreeReader?
I did not notice that this is hanging from McEventCollection_p5_GEN_EVENT.
Please go for “McEventCollection_p5_GEN_EVENT.m_genParticles.m_px”.
Cheers,
D
Hi,
Were you able to solve this as I am having the same error?
-meenandm
Danilo
December 5, 2023, 11:04am
9
Hi,
Welcome to the forum!
Could I suggest you open a new thread about the issue you are currently facing? A lot changed in ROOT (for good!) in the last 7y: we’ll be able to support your use case much better!
Cheers,
D