CollectionTree Issue

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 :smiley:

Thank you

-Nam

Hi Nam,

does the tree have a branch called “m_px”?

Cheers,
Danilo

Dear Danilo

Please refer to the image. Could you help me?

-Nam


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

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

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