More robust check for chains in a given filter alg
This is to fix a problem encountered with !50856 (closed) in which the the two following chains are in the menu:
- 'HLT_g40_loose_L1eEM24L'
- 'HLT_g40_loose_L1eEM24L_mu40_msonly_L1MU14FCH' The latter requires the explicit 'L1eEM24L' on the first leg to disambiguate the copies seeded by legacy and Phase-I L1Calo RoIs.
In the JSON creation, the test for whether a chain is controlled by a given filter was performed by checking if the chain name was a substring of the filter's chains, because the filter could be checking specific leg IDs ('legXXX_[chainName]'). This leads to problems if one chain's name is a substring of another chain name, as is the case here. The solution is to compare the full names, stripping off the leg prefix if needed.