# Sum of a RVec\<bool\> \[RDataFrame\]

**URL:** <https://root-forum.cern.ch/t/sum-of-a-rvec-bool-rdataframe/51096>\
**Category:** Newbie\
**Tags:** rdataframe, python, root\
**Created:** [August 7, 2022, 5:49pm UTC](https://root-forum.cern.ch/t/sum-of-a-rvec-bool-rdataframe/51096 "2022-08-07T17:49:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daumann](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@Daumann](https://root-forum.cern.ch/u/Daumann)\
**Post date:** [August 7, 2022, 5:49pm UTC](https://root-forum.cern.ch/t/sum-of-a-rvec-bool-rdataframe/51096/1 "2022-08-07T17:49:49Z")

</div>

Dear root experts,

I want to make some plots in a no b-tag region of my phase space. I am reading a ‘Jet\_btag’ vector from my ntuples, which has the type ‘ROOT::VecOps::RVec’. This vector has a boolean entry for each jet in the event, which is 1 if the jet is btagged and 0 otherwise. So, I would like to sum the elements of this array and filter just the events where this sum is 0. I tried some things like:

`df = df.Filter("Jet_btag.Sum() == 0 ", "No b-jet region")`

But it looks like there is no such thing for RVec arrays. And i didn’t found anything like in the documentation. I also tried to convert the array to a numpy array, as its done here → [https://root.cern/doc/master/classROOT\_1\_1VecOps\_1\_1RVec.html:](https://root.cern/doc/master/classROOT_1_1VecOps_1_1RVec.html:)

df = df.Filter("nump.sum(numpy.asarray(Jet\_btag)) == 0 ", “No b-jet region”)

But i get the error:

```auto
input_line_177:2:8: error: use of undeclared identifier 'numpy'

```

So, there is a way to do this directly inside the df.Filter() ?

Cherrs,

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 7, 2022, 9:15pm UTC](https://root-forum.cern.ch/t/sum-of-a-rvec-bool-rdataframe/51096/2 "2022-08-07T21:15:25Z")

</div>

Hi @Daumann ,

in the RVec reference guide ([ROOT: ROOT::VecOps::RVec\< T \> Class Template Reference](https://root.cern/doc/master/classROOT_1_1VecOps_1_1RVec.html)) there is a section titled [Reference for RVec helper functions](https://root.cern/doc/master/namespaceROOT_1_1VecOps.html). There you can see all RVec helper functions – there is one called `Sum`: `df = df.Filter("Sum(Jet_btag) == 0 ", "No b-jet region")`.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![Daumann](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@Daumann](https://root-forum.cern.ch/u/Daumann)\
**Post date:** [August 8, 2022, 6:12pm UTC](https://root-forum.cern.ch/t/sum-of-a-rvec-bool-rdataframe/51096/3 "2022-08-08T18:12:15Z")

</div>

Worked wonderfully, Thanks @eguiraud!
