So there are two things going on:
TTree::Draw
convertsnan
s to zeros on the fly,RDataFrame
does not – one one handTTree::Draw
’s behavior is nicer, on the other it might silently hide issues in your calculations- ROOT histograms that have been filled with
nan
s cannot be drawn, as you experienced
I guess Electron_dxy
is an array of values, so what we are returning is an array of true/false values.
In that case, you can use RVec’s masking feature instead to discard the non-positive elements before taking the logarithm:
auto zMean = d.Define("logd" , "log(Electron_dxy[Electron_dxy > 0])").Mean("logd");
Cheers,
Enrico