24 FCNC Fitter
Renata Kopecná edited this page 2022-02-10 14:51:06 +01:00

FCNC fitter was originally written by Christoph Langenbruch. Then, it was modified by David Gerick to fit the needs of the B+->K*(KSpi+)mumu analysis. Later, Renata Kopecna modified it further to be slightly more versatile, not have either verbose or super verbose modes only and to compile much faster.

Table of Contents

Compilation

The compilation is done by using cmake. The include of spdlog and all the libraries is done in CMakeLists.txt. When you install spdlog, check the path is properly included! Also, it will fail on lhcba1, run on d0new.

Compile the code with a simple

bash cmake.sh

Or just run the code using the amazing python tool for running the code, it will take care of the compilation automatically.

Creating necessary folders

There is a neat bash script for that, just run

bash makefolders.sh

spdlog

Spdlog is a fast logging library. It is made for C++ and consists only of headers. Spdlog is used in FCNCfitter now, as the previous version only used two levels of verbosity (verbose and super verbose) using basic prints. To run the current version of the FCNC fitter it is required to be installed.

The github repository can be found at https://github.com/gabime/spdlog/wiki/1.-QuickStart

For simple instalation guide and tutorials, see https://spdlog.docsforge.com/master/

After installation, check that the path to the spdlog/include and spdlog/include/spdlog folder is added to the CMakeLists.txt file. Either set it relative to the directory where the CMake is stored

set(SPDLOG_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/yourRelativePath/spdlog/include/")
set(SPDLOG_INCLUDE_DIR_TWO "${CMAKE_CURRENT_LIST_DIR}/yourRelativePath/spdlog/include/spdlog/")

or set the absolute path

set(SPDLOG_INCLUDE_DIR "$/yourPath/spdlog/include/")
set(SPDLOG_INCLUDE_DIR_TWO "/yourPath/spdlog/include/spdlog/")

git

There is a python script for easier commiting and pushing to git. Check push.py for the details.

Output

There are possible 6 levels of verbosity, which follows the spdlog standard. The levels have different color codes

level color description
0) Trace white Used for development purposes, not recommended to stream this into a file because the output is then VERY verbose.
1) Debug blue More verbose settings, prints also numbers and more detailed status of the code, shoudl be used in case of issues
2) Info green Default settings, prints the current status of the code
3) Warning yellow Shows not critical or small problems only
4) Error red Prints only error messages
5) Critical full red Prints only very serious error messages, the program should end/or crash after such message

The plots are saved in ./plots/ folder. There are a lot of subfolders for easier organization of the plots.

Known issues

The running per year is not working flawlessly as it wasn't really ever used. The paths are sometimes wrongly configured due to this and hence the loading of files sometimes fails.

Running

For the detailed explanation of possible parameters, click here.

For quickly running everything, run the following commands

python run.py -convert -all -Run 1
python run.py -dontCompile -convert -all -Run 2 
python run.py -dontCompile -convert -genMC -Run 2
python run.py -dontCompile -convert -genMC -PHSP -Run 2
python run.py -dontCompile -MC -angCorr -Run 1 -scan
python run.py -dontCompile -MC -angCorr -Run 2 -scan
python run.py -dontCompile -MC -angCorr -Run 1 
python run.py -dontCompile -MC -angCorr -Run 2 
python run.py -dontCompile -MC -angRes -Run 1
python run.py -dontCompile -MC -angRes -Run 2
python run.py -dontCompile -MC -Run 12 -fit -Ref -nBins 1
python run.py -dontCompile -MC -Run 12 -fit -nBins 5
python run.py -dontCompile -Run 12 -v 2 -fit -Ref -nBins 1 -genMC -Ref
python run.py -dontCompile -Run 12 -v 2 -fit -nBins 5 -genMC
python run.py -dontCompile -Data -Run 12 -fit -Ref -nBins 1 -massDim
python run.py -dontCompile -Data -Run 12 -fit -nBins 5 -massDim
python run.py -dontCompile -Data -Run 12 -fit -Ref -nBins 1 -onlyBkg -upper
python run.py -dontCompile -Data -Run 12 -fit -nBins 5 -onlyBkg -upper
python run.py -dontCompile -Data -Run 12 -v 2 -fit -Ref -nBins 1
  • First, it compiles the code and prepares the tuples with Run 1.
  • Then, since we already compiled the code, we use the -dontCompile option for running the next commands.
  • We prepare the tuples for Run2. Then, it scans the order of polynomial used for the PHSP angular description.
  • Next step is to create the angular acceptance weights using the optimal polynomial.
  • Then, the signal Monte Carlo sample is fitted: first fit the reference channel, then the signal channel.
  • After this step is done, it fits the generator level Mont sample in the J/psi Q2 bin and rare channel in 5 Q2 bins.
  • The next step is to fit the data in the B+ and K*+ masses: first, fit the J/psi channel, then the rare channel in the 5 bins.
  • Then, fit the angular background distributions (upper B+ mass sideband) using a chebyschev polynomial.
  • The last step is to fit the data, J/psi channel in 4 dimensions (B+ mass, cos(thetal), cos(thetak), phi)

