Fast kernel methods for Data Quality Monitoring as a goodness-of-fit test

We here propose a machine learning approach for monitoring particle detectors in real-time. The goal is to assess the compatibility of incoming experimental data with a reference dataset, characterising the data behaviour under normal circumstances, via a likelihood-ratio hypothesis test. The model is based on a modern implementation of kernel methods, nonparametric algorithms that can learn any continuous function given enough data. The resulting approach is efficient and agnostic to the type of anomaly that may be present in the data. Our study demonstrates the effectiveness of this strategy on multivariate data from drift tube chamber muon detectors.


Introduction
Modern high-energy physics experiments operating at colliders are extremely sophisticated devices consisting of millions of sensors sampled every few nanoseconds, producing an enormous throughput of complex data.Several types of technologies are employed, devoted to identifying and measuring the particles that originated in the collisions; in all cases, the environmental conditions are severe, making the required performances challenging to achieve.Although the various subsystems are designed to offer redundancy, measurements can be undermined by malfunctions of parts of the experiment, either because of critical inefficiencies or because of possibly misinterpreted spurious signals.In addition to supervising the status (powering, electronic configuration, temperature, etc.) of the various hardware components, data from all sources must thus be monitored continuously to assess their quality and to promptly detect any faults, possibly providing indications about their causes.Given the rate of tens of MHz at which data is gathered and the number of sensors to be checked, the monitoring process needs to be as automated as possible: approaches based on Machine Learning (ML) techniques are particularly suited for this task and have started being employed by the experimental collaborations [1][2][3][4], complementing more traditional methods [5][6][7][8][9].Data quality monitoring (DQM) consists, in essence, of comparing batches of data with corresponding reference samples gathered in nominal conditions; departures from the latter can then be analysed to identify their origin.The data processing must fit the computational constraints imposed by the frequency at which batches are delivered and by their size, with the latter depending on the granularity with which sensors are grouped and the statistical uncertainty aimed at.
In this work, we present the application of a methodology developed in the context of model-independent searches for new physics [10][11][12]-specifically of its kernel methods implementation [13] based on the Falkon [14] library-as an efficient and effective DQM tool.The method (dubbed NPLM) implements a hypothesis test leveraging the ability of classifiers to infer the underlying data-generating distributions in order to estimate the likelihood ratio test statistic.The Falkon-based implementation of NPLM offers tremendous advantages in terms of training time compared to the one based on neural networks.It can thus be used for DQM.
Conventional DQM methods typically consider a number of one-dimensional distributions; a key feature of NPLM is the capability of examining the phase space as a whole, not depending critically on the choice of input variables and being sensitive to their correlation.It is then possible to provide low-level quantities to the algorithm that require limited pre-processing.This can be particularly advantageous for DQM, as it allows it to deal with almost raw data from the detectors' electronic front-ends, therefore limiting the bias introduced by further manipulations that could hide issues in the data.
To test the effectiveness of NPLM for DQM, we exploit an experimental setup which we have full control of, consisting of a reduced-size version of the muon chambers installed in the CMS experiment at the Large Hadron Collider (LHC).The setup is operated as a cosmic muon telescope.As explained later, scaling tests are performed to assess the performances of the DQM algorithm in view of its possible deployment during standard LHC operations.
The paper is organised as follows.In the next section, we introduce the experimental setup and the algorithm input variables.These include a reference data set collected under standard conditions and smaller samples with anomalous controlled behaviours.The ML model and our core strategy are then described in Section 3, whereas an overview of the results is given in Section 4. Finally, the last section is devoted to conclusions and further developments.

