\section{Event Selection}\label{sec:sel-EventSelection}

LHC collisions occur with a frequency of 40\mhz. Storing all the data coming into \lhcb would require storing data rates of 1\tbyps, which would require 3.6 petabytes per every hour of collisions\footnote{The whole current \lhcb dataset would then contain more than 30 exabytes of data. To put this into perspective, it is estimated that Google, Microsoft, Amazon and Facebook combined together store 1.2 exabytes of data~\cite{ANA-data}.}. However, only in about one of 400 collisions a \bbbar quark pair is produced and the chance of a \B meson decaying into \Kstar\mumu is circa one in a million. Therefore, it is needed to process the data quickly and select only the required events, while maintaining very high purity and efficiency of this selection. 

The selection of \BuToKstmm candidates is realized in several steps. First, the events have to pass the online (\emph{trigger}) selection. Then, tighter selection criteria are applied in a centralized (\emph{stripping}) selection. The criteria applied in these two steps are common for many \lhcb analyses. Next step is an even tighter preselection that is specific for this work. These events are further filtered by utilizing a multi-variate analysis. In order to utilize the simulation sample in the multi-variate analysis, the simulated sample is validated and corrected to match the data. The final selection is validated using available simulation samples and exploiting the reference channel \BuToKstJpsi. 

\input{Chapters/EventSelection/TrigStrip}

\input{Chapters/EventSelection/Cut}

\input{Chapters/EventSelection/Simulation}

\input{Chapters/EventSelection/MVA}

\input{Chapters/EventSelection/MultCand}

\input{Chapters/EventSelection/Signal}

\input{Chapters/EventSelection/Backgrounds}

\subsection{Final selection}\label{sec:sel-FinalSelection}

Using \refEq{significance} and \refEq{YieldEstimation2}, the expected significance for each Run is estimated for many values of the MLP response. This is shown in \refFig{sel-MLPscan}. The maximum expected significance corresponds to cut on the MLP response at a value of 0.9985 for \runI and of 0.996 in \runII. \vspace{-0.5\baselineskip}

\begin{figure}[hbt!]
	\centering
	\includegraphics[width=0.67\textwidth]{./Data/FinalSelection/ExpectedSignificance.eps} 
	\captionof{figure}[Expected significance of the \BuToKstKppizmm selection.]{Expected significance of the \BuToKstKppizmm decay yield. The significance is obtained using \refEq{significance} and \refEq{YieldEstimation2}. The maximum significance value is 0.9985 for \runI and 0.996 for \runII.}. \label{fig:sel-MLPscan}
\end{figure}

The resulting mass distribution after applying the optimal MLP response cut on the full dataset obtained during  \runI and \runII datat aking in the \jpsi resonance region is shown in \refFig{sel-JpsiYield}. The expected signal and background yields obtained from the reference channel in the \BuToKstmm  channel are depicted in \refTab{sel-yields}. The measured signal yield in the table is obtained from the fits to the signal channel presented in \refFig{sel-SignalYield}. It is worth noting here that the optimization was performed on the \BuToKstJpsi decay. As shown in \refFig{sel-MLPscan}, the MVA response value corresponding to the highest significance is not distinct and susceptible to fluctuations. Therefore, the expected \BuToKstmm decay yields are higher than the actual fitted yields. 

\begin{figure}[hbt!]
	\centering
%	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/Run1_KplusPi0Resolved_JpsiOnly_BplusMassModel_OneCB_SingleExponential_DTF_removedMultiple_TMVA0.999133_constrained_fixShape_fixedMassWindow.eps} \hspace{-5pt}	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/Run2_KplusPi0Resolved_JpsiOnly_BplusMassModel_OneCB_SingleExponential_DTF_removedMultiple_TMVA0.997074_constrained_fixShape_fixedMassWindow.eps}
	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/Jpsi_Run1.eps} \hspace{-5pt}	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/Jpsi_Run2.eps}
	\captionof{figure}[Signal yield of the \BuToKstJpsi decay.]{Signal yield of the \BuToKstJpsi decay. The symbol $\mu(m_B)$ stands for the mean of the signal distribution, $\sigma(m_B)$ is the width of the peak. All parameters of the fit are left floating. The  signal (blue) is fitted by two-sided Crystal Ball function (for the definition, see \refApp{CrystalBall}), background (red) is described by an exponential function. The fitted signal and background yields are consireded in $\pm$100\mev around the \Bu meson mass.} \label{fig:sel-JpsiYield}
\end{figure}
	

\begin{table}[hbt!]
	\centering
	\begin{tabular}{l|l|l} %ALREADY UPDATED TO THE NEW MLP
					& Expected 	& Fitted \\ 
		\runI 		&			&       \\ \hline
			Signal 		& 67    & 37$\pm$10\\
			Background  & 14    & 49$\pm$7\\
			S/sqrt(S+B) & 7.47  & 4.03 \\
					&		 	&   \\
		\runII 		&  		 	&   \\ \hline
			Signal	    &298 & 233$\pm$26\\
			Background  &203 & 262$\pm$17\\
			S/sqrt(S+B) &13.30  & 10.49
	\end{tabular}
	\captionof{table}[Expected and measured signal yields in the \BuToKstmm decay.]{Expected and measured signal yields in the \BuToKstmm decay.  The expected \BuToKstmm decay yields are higher than the actual fitted yields due to the optimization of the MVA response cut using only the reference \BuToKstJpsi decay. \label{tab:sel-yields}}
\end{table}	
%

\begin{figure}[hbt!]
	\centering
