RapidFit is a fitting tool developed by the Edinburgh LHCb group. It does not use RooFit. It is intended to be used by the group to perform fits to data from Bs->J/psiPhi and Bs->PhiPhi channels (along with anything else we need). The alpha version of RapidFit has just been released.



Nota Bene

I would recommend that you do this on the PPE machines but it will also work on your Linux or Mac laptop, but you need to know what you are doing.

Checking out of SVN

Check out the package (-t specifies the tag that you want to use). We want the beta release. Pick a directory where you want to install RapidFit.

RapidFit doesn't at this time of writing (22/11/2010) have a stable version which should be downloaded and run, instead I recommend running trunk at this time:

svn co svn+ssh://cern-username@svn.cern.ch/reps/lhcbedinburgh/Code/Fitting/RapidFit/trunk


export RAPIDFITINSTALL=~/lhcb/beta_s/Fitting/RapidFit
export RAPIDFITVERSION=tags/mc09_fitting_validation                   #     tags/beta_20091124   # only tags/mc09_fitting_validation in repo  03/05/10
mkdir -p $RAPIDFITINSTALL/tags
svn co svn+ssh://cern-username@svn.cern.ch/reps/lhcbedinburgh/Code/Fitting/RapidFit/$RAPIDFITVERSION

Set up your ROOT environment

Now make sure that your ROOT environment is setup. ROOTSYS below is set appropriately for working on the PPE machines. You can put the stuff below into a script that you source, if you want.

export ROOTSYS=/Disk/lochnagar0/general/root/5.24.00_slc5_gcc34_bin
export PATH=${ROOTSYS}/bin:${PATH}:
export DYLD_LIBRARY_PATH=${ROOTSYS}/lib:${DYLD_LIBRARY_PATH} # only needed for Mac OS X


Change into the directory containing the code and compile. Make sure that you set the path correctly for your installation.

make -j3 # -j3 will probably be beinificial on most machines

Run a fit!

cd $RAPIDFIT/bin
./fitting -f $RAPIDFIT/config/RaPDFToy_noBkg.xml

Now check the output? Do the results look good? See some examples below.

Running a job on the PPE Condor cluster using Ganga

To properly perform systematic studies using RapidFit, it will be essential to run many toys. To speed things up it is useful to be able to run these toys in parallel on a batch system. In Edinburgh we have two such batch systems: Condor is available in PPE and the ECDF system which requires you to log into and compile your code on a separate frontend machine. For the moment, we have made available a simple script that will allow you to run your toy study on Condor by submitting many subjobs using Ganga.

> setupLHCb
> GangaEnv
> ganga
[1] load( '/path/to/Fitting/RapidFit/scripts/GangaJobForEdinburghCondor.py' )
[2] jobs[-1].submit()

Post-processing of the Condor jobs

The Condor jobs will produce many fit results files which Ganga merges together for you. We have developed a pyROOT script which will summarise this merged file for you and produce a table of the pull plot statistics for each of the physics parameters that are floated in the fit. After setting up your ROOT environment do this:

python $RAPIDFIT/scripts/PrintLatexTableOfPullResults.py $RAPIDFIT/config/your_fit_config.xml /path/to/merged/outout/pullPlots.root /path/to/outputfile.root

Fitter Configuration

XML Config file

Description of RapidFit's XML configuration format.

Command line arguments

Description of RapidFit's Command line arguments.

Source code


The code has some (limited) Doxygen markup inside it. The online class list etc can be found here.

Write your own!

The intention of the RapidFit framework is that most components are interchangeable, and so new classes can easily be created and used. An obvious example is the creation of PDFs: all different functions, but implementing the same interface. Advice on creating your own PDF can be found here.

Once you have written your own class for RapidFit, to make it accessible you simply add an appropriate entry in ClassLookUp.cpp.

The PDFs which are available

J/PsiPhi Signal

RaPDF_Bs2JpsiPhi J/PsiPhi signal
Description This is the classic J/PsiPhi PDF containing the time and angle factors, as well as ancillary parameters such as Bs mass difference, mistag rate...etc.
Parameters: "gamma"
"deltaGamma "
"deltaM "
Observables: "time"
RaPDF_Bs2JpsiPhiNew J/PsiPhi signal with event-by-event mistag
Description As above but the mistag is now promoted to an event-by-event observble.
Parameters: "gamma"
"deltaGamma "
"deltaM "
Observables: "time"
RaPDF_Bs2JpsiPhiMassSignal Bs mass distribution model PDF
Description This is the factorised mass distribution PDF incorporating two gaussians as per the roadmap model. The gaussians each have a different width, and are specified by a relative fraction. All of these parameters can be floated in the fit
Parameters: "f_sig_m1"
Observables: " mass"

