[ROOT] Re: Bool Selection in Tree [Was: I am not clear on to use booleans]

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Aug 11 2001 - 10:43:24 MEST


Hi Chris,

It turns out that Boolean variables must be assigned the type "b" and not
"B".
If you do not want to recreate your tree, you can do the following
  TLeaf *leaf = ntp100->GetLeaf("ispMicroLoose");
  leaf->SetUnsigned();

You can set this attribute permanent on the file if you open the file
in "update" mode and do:
  ntp100->Write();
after having changed the leaf attribute.

Rene Brun


On Fri, 10 Aug 2001, Chris Roat wrote:

> I am using 3.00-06 on a Pentium machine running RedHat 7.1.
> 
> Your example works for me.  Thank you.
> 
> I've attached the root file I'm using.  Perhaps you can tell me how it
> might have been generated wrong?  The boolean variable in question is
> ispMicroLoose in the tree ntp100.
> 
> The difference I see is the substitution of /B (my tree) for /b (your
> tree) in the branch title.  I can change the tree by getting the branch
> and using SetTitle on it to change /B to /b.  I still have the same
> problem.
> 
> To summarize, the second command below actually selects MORE events
> than the first, even though additional cuts are applied.  It seems to
> ignore ispMicroLoose.
> 
> mytree->Draw("p", "ispMicroLoose")
> mytree->Draw("p", "p>0&&ispMicroLoose")
> 
> Thanks,
> Chris
> 
> 
> 
> 
> *** Today, you (Rene Brun) wrote ***
> 
> | Hi Chris,
> |
> | I do not see any problems with booleans. In the attachment you will
> | find a variant of the standard tutorial tree1.C with a boolean variable.
> | You can play with it with the type of selection in your mail.
> |
> | I take once more this opportunity to request that:
> |   - the ROOT version number and the machine be specified in the mail
> |   - also always specify a subject in the mail. This facilitates the archiving
> |     and the search.
> |
> | Rene Brun
> |
> | Chris Roat wrote:
> | >
> | > Hello Rooters,
> | >
> | > I am not clear on to use booleans work in complex (>1 cut) selection
> | > expressions.  For instance, if I have a tree with 2 floats, floatA and
> | > floatB, and a bool, boolA, I try the following 4 cases.
> | >
> | > Note: In my tree, all floatB's are greater than zero.  The cut is included
> | > to illustrate my problem.  boolA's are both true and false.
> | >
> | > a) tree->Draw("floatA", "floatB>0")
> | > b) tree->Draw("floatA", "boolA")
> | > c) tree->Draw("floatA", "(floatB>0)&&(boolA)")
> | > d) tree->Draw("floatA", "(floatB>0)*(boolA)")
> | >
> | > As expected, a) produces a plot of the full tree.
> | >
> | > As expected, b) produces a plot of the tree subset where bool is true.
> | >
> | > NOT as expected, c) & d) produced a plot of the whole tree.  Somehow my
> | > bool test is not included in the selection criteria.
> | >
> | > What am I doing incorrectly?
> | >
> | > Thanks for your help,
> | > Chris
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET