When I try to create a Histo1D using event weights, I get a segfault.
However, if I don’t use event weight there’s no crash. Is there a way to get around the problem? The tree with floats is provided by the experiment, so I can’t remake the trees with doubles.
relevant error message might be:
/home/suyong/work/Tools/root-6.15/etc/…/include/ROOT/RDF/ActionHelpers.hxx:259:9: note: candidate function not viable: no known conversion from ‘ROOT::VecOps::RVec’ to ‘double’ for 2nd argument
void Exec(unsigned int slot, double x0, double x1) // 1D weighted and 2D histos
_ROOT Version: 6.15.01
_Platform: Linux
_Compiler: gcc 6.4.1
Hi Suyong,
could it be that the problem is that "Sel2_jetpt" is a single double and "evWeight" is an array?
Cheers,
Enrico
edit:
if yes, the issue is that RDF can’t deal with this case. If what you intended was to weight the single "Sel2_jetpt" value with each of the weights in "evWeight", you can do it with df.Define("weighted_jetpt", "Sel2_jetpt*evWeight").Histo1D(...) (because in the DefineevWeight is read as an RVec which allows element-by-element multiplication by a scalar
Actually, “Sel2_jetpt” is a vector of floats (not doubles) and “evWeight” is a single number per event. What I wanted is what I would do in C++ as
for (auto i=0; i<Sel2_jetpt.size(); i++)
{
hjetpt->Fill(Sel2_jetpt[i], evWeight);
}
I was thinking the error occurred because Sel2_jetpt is vector of floats rather than doubles.
the workaround should not be needed any more when using the master and 6.16 patches branch since the support of filling with iterable column values with scalar weights has been implemented (https://sft.its.cern.ch/jira/browse/ROOT-9985). This feature will be part of ROOT 6.18 and 6.16/02.