# RDataframe type conversion error

**URL:** <https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [July 22, 2020, 1:33pm UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569 "2020-07-22T13:33:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SiewYan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/siewyan/32/20273_2.png) [@SiewYan](https://root-forum.cern.ch/u/SiewYan)\
**Post date:** [July 22, 2020, 1:33pm UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/1 "2020-07-22T13:33:15Z")

</div>

Hello root expert,

I am trying define a new column for my RDataframe

df.Define( ‘Test’, ‘TMath::Exp(Sum(TMath::Log((CleanJet\_pt\>20 && abs(CleanJet\_eta)\<2.5) \* Jet\_btagSF\_shape[CleanJet\_jetIdx]+1 \* (CleanJet\_pt\<20 || abs(CleanJet\_eta)\>2.5))))’ )

and i am getting

input\_line\_150:5:34: error: no viable conversion from ‘RVec\<decltype(v0[0] + v1[0])\>’ (aka ‘RVec’) to ‘Double\_t’ (aka ‘double’)  
return TMath::Exp(Sum(TMath::Log((CleanJet\_pt\>20 && abs(CleanJet\_eta)\<2.5)_Jet\_btagSF\_shape[CleanJet\_jetIdx]+1_(CleanJet\_pt\<20 || abs(CleanJet\_eta)\>2.5))))  
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
/home/shoh/anaconda3/envs/gen/include/ROOT/RVec.hxx:343:4: note: candidate template ignored: could not match ‘RVec’ against ‘double’  
operator RVec() const  
^  
/home/shoh/anaconda3/envs/gen/include/TMath.h:750:37: note: passing argument to parameter ‘x’ here  
inline Double\_t TMath::Log(Double\_t x)

Looks like there is a conversion error , any idea how to solve this?? I am new to RDataframe…  
Thanks!

Cheers,  
Siewyan

\_ROOT Version: 6.20/02  
\_Platform: Ubuntu 18.04  
\_Compiler: gcc 7.5.0

---

<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:** [July 22, 2020, 2:12pm UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/2 "2020-07-22T14:12:45Z")

</div>

Hi @SiewYan,  
the error message means you are calling `TMath::Log` (a function that takes a `double`) with an argument that is an `RVec` (i.e. a vector). I guess your `CleanJet_pt` column is an array and not a single double?

Changing `TMath::Log` to `log` might solve the error. `TMath::Exp` will probably have the same issue.

RDataFrame reads arrays as RVecs, more information on RVec is available [here](https://root.cern/doc/master/classROOT_1_1VecOps_1_1RVec.html) and at “Reading and manipulating collections” in the [RDataFrame user guide](https://root.cern.ch/doc/master/classROOT_1_1RDataFrame.html).

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![SiewYan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/siewyan/32/20273_2.png) [@SiewYan](https://root-forum.cern.ch/u/SiewYan)\
**Post date:** [July 23, 2020, 10:27am UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/3 "2020-07-23T10:27:30Z")

</div>

Hi @eguiraud, thanks for the hints, i manage to make it run!

However, I have a general condition in my cuts, ‘Jet\_btagDeepB[CleanJet\_jetIdx] \> 0.1522’ in my definition of column. While i run with it and do

hf.Histo1D(“test” ).GetPtr()

I got an error : runtime\_error: Cannot index RVec with condition vector of different size

By specifying the index of CleanJet\_jetIdx i manage to solve it. However, is there a way to use it without specifying the index since the code is meant to run on inclusive ntuple.

Thanks again!  
Cheers,  
Siewyan

---

<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:** [July 23, 2020, 10:31am UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/4 "2020-07-23T10:31:18Z")

</div>

> [@SiewYan](#):
>
> runtime\_error: Cannot index RVec with condition vector of different size

This means that for some events `Jet_btagDeepB` has a different size than `CleanJet_jetIdx`. In that case, `Jet_btagDeepB[CleanJet_jetIdx]` is ill-formed.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![SiewYan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/siewyan/32/20273_2.png) [@SiewYan](https://root-forum.cern.ch/u/SiewYan)\
**Post date:** [July 23, 2020, 10:48am UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/5 "2020-07-23T10:48:29Z")

</div>

Thanks again! It make sense now.

Cheers,  
Siewyan

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 6, 2020, 10:48am UTC](https://root-forum.cern.ch/t/rdataframe-type-conversion-error/40569/6 "2020-08-06T10:48:30Z")

</div>

Closed on August 6, 2020, 10:48am UTC

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