Skip to content

Allowing Redefine inside modules

Jaime Leon Holgado requested to merge feature/Redefine into py3

RDataFrame doesn't allow to Define a variable whose name is already in the RDataFrame. If the variable needs to be redefine, the Redefine method can be used. However, this method doesn't work if the variable hasn't been previously defined (i.e. Redefine != Define + Redefinition if needed).

This MR creates a new inner class inside RDFModuleTask, RDataFrame, that contains a ROOT.RDataFrame inside. When using this class instead of ROOT.RDataFrame, Define works as in ROOT.RDataFrame if the variable doesn't exist. If it does, the new class will call the ROOT.RDataFrame.Redefine method instead only if RDFModuleTask's allow_redefinition = True (if not, it will raise a ValueError).

Bad news though, the Redefine method is NOT defined in the ROOT version used in the present CMSSW version considered. In CMSSW_13_0_13 (target release for future upgrades, since it allows both centos7 and almalinux9), it does. In any case, the new class should be transparent to CMSSW_12_3_0_pre6, so no change in behaviour is expected if running on this CMSSW version.

Merge request reports