# Draft: Educated prescaling for RICH1 and RICH2 alignment optimization

Software alignment of the RICH1 and RICH2 optical systems by the use of data, suffers from extremely uneven -- between central and peripheral mirrors -- population with Cherenkov photons. The difference is about five orders of magnitude for the minbias events. That causes huge redundancy in the number of events needed to populate sufficiently the peripheral mirrors. To mitigate that, a highly depleted subset of events that populate central areas with Cherenkov photons at approximately the same density as the peripheral ones, needs to be preselected by the HLT1 lines.

Because reconstruction of photons at the HLT1 level is not feasible, due to the performance limitations, a certain "dictionary", in terms of the tracks' kinematics, rather than in terms of photon numbers, needs to be used in HLT1, to make the event selection decisions.

This MR is dedicated to making use of the arrays, prepared in advance, aka "dictionaries", of the spatial angular intervals for the tracks, in the corresponding RICH1 and RICH2 prescaling lines. The "key" here is the ordinal number of the particular angular interval, and the "value" is the value of the element. The meaning of the magnitude of an element is its interval's "weight", which is compared to the random number in (0, 1] interval.

The logic is to select the event if it has at least one track hitting at least one such angular interval, and the decision is positive if the random number is less than the "weight" of that interval. In other words, intervals that are responsible for population of the "central" areas have very small wights, and therefore, the corresponding events are selected very rarely. In contrast, intervals with weights close to 1, are hit very rarely, but such events are always selected.

The weights are calibrated in advance, in such a way (omitting some subtle details), that a fairly even population of the mirrors is ensured, at a minimum number of events to be processed in the full HLT2 reconstruction of events, including reconstruction of the Cherenkov photons.

The mechanism is a principal extension of the so-called random prescaling, in that the decision, based on a dictionary of weights, is taken randomly. Hence -- "educated random prescaling". Specifically, the already existing deterministic quasi-random number generation algorithm is used (`DeterministicScaler`

).

Closes #166.