Tuple conversion

The functions used to convert and tne load the converted TTrees are defined in event.cc. It takes the output from the selection and converts it into a tuple with branch names that make the fitter's life easier. The correct path is saved in paths.cc, function getSelectedTuplePath(int dataset, int run, int year).

To run the conversion for all the samples, do

python run.py -convert -all -Run 1
python run.py -convert -all -Run 2 

Parameters and constants

Constants

The constants are saved in constants.hh and constants.cc.

The constants in constants.cc are functions either returning a combination of global constants in constants.hh, such as

double CTL_RANGE(){ 
    return CTL_MAX - CTL_MIN; 
}

or returns values depending on number of bins, either the Q2 edges of the bins or the S and P observables.

It also contains a function returning a vector of strings with the names of the background parameters depending on the folding and the order of the used polynomial.

In constants.hh global variables are included:

  • Mathematical constants (1 sigma = 0.638, pi, ... )
  • Q2 ranges
  • Angle ranges
  • (LaTeX) names
  • Plotting options
  • PDG masses
  • Mass windows
  • Particle IDs
  • Angular correction orders
  • Weighting options
  • Parameter values
  • Quite some obsolete constants from the Kspi+ analysis

Parameters

The class definition of the parameters used in the fitter is in parameters.cc. The class consist of

  • current value
  • star value
  • previous value
  • error
  • upper error
  • lower error
  • previous upper error
  • previous lower error

The parameters used in the fitter are then defined in bu2kstarmumu_parameters.hh. The functions defined there inititialize the parameters either to the defualt or based on the given fit model. The functions can also load parameters from files, which is handy when fixing parameters to the reference channel or when generating toys. Helper functions used to retrieve the data from files are also defined there.

Options

Most of the fit options are stored in the class defined in opitons.hh. In the class init, the default values are set. As this is a legacy code, there is A LOT of unused options or options that just don't do anything.

Fit models

There are many options how to put together the model that has to be fit. Therefore, separate files with definitions of the model for given case are saved in given source files. The files that were actually used are listed in the neat table below. For the full details, consult my thesis.

File name Description
backgroundfit.cc Performs the fit of the background only: taken from upper mass sideband, functions are chebyshev polynomial for angles and exponential for the B+ mass.
genlvlfit.cc Loads the generator level tuple and performs the full angular fit.
mainfit.cc Fits the data in 4 dimensions: B+ mass and the three angles. Be careful when running on rare data, the blinding might not be set perfectly as it never got to actually run the code
massfit.cc Fits the B+ and K*+ masses. B+ mass is fitted using double sided Crystal Ball, K*+ uses the LASS parametrization
mcfit.cc Performs the monte carlo fit: there is no background contribution. Fit is performed in 4D: B+ mass and the angles
toysfit.cc Fits the distributions from toys.

Angular acceptance

The angular acceptance functions are defined in angularcorr.cc. The range of the polynomials is set in the get_scan_low(bool quickTest, bool only_1D_chi2) and get_scan_high(bool quickTest, bool only_1D_chi2) functions. The actual math is done in bu2kstarmumu_pdf.cc.

File structure

Currently, the file structure is as follows. All the .cc source files also have their corresponding header with the same name.hh.

  • bu2kstarmumu.cc: The main
  • sources
    • help.cc
    • parse.cc
    • paths.cc
    • tests.cc
    • Core: the core functions used in the FCNC fitter, where the calculations happen
      • bu2kstarmumu_generator.cc
      • bu2kstarmumu_loader.cc
      • bu2kstarmumu_parameters.cc
      • bu2kstarmumu_pdf.cc
      • bu2kstarmumu_plotter.cc
      • events.cc
      • fitter.cc
      • folder.cc (Folds the events, does not have to do anything with file folders :))
      • funcs.cc
      • integrals.cc
      • options.cc
      • toystudy.cc
    • Helpers: Smaller utility functions, plotting functions
      • design.cc
      • helpers.cc
    • Params: definition of constants, parameters used in the fit, their default values and boundaries
      • constants.cc
      • parameters.cc
      • parameterscan.cc
    • Run: Functions that initialize the fit model and then perform the fit
      • angularcorr.cc
      • backgroundfit.cc
      • feldman_cousins.cc (Never used)
      • genlvlvfit.cc
      • likelihoodscan.cc (Never used)
      • mainfit.cc
      • massfit.cc
      • mcfit.cc
      • momfit.cc: Method of moments fit (Never used)
      • multifit.cc (Never used)
      • pulls.cc
      • toysfit.cc
    • Scripts: Smaller functions mostly used for plotting
      • EvaluateToys.cc
      • GenLvlvsMC.cc
      • GetMeanError.cc
      • ReferencePlots.cc
      • RunningScripts.cc
      • ScriptHelpers.cc