Add helper script to produce LumiSummary scheme
The upcoming change to the LumiSummary banks will load the layout of counters within the bank from the TCK in JSON format. This helper script produces an optimised JSON representation for a given collection of luminosity counters. Input files should contain one counter per line formatted as "CounterName MaxEntries", where the name may not contain white space and MaxEntries is the maximum value that the counter should be expected to contain.
As multiple counters may be packed into a single 32-bit integer and counters may not overrun between two integers, the packing order of the counters must be optimised. The script initially implements a "first-fit decreasing" algorithm where counters are considered in descending size order and placed into the first available slot (adding an extra int
if necessary).
The script attempts to further optimise the schema by randomly removing a subset of the smaller counters (<16bits) and reinserting then in a random order. Such mutations are retained only if they reduce the number of int
s required to store the counters. A schema where all of the words contain a 16-bit or larger counter cannot be further optimised so the optimisation should be skipped in such cases. The optimisation is repeated a configurable number of times until a configurable packing efficiency is achieved.