Use of RDataFrame to make profile plots from one scalar and one vector

I am trying to make profile plots for one scalar (“angle” in my code) and one vector (“correctHits” in my code). I am not sure what is the best way to do this. The code snippet I used is the following:

auto CalcHit = [](ints &bec, ints &clus) {
        auto clusSize = clus;
        return clusSize[bec==0];
auto profile_hit = dCut.Filter("nhit > 0")
                       .Define("correctHits", CalcHit, {"hit_bec", "hit_clusize"})

Here hit_bec and hit_clusize are vectors of int with equal size and ints is just

ROOT::VecOps::RVec <int>

. I intend to make the profile plots of angle and correctHits (hits for which bec==0). When I am running this, I get this error:

Error in <TRint::HandleTermInput()>: std::runtime_error caught: Cannot fill object if the type of the first column is a scalar and the one of the second a container.

What should be the best way to tackle this problem?

Thank you very much,

_ROOT Version: 6.18/04
_Platform: linuxx8664gcc
_Compiler: gcc 7.4.0

Hi @arkasantra,

I think what’s missing is that angle is not a vector, so it’s unclear whether each entry in the profile gets the same angle or a different one. We can tell ROOT explicitly by making angle a vector. Insert a Define like:

Define("angle_broadcast", "return ROOT::VecOps::RVec<double>(correctHits.size(), angle);", {"correctHits", "angle"})

and use angle_broadcast to fill instead of angle.

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