4 Comparison tool
Renata Kopecná edited this page 2022-03-08 12:50:13 +01:00

What is this tool good for

When performing various checks, it is useful to compare distributions of two different distributions. An example would be a check of the sWeighted data compared to MC sample or checking that variable distributions for B+ agree with B-. This tool allows the user to run a script that takes as an input

  • data type (MC?, year, polarity,...)
  • variables to be compared
  • Selection status of the data (sWeighted, how sWeighted, after the MVA cut, ...)

The tool then plots the normalized distributions and their ratio. The .eps and .root files are saved.

Code structure

Note that this tool was written when python2 was the default almost everywhere. Most functionalities are not rewritten to be compatible with python3.

The code is executed using compareUltimate.py, where the commnads are parsed and the comparison is executed.

Helper functions that allow the user to quickly compare for instance different MC samples or MC to sWeighted data are defined in compareUltimateSelection.py.

The main body of this tool is in compareUltimateSource.py. In this file, the function compareUltimate() is defined.

Helper functions are defined in Utils.py.

The actuall plotting (creating of nice histograms and getting their path) is defined in Plots.py.

LHCbStyle.py is a one-to-one copy of LHCbStyle.h. This file defines a reasonable style for (black-and-white) "publication quality" ROOT plots. The default settings contain many features that are either not desirable for printing on white paper or impair the general readability of plots.

The constants used are defined in Globals.py. On top of this, the ranges for each variable are hardcoded. The file also contains lists of most used variables for each particle.

The paths for the input files are taken from the selection code in getPathForPython.cc. Note that the correct include of Paths.hpp is required for proper running of the code.

Usage

Prerequisities

First, we need to compile getPathForPython.cc Before the first use, make sure the include of Paths.hpp has the correct path! The compilation is done using

cd Code/Selection/ComparisonTool
g++ getPathForPython.cc `root-config --libs --cflags` -o getPathForPython

If the compilaiton fails, consult this page.

Plotting

The code is executed as

python compareUltimate.py -arguments

For the arguments, look inside compareUltimate.py or print all the possible arguments by executing

python compareUltimate.py -h

LHCbStyle.py

Simply add the line from LHCbStyle import LHCbStyle at the beginning of your root program (and make sure LHCbStyle.py is in a location accessible to the compiler). Then add the line lhcbStyle()somewhere at the beginning of your program.

Statistics and fit boxes:

"Decorative" items around the histogram are kept to a minimum. In particular there is no box with statistics or fit information. You can easily change this either by editing your private copy of this style file or by calls to "gStyle" in your macro. For example,

gStyle->SetOptFit(1011);

will add fit information.

Font:

The font is chosen to be 62, i.e.helvetica-bold-r-normal with precision 2. Font is of course a matter of taste, but most people will probably agree that Helvetica bold gives close to optimal readibility in presentations. It appears to be the ROOT default, and since there are still some features in ROOT that simply won't respond to any font requests, it is the wise choice to avoid ugly font mixtures on the same plot... The precision of the font (2) is chosen in order to have a rotatable and scalable font. Be sure to use true-type fonts! I.e.Unix.*.Root.UseTTFonts: true in your .rootrc file.

"Landscape histograms"

The style here is designed for more or less quadratic plots. For very long histograms, adjustements are needed. For instance, for a canvas with 1x5 histograms:

  TCanvas* c1 = new TCanvas("c1", "L0 muons", 600, 800);
  c1->Divide(1,5);

adaptions like the following will be needed:

    gStyle->SetTickLength(0.05,"x");
    gStyle->SetTickLength(0.01,"y");
    gStyle->SetLabelSize(0.15,"x");
    gStyle->SetLabelSize(0.1,"y");
    gStyle->SetStatW(0.15);
    gStyle->SetStatH(0.5);