cms-analysis / CombineHarvester

CMSSW package for the creation, editing and analysis of combine datacards and workspaces
cms-analysis.github.io/CombineHarvester/
15 stars 180 forks source link

Regex for rate param matching #249

Closed pkausw closed 1 year ago

pkausw commented 3 years ago

Assume that you want to declare a rateParam par_name in the datacard and want to match it to all processes that end with _CR. A convenient way to this would be to add a line in the datacard stating

par_name    rateParam    *    *_CR    1    [-5,5]

While this is also supported in text2workspace.py, this will not work in the current version of the CombineHarvester. This is due to the fact that the code explicitly checks the current process name against * or a full match. I doesn't allow for wildcard expressions beyond an explicit *.

This pull request changes the matching to a boost::regex matching. The expressions of the line above for the bins and the processes are first prepared as inputs for boost::regex to avoid crashes. Afterwards, the current bin/process is matched to the regex expression

pkausw commented 2 years ago

Hi @ajgilbert , sorry for my extraordinarily long reaction time! Thanks for reviewing the PR. I'm happy to change the behavior that you pointed out in the code snippets; I'll continue the discussion in the corresponding code snippets.

ajgilbert commented 1 year ago

This was already addressed in #240, so closing this PR.