Experimental setup
For this research, we exploited an experimental apparatus consisting of a set of Drift Tube (DT) chambers housed at the Legnaro INFN National Laboratory (Fig. 1, left).These chambers are a smaller in size copy of those deployed in the CMS experiment at the LHC [15].The basic element of a DT chamber is a 70 cm long tube with a cross section of 4 × 2.1 cm 2 (Fig. 1, bottom right).Inside each tube, an electric field is produced by an anodic wire laid in the centre and two cathodic strips (cathodes) on the sides; the former is set at a voltage of 3.6 kV, the latter at −1.2 kV.An additional pair of strips at 1.8 kV is placed above and below the wire to improve the homogeneity of the field.The tubes are filled with a mixture of argon and carbon dioxide gas (85%-15%) that gets ionised by charged particles passing through it.The produced electrons drift towards the wire at a constant velocity along the field lines, where they are collected.For each tube, the front-end electronics record the arrival time of the ions, amplify the signal, and filter out noise below a specific threshold (nominally 100 mV).
A drift tube chamber consists of 64 tubes arranged in four layers of 16 tubes each.The layers are staggered horizontally by half a cell.The setup at Legnaro records muons from cosmic rays, which occur at a rate of about 1 per minute per cm 2 at sea level.Data acquisition occurs continuously at a rate of 40 MHz, without the need for any trigger logic.An external time reference is provided by plastic scintillators placed in between the DT chambers; the corresponding information is added to the data stream and used in the following analysis steps.
Thanks to the homogeneity of the electric field, the particle's position within each tube (with a left-right ambiguity) is linearly dependent on the drift time.Namely, the distance of the muon track from the wire reads with t hit the time associated to each signal in a tube (called a hit).The two parameters are the drift velocity v d , known by means of a calibration procedure (in our case, v d = 53 µm/ns), and the time pedestal t 0 , which can be deduced from the timing information provided by the scintillators1 .The drift time t is obtained by the difference between t hit and the time pedestal.The hits occurring in a time window of 90 µs centred around the signal provided by the scintillators are grouped in quadruplets (with one hit pertaining to each of the four layers as in Fig. 1, right top).Then, a linear fit is performed on each of the quadruplets and the candidate muon track is obtained from the combination yielding the best χ 2 .In this way the trajectory of the muon in the plane transverse to the tubes is determined, with a precision on the position of about 180 µm and on the slope of about 1 mrad.Tracks from various DT chambers can be combined to determine the 3D muon trajectory; in the following we will however consider only the 2D measurement.
If the detector conditions are anomalous, the efficiency and accuracy of the muon track reconstruction may be compromised.Ensuring the proper operation of the detector thus requires monitoring the quality of the recorded data.In what follows, we consider six basic quantities related to the passage of a muon through a DT chamber: • Drift times t i : the four drift times associated with the muon track.The drift time distribution is displayed in Fig. 2 in different ranges for the muon track angle θ (or "slope", see the next item), showing the correlations between these two variables.The t i distributions are also reported in Figs. 3 and 4.
• Slope θ: the angle formed by the muon track with the vertical axis.The chamber efficiency is expected to drop beyond |θ| ∼ 40 degrees as we see in Figs. 3 and 4.
• at the LHC orders of magnitude larger than that of our laboratory in Legnaro, but the recorded spurious hits rate can also be affected by issues related to the detector operation conditions.
The six variables x = {t 1 , . . ., t 4 , θ, n Hits } will be the input features of the NPLM algorithm for DQM, described in the next sections.Notice that the data are gathered from the subset of tubes in a single chamber that geometrically matches the scintillators, i.e. about three tubes per layer.We collected the data by artificially inducing possible issues that can occur during detector operations.Specifically, we reduced the voltage of the cathodic strips to 75%, 50%, and 25% of their nominal value (-900 V, -600 V, and -300 V, respectively), and we lowered the frontend thresholds to 75%, 50%, and 25% of their nominal value (75 mV, 50 mV, and 25 mV, respectively).The former action distorts the electric field shape, whereas the latter mimics the sudden contribution of noise sources.We conducted a dedicated data acquisition campaign in these six anomalous configurations, collecting around 10 4 events for each configuration.We also collected around 3 × 10 5 data points in the normal (or, reference) working conditions of the apparatus. 2The distribution of the six input features for the reference data and the data collected under the different anomalous conditions are shown in Fig. 3 (variation of the cathodes voltages) and Fig. 4 (variation of the thresholds).These data will be used to design and calibrate the DQM algorithm, as described in the following section.

