Reassign the RooFormulaVar from RooWorkspace

Dear experts,

I have a very complicated simultaneous pdf, that has a multicategory based on year (4), mass bin (6), and trigger decision (2).

One RooFormulaVar has to be shared between two years while being separate from the remaining 2 years.
I get the pdf from RooWorkspace already split into the years category, so I thought I can quickly hack into it by using the RooCustomizer functionality.

Basically, I have this in my RooWorkspace:

RooFormulaVar::FitConfig_OS_TagDilutionPlus[ actualVars=(OS_Combination_DEC,FitConfig_OS_calibratedMistagB) formula="1.0+@0*(1.0-2.0*@1)" ] = 1.7285

RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}[ actualVars=(OS_Combination_DEC,FitConfig_OS_calibratedMistagB_{bin0;p2015;biased}) formula="1.0+@0*(1.0-2.0*@1)" ] = 1.7285

And I want this

RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}[ actualVars=(OS_Combination_DEC,FitConfig_OS_calibratedMistagB_{bin0;p2015;biased}) formula="1.0+@0*(1.0-2.0*@1)" ] = 1.7285

to be

RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}[ actualVars=(OS_Combination_DEC,FitConfig_OS_calibratedMistagB_{bin0;p2016;biased}) formula="1.0+@0*(1.0-2.0*@1)" ] = 1.7285 

So I did the following (ws is the RooWorkspace I have):

ws.RecursiveRemove(ws.arg('RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}'))
ws.factory("EDIT::RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}(RooFormulaVar::FitConfig_OS_TagDilutionPlus, FitConfig_OS_calibratedMistagB = FitConfig_OS_calibratedMistagB_{bin0;p2016;biased})")

I am not sure it is valid as I can not even get past this error:

[#0] ERROR:ObjectHandling -- RooFactoryWSTool::processSingleExpression(EDIT::RooFormulaVar::FitConfig_OS_TagDilutionPlus_{bin0;p2015;biased}(RooFormulaVar::FitConfig_OS_TagDilutionPlus, FitConfig_OS_calibratedMistagB = FitConfig_OS_calibratedMistagB_{bin0;p2016;biased})) : ERROR: Syntax error: Class::Instance must be followed by (...)
[#0] ERROR:ObjectHandling -- RooFactoryWSTool::processExpression() ERRORS detected, transaction to workspace aborted, no objects committed

Maybe this is not the best approach or maybe there is a way to merge categories for one parameter after the RooWorkspace is created. In any way, if you have any idea how I could achieve the goal of changing part of the RooWorkspace to make sure that one of the parameters is not shared between the year, I would be very grateful.

Maybe @jonas can help here?

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