I’ve ran into a problem when I was converting my analysis code to RDataFrame. In my code I have a branch named “weight” both in the input and the output tree with the latter being a modified version of the former:
outputTree = TTree(treeName, '')
weight = array('d',[0])
outputTree.Branch("weight", weight, "weight/D")
for event in inputTree:
weight[0] = event.weight * datasetWeight
outputTree.Fill()
Is there a way to achieve the same result with RDataFrame? I thought of making an intermediate column for the modified weights, deleting the original “weight” column and than copying the intermediate values to new “weight” column, but I didn’t find a way to delete an existing column.
I think rdf implements a zero copy policy. modifying in place your weights read through an rvec or as a string (which uses internally rvecs) could well do the job even if I dislike the solution and am sure rdf will allow something better soon
I’ve found a workaround for how to change the name of the branch: make a column “weightModified”, snapshot it, open the file and then use TTree::SetAlias
tree.SetAlias('weight', 'weightModified')
But now the problem is to use the Python variable to multiply the weight in the ‘Define’ statement. The following code