Methodology
In the setup described in the previous section, we are interested in assessing the quality of individual batches of data collected by the apparatus, each of which denoted as D = {x i } N D i=1 .Namely, we ask whether the statistical distribution of the data points in D coincides or not with the one expected under reference working conditions, p(x|R).We thus aim at performing what is known in statistics as a goodness-of-fit test.See [17] for references and a concise overview.
The reference distribution p(x|R) is not available in closed form.What is available is instead a second dataset R = {x i } N R i=1 collected by the same apparatus when operated in the reference working conditions, such that the data in R do follow the p(x|R) distribution.Our goodnessof-fit test is thus carried out by comparing the two datasets D and R, asking whether they are thrown from the same statistical distribution.The problem can then be formulated as a two-sample test, in which, however, D and R play asymmetric roles.The reference dataset R is instead created within the methodology design, with mild or no limitation on its size, N R .A larger R dataset offers a more faithful representation of the underlying reference statistical distribution and therefore a more accurate test.Furthermore, taking N R larger than N D reduces the effect of the R dataset statistical fluctuation on the outcome of the test, leaving only those inherently due to the fluctuations of D. This makes the outcome for a given data batch D nearly independent on the specific instance of the set R that is employed for the test, making the result more robust.In what follows, we will thus preferentially consider an unbalanced setup for the two datasets, with N R > N D .We will further exploit the availability of a relatively large volume of data collected under the reference working conditions for calibrating the test statistics variable and for selecting the hyperparameters, as discussed in the following.
The availability of a large set of data that are accurately labelled as having been collected under the reference detector conditions deserves further comments.These data are routinely available, in particular in high-energy physics experiments, and are in fact used for the design and calibration of regular DQM methods [5][6][7][8][9].They are validated by a careful offline inspection, which typically requires human intervention.This validation process is way too demanding and slow to be employed as a DQM algorithm.The purpose of DQM is in fact to monitor the data quality online, i.e. while they are being collected.The offline validation is instead straightforwardly capable of producing labelled reference data samples that are way larger than individual data batches.

