RDataframe type conversion error

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…


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

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 and at “Reading and manipulating collections” in the RDataFrame user guide.


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!

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.


1 Like

Thanks again! It make sense now.


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