Problem with SetBranchStatus to deselect a branch

Hi,

I have two branches “br” and “brCut” inside a tree name “tree”. In the root file, order of the branch is first “br” and then “brCut”. I want to scan (or draw) a variable “mag” from the “brCut”. My sample code is:

TChain *chain = new TChain("tree");
chain->Add("*.root");
chain->SetBranchStatus("br", 0);
chain->SetBranchStatus("brCut", 1);

chain->Scan("mag");

Error is:

Error in <TTreeFormula::DefinedVariable>: the branch "br" has to be enabled to be used
Error in <TTreeFormula::Compile>:  Part of the Variable "mag" exists but some of it is not accessible or useable

It looks like, it tries to find the first branch by default unless it is written explicitly as
"chain->Scan(“brCut.mag”)".
Any suggestion? :question:

Thanks.

Hi,

I don’t know what the tree looks like (you could show the output of chain->Print()), but I’d guess there is a br.mag that will be used if you don’t specify brCut.mag?

Cheers, Axel.