Changing the values in the branch

I need to change the data values in the branch: a given number needs to be subtracted from each numeric value. How can this be implemented?

_ROOT Version: 6.26/10
_Platform: pycharm community
Compiler: Not Provided


This cannot be done.

  • You could apply your “fixes” when you actually analyze the data (e.g., define some alias “corrected_branch = original_branch - corerection_value” and then use the “corrected_branch” in the analysis).
  • You could “copy” your tree to another file, modifying its entries on the fly.
  • You could create a “friend tree” with new branches.
  • You could add new branches to the existing tree.

Alright.
If i copy my file, how can i change the data of branch?

@eguiraud Maybe some RDataFrame expert can help in creating a Snapshot with “recomputed” branches.

Hi, you can use Redefine+Snapshot for that. You can find the docs at ROOT: ROOT::RDataFrame Class Reference .

For example

ROOT::RDataFrame("tree", "file.root").Redefine("x", "x*0.9").Snapshot("newtree", "newfile.root");

will write out the contents of the original tree in a new tree and with x rescaled by a factor 0.9.

Cheers,
Enrico

TypeError: Template method resolution failed:
none of the 3 overloaded methods succeeded. Full details:
TypeError: takes at least 3 arguments (2 given)
TypeError: takes at least 3 arguments (2 given)
runtime_error: Unknown column: size
runtime_error: Unknown column: size

There is a “size” columns being used somewhere that RDF does not recognize. Feel free to share a minimal self-contained reproducer that I can take a look at.

Cheers,
Enrico

It turns out that the desired column “Channel0” is located inside a branch with the same name.

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