%	\includegraphics[width=0.48\textwidth]{./Data/FinalSelection/Run1_KplusPi0Resolved_mumu_BplusMassModel_OneCB_SingleExponential_DTF_removedMultiple_TMVA0.9985000_constrained_fixShape_fixedMassWindow.eps} \hspace{10pt}
%	\includegraphics[width=0.48\textwidth]{./Data/FinalSelection/Run2_KplusPi0Resolved_mumu_BplusMassModel_OneCB_SingleExponential_DTF_removedMultiple_TMVA0.996000_constrained_fixShape_fixedMassWindow.eps}
	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/mumu_Run1.eps} \hspace{-10pt}
	\includegraphics[width=0.49\textwidth]{./Data/FinalSelection/mumu_Run2.eps}
	\captionof{figure}[Signal yield of the  \BuToKstKppizmm decay.]{Signal yield of the  \BuToKstKppizmm decay. $\mu(m_B)$ stands for the mean of the signal distribution, $\sigma(m_B)$ is the width of the peak. The signal shape is constrained to the shape of the signal yield in the resonance region shown in \refFig{sel-JpsiYield}. The  signal (blue) is fitted by two-sided Crystal Ball (for the definition, see \refApp{CrystalBall}), background (red) is described by exponential function.} \label{fig:sel-SignalYield}
\end{figure}

The selected \BuToKstmm candidates are divided in \emph{four} \qsq bins: [0.1-4.0]\gevgev (excluding 0.98-1.1\gevgev in order to remove $\phi\to\mumu$ contribution), [4.0-8.0]\gevgev, [11.0-12.5]\gevgev and [15.0-18.0]\gevgev. The measured mass distributions in these bins are presented in \refApp{yield_q2}. The measured signal and background yields together with their significance are shown in \refFig{sel-q2Yield}. The significance is also compared to a study by the \cms collaboration of \runI data exploiting \BuToKstKspimm ~\cite{ANA-CMS-angular}\footnote{This comparison is chosen as the significance in the analysis by the \cms collaboration is comparable to the significance presented here. The other previous measurements discussed in \refSec{ANA_previous} were performed either in experimentally cleaner environment or with only charged particles in the final state, reaching higher significance values.}
  The \KstToKsPi, \KS\to\pip\pim channel is detected more efficiently with better resolution, as the final state consists of charged particles only. The measured significance is higher than the one in the study done by the \cms collaboration, proving the potential of this analysis to measure all angular observables mentioned in \refEq{Si_definition}. It is worth noting here that the \cms collaboration successfully measured only the \FL and \AFB angular parameters.

\begin{figure}[hbt!]
	\centering
	\includegraphics[width=0.75\textwidth]{./Data/FinalSelection/KplusPi0Resolved_Q2_Run12.eps}
	\captionof{figure}[Yields and siginificance compared to a CMS meaurement.]{\textcolor{red}{Signal} (red) and \textcolor{black}{background} (black) yields and measured \textbf{\textcolor{ao}{significance}} (blue) in the combined \runI and \runII dataset. In the first bin $\qsq\in[0,4]$, the $\phi\to\mu\mu$ contribution ($\qsq\in[0.98,1.1]$) is removed. The \textbf{\textcolor{ao(english)}{green}} data are taken from a study done by \cms. The study uses the \BuToKstKspimm decay data from \runI~\cite{ANA-CMS-angular}.} \label{fig:sel-q2Yield}
\end{figure}


The numbers of signal candidates per data-taking year are given in \refTab{sel-selection_yields} for the reference \BuToKstJpsi and in \refTab{sel-selection_yields_rare} for the signal \BuToKstmm channel. To put the final number of candidates in perspective, the number of candidates after each selection step is included as well. 


\begin{table}[hbt!]
	\centering
	\begin{tabular}{p{3.4cm}|cccccc}
 		selection $\setminus$ year  & 2011	& 2012			& 2015			& 2016			& 2017			& 2018 \\ \hline
		Trigger and online	& 23\,718\,772	& 58\,047\,021	& 9\,822\,137	& 57\,955\,614	& 32\,702\,706	& 54\,868\,587\\
		Preselection		& 31197			& 67191			& 13769			& 89310			& 90460			& 90660\\
		MLP selection		& 4409			& 8637			& 2483			& 16475			& 17885			& 17659\\					
	\end{tabular}	
	\captionof{table}[Number of reference channel candidates for each selection stage.]{Number of the  \textbf{reference channel} event candidates after the trigger and the stripping selection, preselection and MLP selection. Event candidate is any event passing the selection step, therefore this includes background candidates. In the last step, the background is mostly combinatorial. Note the discrepancy between the events passing the trigger and online selection in 2017 data-taking year compared to 2016 and 2018: this is a result of stricter stripping selection. For details see \refTab{stripping_cuts}. \label{tab:sel-selection_yields}}
\end{table}	


\begin{table}[hbt!]
	\centering
	\begin{tabular}{p{3.4cm}|cccccc}
	selection $\setminus$ year  & 2011			& 2012			& 2015			& 2016			& 2017			& 2018 \\ \hline
	Trigger and online			& 10\,972\,833	& 28\,455\,565	& 5\,322\,454	& 31\,999\,312	& 16\,969\,963	& 30\,897\,345\\
	Preselection			& 3134			& 6881			& 1288			& 10017			& 10016			& 10090\\
	MLP selection				& 42			& 101			& 39			& 216			& 242			& 241\\			
	\end{tabular}	
	\captionof{table}[Number of signal channel candidates for each selection stage.]{Number of the \textbf{signal channel} event candidates after the trigger and the stripping selection, preselection and MLP selection. Event candidate is any event passing the selection step, therefore this includes background candidates. In the last step, the background is mostly combinatorial. Note the discrepancy between the events passing the trigger and online selection in 2017 data-taking year compared to 2016 and 2018: this is a result of stricter stripping selection. For details see \refTab{stripping_cuts}. \label{tab:sel-selection_yields_rare}}
\end{table}	

\clearpage    
