Discussion:
TTree Draw vector size for a subset of vector elements
Clement Helsens
2014-09-10 08:38:26 UTC
Permalink
Dear ROOT support,

that might be an easy question to answer, but I can not find the solution to my problem.
I have a TTree containing a vector of integer: "jetsid : vector<int>"

To draw the size of it I’m simply doing:

truth->Draw("@jetsid.size()")

now, I can not find a way to draw the number of elements of my vector that have a given value, for instance 5 to select b-quarks.

Thanks for the help!
Clement
Suvayu Ali
2014-09-10 11:51:11 UTC
Permalink
Hi Clement,
Post by Clement Helsens
Dear ROOT support,
that might be an easy question to answer, but I can not find the solution to my problem.
I have a TTree containing a vector of integer: "jetsid : vector<int>"
now, I can not find a way to draw the number of elements of my vector that have a given value, for instance 5 to select b-quarks.
Untested suggestion: if I understood TTreeFormula correctly, how about
using Length$(jetsid) as your expression, with jetsid==5 as your
selection cut?

The docs say Length$ returns "number of available instances in the
formula". I understood that as number of matches, after the selection.
Instead if it is number of absolute matches (irrespective of selection),
then the above suggestion will not work.

Hope this helps,
--
Suvayu

Open source is the future. It sets us free.
Philippe Canal
2014-09-10 12:15:04 UTC
Permalink
Hi,

You can do

truth->Draw("Sum$( jetsid == 5 )");

Cheers,
Philippe.
Post by Clement Helsens
Dear ROOT support,
that might be an easy question to answer, but I can not find the solution to my problem.
I have a TTree containing a vector of integer: "jetsid : vector<int>"
now, I can not find a way to draw the number of elements of my vector that have a given value, for instance 5 to select b-quarks.
Thanks for the help!
Clement
Clement Helsens
2014-09-10 12:39:01 UTC
Permalink
thanks!
that works like a charm!

Cheers,
Clement

Le 10 sept. 2014 à 14:15, Philippe Canal <***@fnal.gov<mailto:***@fnal.gov>> a écrit :

Hi,

You can do

truth->Draw("Sum$( jetsid == 5 )");

Cheers,
Philippe.

On 9/10/14 3:38 AM, Clement Helsens wrote:
Dear ROOT support,

that might be an easy question to answer, but I can not find the solution to my problem.
I have a TTree containing a vector of integer: "jetsid : vector<int>"

To draw the size of it I’m simply doing:

truth->Draw("@jetsid.size()")

now, I can not find a way to draw the number of elements of my vector that have a given value, for instance 5 to select b-quarks.

Thanks for the help!
Clement

Loading...