The NPLM method
We employ the "New Physics Learning Machine" (NPLM) method, which was proposed and developed by some of us [10][11][12][13] to address a similar problem in the different context of searches for new physical laws at collider experiments.The search for new physics is performed by comparing the measured data with a reference dataset whose statistical distribution is the one predicted by a standard set of physical laws that supposedly describe the experimental setup.The purpose of the comparison is not to assess the quality of the data like in DQM, but the quality of the distribution prediction and in turn to check whether the standard laws are adequate or, instead, new physical laws are needed to model the experimental setup.However, this conceptual difference does not have practical consequences.The NPLM setup of D versus R data comparison is straightforwardly portable to DQM problems.
The NPLM method design is inspired by the classical approach to hypothesis testing based on the likelihood ratio [18].A model f w (x) acting on the space of data x, with trainable parameters w, is employed to define a set of alternatives to p(x|R) for the distribution of the data points in D. Since the alternative hypothesis depends on w, we denote it as H w and p(x|H w ) is the alternative distribution of x.In particular, f w (x) directly parametrises the logarithm of the ratio between p(x|H w ) and p(x|R).The model f w (x) could be a neural network as in [10][11][12], or it could be built with kernel methods [13].We will employ the latter option for reasons that will become clear soon.The model is trained by adjusting its parameters to best accommodate the observed data.Consequently, the trained parameters w define the best-fit hypothesis H w .Following [18], the test statistic variable to be employed for the assessment of the quality of the data D is3 In order to train the model we exploit a classical result of statistical learning: a continuousoutput classifier trained to tell apart two datasets approximates -possibly up to a given monotonic transformation-the log ratio between the probability distribution of the two training sets.This property is proven explicitly in e.g.[10,13] for the weighted logistic loss By assigning label y = 0 to the data in R, and y = 1 to those in D, the model f w (x) trained with the loss in Eq. ( 3) approaches the logarithm of p(x|H w )/p(x|R) as it was needed in Eq. ( 2).The weight factors in Eq. ( 3), which depend on N 1 /N 0 = N D /N R , are included because the two training datasets are unbalanced as previously explained.
A direct application of the classical theory of hypothesis testing [18] would actually suggest to employ a different loss function.In fact, the best-fit parameters w to be used in the definition of the test statistic (2) should be those that maximise the likelihood function.Minimising the logistic loss produces instead an estimate of the best-fit parameters that is different, a priori, from the maximum likelihood estimate.This can be remedied by employing a special loss function called "maximum likelihood loss", whose minimisation is equivalent to maximising the likelihood [10].The maximum likelihood loss is not used in the kernel-based implementation of NPLM [13] and the logistic loss (3) is preferred for practical reasons.No strong performance degradation has been observed using the logistic loss in place of the maximum likelihood loss in the tests of the NPLM method performed so far.
Using the elements above, the design of the NPLM method for DQM works as follows.We first pick up a model for f w (x) and select its hyperparameters.The hyperparameters selection strategy is described in the next section for the kernel-based implementation of NPLM.Next, we need to calibrate the test statistics variable (2) in order to be able to associate its value t(D) to a probability p[t(D)], the p-value.This probability will be the output of the DQM algorithm.Based on its value, the analyser will eventually judge the quality of each data batch D. For instance, the analyser might define a probability threshold, below which the data batch is discarded or set apart for further analyses.Above the threshold the batch could be retained as a good batch.
It should be noted that the selected hyperparameters and the p-value do depend on the detailed setup of the DQM problem under consideration.For instance, different hyperparameters will be used in Section 4 for the setup with 5 input features and data batch size N D = 1000 than in the case of 6 features and N D = 500.The p-value calibration function p[t] will be also different.However, once these elements are made available for a given setup, they can be used to evaluate the quality of all the D batches in that setup.The only operation that the DQM algorithm has to perform at run-time is one single training of D against R, out of which t(D) is obtained and in turn p[t(D)].
Calibration is performed as follows.The test statistics (2) is preferentially large and positive if the best-fit alternative distribution p(x|H w ) accommodates the data better than the reference distribution p(x|R) does, signalling that the data batch is likely not thrown from p(x|R).Large t(D) should thus correspond to a small probability.The precise correspondence is established by comparison with the typical values that t attains when the data batch is instead a good batch.We thus compute the distribution, p(t|R), that the t variable possesses when the data follow the reference statistical distribution and the p-value is defined as The physical meaning of p[t(D)] is the probability that a good data batch gives a value of t that is more unlikely (i.e., larger) than the value t(D) produced by the batch D. If a threshold is set on p, this threshold measures the frequency at which good data batches are not recognised as such by the algorithm.The p(t|R) distribution is straightforwardly estimated empirically, thanks to the availability of reference-distributed labelled data points.We create several artificial data batches-called Toy datasets-of the same size N D as the true batches.We run the training and compute t on each of them.Each Toy dataset should be statistically independent, and independent from the reference dataset R that is employed for training.A very large sample of referencedistributed data is thus used in order to produce both the Toy batches and the reference dataset.By histogramming the values of t computed on the Toys we could easily obtain an estimate of p(t|R) and hence of p [t].A different procedure is adopted here, exploiting the empirical observation [13] that p(t|R) is well approximated by a chi-squared (χ 2 ) distribution.The number of degrees of freedom of the χ 2 depends on the setup but can be determined by fitting to the empirical distribution of the t values computed on the Toys.The survival function (one minus the cumulative) of the corresponding χ 2 distribution will be used as an estimate of p[t].It should be noted that by proceeding in this way we will be formally able to compute very small p-values that correspond to highly-discrepant data batches with very large t(D).However, the agreement of p(t|R) with the χ 2 cannot be verified in the high t region, which the Toys do not populate, and there is no theoretical reason to expect that this agreement will persist in that region.Our quantification of the p-value is thus only accurate in the region that the Toys statistically populate.For instance, if 300 Toys are thrown, only p-values larger than around 1/300 are accurately computed.If t(D) falls in a region where our determination of p is much smaller than that, ours should be regarded as a reasonable estimate that is particularly useful to compare the level of discrepancy of different batches, but it cannot be directly validated.However, in those cases we will be able to ensure that p[t(D)] 1/300 by directly comparing with the t values on the Toys.
Another feature of the NPLM approach is the possibility of exploiting the function f w learned during the training task to characterise anomalous batches of data.The function f w represents the log-ratio between p(x|H w ) and p(x|R) and, hence, can be used to deform and adapt the reference distribution to the data by reweighting, according to the following expression p(x|H w ) = e f w (x) p(x|R). ( The function exp(f w (x)) will be close to one if the data are well-described by the reference distribution, while it will depart from it otherwise.One should therefore be able to gain additional information about the anomalous batch by inspecting this quantity as a function of the input variables, or any combination of them, even when not explicitly provided as an input feature for the training.Having access to this kind of information is a valuable element in the context of the search for new physics [10,11,13], since the physics-motivated variables that one might want to inspect to explain a potential anomalous score could be some type of nontrivial combination of the input features with a clear physical meaning, such as the invariant mass of a many-body final state.For DQM applications, this analysis is less relevant since a direct visual inspection of the ratio between the binned data and reference marginal distributions is already quite informative and the user might not be not interested in exploring specific high-level features in the first place.On the other hand, one can still exploit the possibility of reconstructing the data distribution using f w as a debugging tool, namely to check whether the learning model correctly recognises if the data deviates from the reference and how.Moreover, somewhat aside from the main goal of the present article, the output of the NPLM-DQM application could be exploited to study those data batches that display significant deviations from the reference and, depending on the characteristic of the departures, to classifying them into different anomalous categories.Further investigations on a possible extension of the application in this respect are left for future work.

Falkon-based NPLM
Applying NPLM to the DQM problem is simpler than using it for new physics searches.For new physics searches one needs to worry about imperfections in the reference data that stem from the mismodelling of the reference distribution based on the underlying standard physical laws.Including these effects in NPLM is possible but requires dedicated work and domainspecific expertise [12].Mismodelling is not a concern in DQM problems because no modelling is required at all: the reference-distributed data are merely collected from the same experimental apparatus and not simulated.NPLM algorithms for DQM can thus be designed more easily and systematically without the need for extremely specialised domain knowledge.
DQM applications are, however, much more computationally demanding than new physics searches.For new physics searches there is typically only one dataset D to be analysed.For DQM, a large flow of data batches needs to be analysed online.We will see in Section 5 that, for instance, order 10 seconds are needed to the CMS muon system to collect one data batch.Our DQM algorithm must respond on a competitive timescale in order to be applicable to that problem.The relevant operation time is the one needed for a single training, as previously explained.The original implementation of NPLM based on neural networks is vastly incompatible with this requirement.On the other hand, the one based on kernel methods is much faster to train on problems of comparable scale [13].It could thus match the specification requirements for applications to LHC detectors.
The performance of the kernel-based version of NPLM stems from those of the Falkon [14] library, the core algorithm powering our implementation.A sketch of the basic theoretical and algorithmic ideas implemented in Falkon, developed in Ref. [19][20][21], are reported below.
With kernel methods, one learns functions of the following form with N = N 0 + N 1 the total size of the training dataset.Here k σ (x, x i ) is the kernel function and σ some hyperparameter.We consider the Gaussian kernel so that f w is a linear combination of Gaussians of fixed width σ, centred at the training data points.The optimisation of the model parameters w is achieved by minimising the empirical risk L(f w ), plus a regularisation term The empirical risk in our case is the one associated with the logistic loss ( 3) The regularisation term is given by Its relative importance in the optimisation target ( 8) is controlled by the hyperparameter λ.Kernel methods are non-parametric approaches, in the sense that the number of parameters w in Eq. ( 6) increases automatically with the total number of data points and, in the large sample limit, they can recover any continuous function [22,23].However, optimising the function in Eq. ( 6), with the target in Eq. ( 8), requires handling an N × N matrix-the kernel matrixwith entries k σ (x i , x j ).The computational complexity of the optimisation thus scales cubically in time and quadratically space with respect to the number of training points N [14,19].These costs prevent the application to large-scale settings, and some approximation is needed.
Within the Falkon library, the problem of minimising Eq. ( 8) is formulated in terms of an approximate Newton method (see Algorithm 2 of [14]).The algorithm is based on the Nyström approximation, which is used twice.First, to reduce the size of the problem, by considering solutions of the form where {x 1 , ..., xM } ⊂ {x 1 , ..., x N } are called Nyström centres and are sampled uniformly at random from the input data.The number of centres M ≤ N is a hyperparameter to be chosen.Then, Nyström approximation is again used to derive an approximate Hessian matrix Here, T is such that T T = K (Cholesky decomposition), with K ∈ R M ×M the kernel matrix subsampled with respect to both rows and columns.D ∈ R M ×M is a diagonal matrix s.t. the i-th element is the second derivative of the loss (y i , f w (x i ), ) with respect to its first variable.Eq. ( 12) is then used as a preconditioner to perform conjugate gradient descent.With this strategy, the overall computational cost to achieve optimal statistical bounds is O(N ) in memory and, of particular importance for our scope, O(N √ N log N ) in time.The reader can find more details in Ref. [14].

Hyperparameters selection
The selection of the three Falkon hyperparameters M , σ and λ follows the prescriptions of Ref. [13], with one minor modification described below.The hyperparameters selection employs data collected under the reference working condition, and proceeds as follows.
The number of centres M controls the expressive power of the model and therefore it should be as large as possible not to compromise the sensitivity to anomalous distributions with intricate shapes.It must also be at least as large as √ N in order to achieve statistically optimal bounds of the training convergence.At the same time, training is faster if M is smaller.The experiments performed in Ref. [13] show that any value of M above around the data batch size N D does not compromise sensitivity.
The Gaussian width σ is selected as the 90th percentile of the pairwise distance between reference-distributed data points.Notice that the model (11) acts on an input vector x whose input features are standardised to have zero mean and unit variance on reference-distributed data.The same standardisation is applied before computing the distances.
The regularisation parameter λ is kept as small as possible while keeping training stable, i.e. avoiding large training times or non-numerical outputs.A number of reference-distributed Toy data batches is employed for this study, each trained against the reference sample R. Some of the experiments performed in this paper employ quite smaller data batches (e.g., N D = 250) than those considered in Ref. [13].In these new conditions we observe that the compatibility of the test statistic distribution with a χ 2 (see the end of Section 3.1) is violated for very small λ.In these cases, we raise λ until when the agreement with the χ 2 is restored.
The hyperparameters selected with the above criteria, in the different setups for DQM considered in this paper, are reported in Table 1.

Alternative approaches
Goodness-of-fit and two-sample test problems are of interest in several domains of science.Many approaches exist, and developing new strategies is an active area of research.One heuristic reason to choose NPLM for DQM, among the many different options, is that it has been developed in the challenging context of new physics searches.Prior experimental and theoretical knowledge suggests that new physics is elusive.The target for new physics searches is thus to spot out minor departures of the actual data from the reference distribution.These departures could emerge either as small corrections to the distribution shape or as relatively large corrections like sharp peaks, which however only account for a very small fraction of the experimental data.Detecting such small effects requires precisely comparing the reference distribution with large datasets, which NPLM is designed to perform.Using NPLM for DQM could thus enable a more accurate monitoring of the data offering sensitivity to more subtle failures of the apparatus.The number of input features in the data that are typically relevant for new physics searches ranges from few to tens, which is an adequate number also for the monitoring of individual detectors and detector systems fully exploiting the correlations among the variables.For comparison, methods to assess the quality of generated images target instead order thousand-dimensional input data.They could be less performant for DQM as they are designed to address a radically different problem.These heuristic considerations suggest that NPLM is a reasonable starting point for the development of novel DQM algorithms based on advanced multivariate goodness-of-fit or twosample test methods, which we advocate in this paper.On the other hand, no comprehensive comparative study of the NPLM performances is currently available.Such comparison is beyond the scope of this paper.However, the DQM problems and datasets we study will be useful benchmarks for future work in this direction.
Work has initiated [24,25] to compare NPLM with a certain class of methods, called "classifier-based" methods.The classifier-based approaches [26] are all those that entail training a classifier to tell apart D from R and using the trained classifier to construct a test statistic for the hypothesis test.A simple implementation [27] employs the classification accuracy as test statistics.Following the standard pipeline for classifiers, the model is trained on part of the D and R datasets (the training set), while the accuracy is evaluated on the remaining data (the test set).The idea is that while the accuracy will be poor (around random guess) if D and R follow the same distribution, it will be higher if their distributions differ.
NPLM is technically a classifier-based method.Its major peculiarities are the choice of the likelihood ratio test statistic in Eq. ( 2) and the fact that the entire datasets are employed both for training and for the evaluation of the test statistics.None of these choices is motivated from the viewpoint of the theory of classification, while they are both natural or in fact required from the perspective of the theory of hypothesis testing that underlies the NPLM approach.Performance studies in [25] show that these choices are beneficial for the sensitivity.These results partly contradict Ref. [24], which however employs different classification models, different criteria for hyperparameters selection and uses permutation tests for the estimate of the sensitivity rather than computing it empirically as in NPLM.These differences are evidently responsible for the different findings and more work is needed for a conclusive assessment.

Results
In this section, we present the application of the NPLM strategy for DQM to the DT chambers data described in Section 2. We will consider monitoring data batches of variable size N D = 250, 500 and 1000, by employing a reference dataset of fixed size N R = 2000.
The input data consists of six features: the four drift times, the muon angle and the number of hits.As shown in the bottom-right plots of Figures 3 and 4, the number of hits, n Hits , is  highly discriminant for the anomalies we considered in our study, and in particular for the ones affecting the thresholds (the lower the threshold, the higher the noise).At the LHC, however, that quantity also depends on the luminosity delivered to the experiment, which could vary greatly even during a single run.Not being necessarily a proxy to a detector issue, it is worth considering also the case where only the other five variables are provided to the algorithm; as an additional benefit, this will allow assessing the ability of the NPLM DQM approach to exploit correlations between variables and detect anomalies even when their effect is unexpected and not straightforwardly evident.The left and middle panels of Figure 5 show the test statistics distribution in the fivedimensional problem, for data batches size N D = 500.The grey histograms display the distribution of t in the reference working conditions, P (t|R).This is obtained empirically by processing reference-distributed Toy data batches, and fitted to a χ 2 distribution as explained in Section 3.1.The different distributions of the test statistic associated with the anomalous batches shown in the coloured histograms are very well separated from the reference distribution, meaning that anomalous data are very likely to be identified as such by the algorithm.This is quantified by the median p-value of the anomalous batches, reported in the central column of  For a comparative assessment of the performance, we computed a Kolmogorov-Smirnov (KS) test on each individual feature for the same data used to train the NPLM model.The KS median p-values are reported in Table 3 and compared with the ones obtained with the five-dimensional NPLM test.We see that individual variables have a very limited power to discriminate the anomalous batches.The NPLM method instead is sensitive to correlated discrepancies in the different distributions and discriminates the anomalies effectively.For illustrative purposes, we show in the left and middle panels of Figure 6 the distribution of the one-dimensional KS statistic computed on the drift time of the first layer (t 1 ) for reference and anomalous batches.By comparison with Figure 5, it is easy to recognise the advantage of the NPLM strategy.We now turn to the study of the complete six-dimensional problem, including the variable n hits .The reference and anomalous test statistic distributions are shown on the right panel of Figure 5.By comparing with the other panels of the figure we can appreciate the tremendous discriminating power of the n hits variable: including n hits all the anomalies can be detected with very high significance.Therefore, using this variable alone for the NPLM DQM test, or running a regular KS test (as shown in the right panel of Figure 6), is sufficient to identify the anomalies, as previously mentioned.
We conclude this section by showing some examples of the data marginal distribution reconstructed by the model.The three plots reported in Figure 7 are produced by reweighting each event of the reference sample used for the training by an exponential factor e f w (x) , as explained in Eq. 5; both the reweighted reference and the data samples are binned, and their ratio with respect to the original reference sample is shown in the bottom panels.By comparing the data-versus-reference ratio (labelled as "true") with the reconstructed one ("learned") we can appreciate the correctness of the model in understanding the nature of the anomaly and, hence, trust the results of the machine learning task.All the numerical experiments presented in this paper have been performed on a single machine equipped with a NVIDIA Titan Xp GPU with 12 GB of VRAM.We tested the performances of the algorithm in terms of execution time; the training time for a single five-dimensional classification task is approximately 0.5 seconds, with no significant dependency on the nature of the data and the size of the sample.

Conclusions and outlook
We presented the test of a powerful ML-based algorithm, NPLM, as a tool to monitor the quality of the data originated by a typical detector used for measuring particles at high energy colliders.NPLM compares collected measurements with a reference dataset describing the standard detector readout, performing a multidimensional likelihood-ratio hypothesis test.
The study demonstrated the capability of the algorithm to detect anomalous detector conditions, with a much greater discriminating power than simpler traditional methods, like Kolmogorov-Smirnov test.
Although conducted on simplified experimental conditions, the test presents figures appropriate for a typical monitoring system of a detector operating at the LHC; in particular, the number of channels and the size of the datasets are of the same order of magnitude as the corresponding CMS DQM application.The amount of data we consider for each batch can be gathered much more quickly at the LHC than in a cosmic stand like the one used here, anyhow the rate at which possible issues should be detected is not larger than one in a minute 4 ; the time requested by NPLM to run -less than a second-makes the algorithms suitable to be executed online.

Figure 1 :
Figure 1: Left: the experimental apparatus at Legnaro Laboratory, with four drift-tube chambers, vertically stacked.Right: a schematic view of the cell (bottom) and an example of hit pattern left by a charged particle crossing a chamber (top).

Figure 4 :
Figure 4: The distribution of the input features in the reference and in three anomalous working conditions of the thresholds.

Figure 5 :
Figure 5: Distribution of the test statistics in the scenario N D = 500.The plot displays the distribution of the test statistic t on reference-distributed Toys and on the data collected under anomalous detector conditions.

Figure 7 :
Figure 7: Examples of input data and respective learned likelihood ratios with sample size N R = 2000 and N D = 500.
Number of hits n Hits : the number of hits recorded in a time window of one second around the muon crossing time.Many spurious hits are present in addition to those due to the passage of a muon.The noise rate depends on the environmental conditions, with the one

Table 1 :
NPLM algorithm parameters configuration for the five-dimensional and six-dimensional experiments considered in this work.The numbers of degrees of freedom of the χ 2 that best approximates p(t|R) is reported in the last column.

Table 2 .
The table also reports the median p-value for larger (N D = 1000) and smaller (N D = 250) batches.The sensitivity to the anomaly increases with N D , as expected.

Table 2 :
Median p-values for different anomalies and data batches size.Five input features are considered, excluding n hits .

Table 3 :
Median p-values in the setup N D = 500.