To use just a time+angles PDF in your xml configuration file you only need to specify:


To connect the time+angles PDF together with the mass PDF in the xml configuration file you need the following:


J/PsiPhi Background

Long lived Background

For the long lived background component the following sets of background PDFs are available:

RaPDF_Bs2JpsiPhiLongLivedBkg J/PsiPhi long lived background time component
Description This is the time component of the long lived background. It has two exponential components and is designed to be exactly as per the roadmap fits. It ignores the decay angles so there will have a flat distribution.
Parameters: "tau_LL1" - first component decay width
"tau_LL2" - second component decay width
"f_LL1" - fraction of the first component
Observables: "time"
RaPDF_Bs2JpsiPhiMassBkg J/PsiPhi long lived background mass component
Description This is the mass PDF for the background consisting of a single shallow exponential
Parameters: "alphaM_pr" - (negative) coefficient of mass in exponential
Observables: "mass"

To connect the time and mass components together for the long lived background you use the following xml in the configuration file:


Prompt background

For the prompt background component the following sets of background PDFs are available. Note that there is no meaning to this component without time resolution as the Gaussian shape comes purely from this effect.

RaPDF_Bs2JpsiPhiPromptBkg_withTimeRes J/PsiPhi prompt background time component
Description This is the time component of the long lived background. It is a single Gaussian.
Parameters: "sigmaPr" - Gaussian width
Observables: "time"
RaPDF_Bs2JpsiPhiMassBkg J/PsiPhi prompt background mass component
Description This is the mass PDF for the background consisting of a single shallow exponential
Parameters: "alphaM_pr" - (negative) coefficient of mass in exponential
Observables: "mass"

