_ROOT Version: 6.22 to 6.24
_Platform: Centos7
_Compiler: gcc8
Dear all,
I would need to understand why a code like the one below does not work. The guilty seems to be the “Map” method (the code runs fine without that instruction). Am I doing anything wrong? Note that df.Report().Print() line is there just to trigger the event loop. Any other equivalent instruction triggering the loop leads to the same error.
Thanks in advance, Juan
###// Python script begins ##########
import ROOT
import array
#/ Create a trivial tree with just one entry with two muons
hfile = ROOT.TFile(“myfile.root”,“RECREATE”)
tree = ROOT.TTree(“events”,“My trivial tree”)
px = array.array(‘f’, [ 10., -10. ])
py = array.array(‘f’, [ 20., -20. ])
pz = array.array(‘f’, [ 30., -30. ])
mass = array.array(‘f’, [ 0.106, 0.106 ])
tree.Branch(‘Muon_px’, px, ‘Muon_px[2]/F’)
tree.Branch(‘Muon_py’, py, ‘Muon_py[2]/F’)
tree.Branch(‘Muon_pz’, pz, ‘Muon_pz[2]/F’)
tree.Branch(‘Muon_mass’, mass, ‘Muon_mass[2]/F’)
tree.Fill()
hfile.Write()
hfile.Close()
#/ Reopen file and use the tree that we have just created
df = ROOT.RDataFrame(“events”,“myfile.root”)
#/ Muon_px, Muon_py, Muon_pz, Muon_mass are already present in the tree, vectors of floats
df = df.Define(“Muon_p4”,“ROOT::VecOps::Construct<ROOT::Math::PxPyPzMVector>(Muon_px, Muon_py, Muon_pz, Muon_mass)”)
df = df.Define(“Muon_theta”,“ROOT::VecOps::Map(Muon_p4,[](ROOT::Math::PxPyPzMVector x){return x.Theta();})”)
df.Report().Print()
###// Python script ends
The error starts with:
In module ‘std’ imported from input_line_1:1:
/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/…/lib/gcc/x86_64-pc-linux-gnu/8.3.0/…/…/…/…/include/c++/8.3.0/ext/alloc_traits.h:64:23: error: cannot form a reference to ‘void’
typedef value_type& reference;
…Preformatted text