SetBranchAddress

Hi,
I need to perform the following operation to get the “Wanted Value” much faster than this example:

       TH1D* myhisto = new TH1D("myhisto", "myhisto", 1, 0, 100);          
       TString mySelector = "channel==" + mychannel;
       myTree->Draw("mybranch>>myhisto", mySelector);
       cout << "Wanted value is = " << myhisto->GetMean();

I already know that myhisto contains only one value because the Branch is filtered with mySelector so, I expect just one value.
I think the “wanted value” could be more directly accessed via SetBranchAddress, but how to use the TCut?

p.s. mybranch is also a vector

ROOT Version: 6
Platform: lxplus
Compiler: Not Provided


Hi @stefano.tettolo,

Yes, you should be able to manually iterate over the entries in a TTree and get the value in a branch provided that another branch matches a criteria.
Please, refer to Trees - ROOT as a starting point on how to iterate over TTree entries.

Cheers,
J.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.