To connect the time and mass components together for both the long lived and prompt backgrounds you use the following xml in the configuration file. Note the need to use Normalised SumPDF. The fraction which appears here is the fraction of prompt background out of all background (this is different to the number appearing in the roadmap which specifies the fraction out of total signal plus background. Note lso that these fractions are different for the tagged and untagged categories since the tag efficiency is different for each PDF.


Installing the Boost libraries

The code uses some of the Boost libraries and so you need to install the Boost headers in order for RapidFit to compile. This is already done for you on the PPE machines.

Examples of outputs

The result of a single toy fit

Looks good smile

Fit status: 3
Minimum function value: 415173
Parameter & Fit result and error & $\sigma$ from input \hline \hline
          gamma &   0.681572 \pm  0.0039162 &   0.401491\\
     deltaGamma &  0.0574591 \pm  0.0106509 &  -0.238563\\
       Aperp_sq &   0.163415 \pm 0.00351309 &   0.971969\\
       Azero_sq &   0.594878 \pm 0.00273006 &   -1.87617\\
     delta_para &    2.48406 \pm  0.0170225 &  -0.936166\\
     delta_perp &  -0.191639 \pm  0.0225572 &  -0.959274\\
     delta_zero &          0 \pm          0 &        nan\\
         deltaM &    17.8018 \pm  0.0100803 &   0.173641\\
          Phi_s & -0.0393056 \pm 0.00580637 &   0.119593\\

Pull plots from multiple toy studies

  • Phi_s.png:

  • deltaGamma.png:

Validation Testing

The following are a set of results from specific versions of RapidFit and are intended as reference validations.

Signal only

This validation is on signal only. Fit conditions were:

Condition Value
RapidFit version xyz.123
Pdf description Signal J/PsiPhi with mass included
Pdf description RaPDF_Bs2JpsiPhiNew x RaPDF_Bs2JpsiPhiMassSignal
tagged events 65000
untagged events 55000
total 110k

The xml configuration file was : t.b.d

Here is a single output from one fit:

Parameter & Fit result and error & $\sigma$ from input \\ \hline 
      $\gambar $         &    0.70036 $\pm$   0.002613 &       0.14\\
      $\dgam  $       &   0.083277 $\pm$  0.0079217 &     -0.091\\
      $\aperp^2$ &    0.23231 $\pm$   0.003606 &      -0.19\\
      $azero^2$  &    0.55734 $\pm$   0.002538 &       0.53\\
      $delta_para$ &    -2.9411 $\pm$   0.061306 &      -0.18\\
     $delta_perp$ &     2.8579 $\pm$    0.05754 &      -0.91\\
     $delta_zero$ &          0 $\pm$          0 &        nan\\
         $deltaM$ &      17.77 $\pm$          0 &        nan\\
          $Phi_s$ &  -0.032297 $\pm$   0.022041 &        0.2\\
       $f_sig_m1$ &       0.74 $\pm$          0 &        nan\\
       $sigma_m1$ &       13.2 $\pm$          0 &        nan\\
       $sigma_m2$ &       22.5 $\pm$          0 &        nan\\
           $m_Bs$ &     5366.4 $\pm$          0 &        nan\\

Here is a summary of results taken from 1000 toy studies:

Key results
Parameter RapidFit Precision
Gamma x
DeltaGamma x
Aperp x
Azero x
deltaPar x
deltaPerp x
Phi_s x

Signal + Background

This validation is on signal plus background . Fit conditions were:

Condition Value
RapidFit version xyz.123
Pdf description Signal J/PsiPhi with mass included + Prompt background + long Lived background
Pdf description see xml
Fractions Fractions of S and B were exactly as taken from the Roadmap note
tagged events 166000
untagged events 221000
total 387k

The xml configuration file was : * RaPDFToy_SigBkg_VALIDATION-4.xml: this will be superceded

Here is a single output from one fit:

 Parameter & Fit result and error & $\sigma$ from input \\ \hline \hline
          gamma &    0.70247 $\pm$  0.0031237 &       0.79\\
     deltaGamma &   0.071063 $\pm$  0.0094299 &       -1.4\\
      Aperp\_sq &    0.24041 $\pm$  0.0049948 &        1.5\\
      Azero\_sq &    0.55581 $\pm$  0.0033243 &     -0.058\\
    delta\_para &    -2.9903 $\pm$    0.10358 &      -0.58\\
    delta\_perp &     2.8271 $\pm$   0.083171 &         -1\\
    delta\_zero &          0 $\pm$          0 &        nan\\
         deltaM &      17.77 $\pm$          0 &        nan\\
         Phi\_s &  -0.046876 $\pm$   0.027136 &      -0.37\\
       tau\_LL1 &      1.114 $\pm$          0 &        nan\\
       tau\_LL2 &      0.161 $\pm$          0 &        nan\\
         f\_LL1 &       0.22 $\pm$          0 &        nan\\
        sigmaPr &      0.044 $\pm$          0 &        nan\\
LongLivedFractionTagged &       0.37 $\pm$          0 &        nan\\
SignalFractionTagged &        0.4 $\pm$          0 &        nan\\
LongLivedFractionUntagged &       0.13 $\pm$          0 &        nan\\
SignalFractionUntagged &       0.23 $\pm$          0 &        nan\\

Here is the comparison to the roadmap document taken from the results of 1000 toy studies:

Key results comparison to roadmap
Parameter Roadmap precision RapidFit Precision
Gamma 0.0031 0.0031
DeltaGamma 0.0091 0.0094
Aperp 0.0042 0.0046
Azero 0.0031 0.0033
deltaPar 0.074 0.103
deltaPerp 0.089 0.083
Phi_s 0.030 0.026


See this talk on the validation of the sWave PDF: http://indico.cern.ch/getFile.py/access?sessionId=0&resId=0&materialId=1&confId=63533


This has been implemented in the code using the proposal given here . The XML syntax is like this (using gamma in the 2010 analysis)


Starting from DecayTreeTuple

For convenience there is a script for converting from DecayTuple names of columns to the names RapidFit assumes here

To use:

Determining the acceptance factors

To determine angular acceptance factors for the signal channel:

  • Find some full simulated Monte Carlo
  • Modify your XML only to have the signal PDF for the angular/time acceptance (no mass PDF)
  • ../bin/fitting -f myXML.xml --calculateAcceptanceWeights

-- GreigCowan - 07 May 2009

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt CreateNtupleWithCorrectObservableNames.py.txt r1 manage 2.8 K 2010-10-22 - 13:24 MatthewNeedham  
Texttxt CreateNtupleWithCorrectObservableNamesNew.py.txt r1 manage 2.8 K 2010-10-22 - 13:24 MatthewNeedham  
PNGpng Phi_s.png r1 manage 14.7 K 2009-10-09 - 15:21 GreigCowan  
XMLxml RaPDFToy_SigBkg_VALIDATION-4.xml r1 manage 8.0 K 2009-12-03 - 15:35 PeterClarke example of VALIDATION-4 - but this will be superceded
PNGpng deltaGamma.png r1 manage 14.4 K 2009-10-09 - 15:21 GreigCowan  
Edit | Attach | Watch | Print version | History: r22 < r21 < r20 < r19 < r18 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r22 - 2013-05-24 - RobCurrie
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback