Project

General

Profile

Python-based EDM analysis » History » Version 8

« Previous - Version 8/22 (diff) - Next » - Current version
Gleb Lukicov, 10/27/2019 05:57 PM


Python-based EDM analysis

Python is awesome! You can start using it for your analysis in two ways: 1) writing Python-based ROOT macros (pyROOT), or interact with ROOT files directly in a JupyerLab environment (JupyROOT) 2) Convert ROOT file into Numpy/HDF/etc. format and fit using Python tools directly (e.g. scipy-optimize).

JupyROOT/pyROOT

To install JupyterLab on your laptop follow the instructions here: https://jupyterlab.readthedocs.io/en/stable/
Make sure to go via the pip installation route (not anaconda!).

Many tutorials to get started with Jupyter are also available (e.g. https://www.dataquest.io/blog/jupyter-notebook-tutorial/)

Finally, test that you can import ROOT into your JupyteLab notebook (e.g. https://root.cern.ch/notebooks/HowTos/HowTo_ROOT-Notebooks.html)
If you have ROOT installed via homebrew, you might need to import the path to ROOT explicitly i.e. (in the very first cell)

import sys
# add brew ROOT (Mac) to the system path
sys.path.append("/usr/local/Cellar/root/6.18.04/lib/root")
import ROOT as r

Alternatively, add "export JUPYROOT=/usr/local/Cellar/root/6.18.04/lib/root" to your .bash_profile and
import sys
# add brew ROOT (Mac) to the system path
sys.path.append(os.environ["JUPYROOT"]) 
import ROOT as r

Then you only need to change the path to ROOT in a single place, if you decide to update ROOT on your laptop.

Blinding
To get started you need to set-up the official blinding tools on your laptop here: https://cdcvs.fnal.gov/redmine/projects/gm2analyses/wiki/Library_installation
Then go to the bottom of that page, and follow "Using the code in Python3". There are already examples provided for a 5 parameter fit by Kim!

Here is one for the tracker fit for an EDM-based analysis
https://github.com/glukicov/EDMTracking/blob/master/SimpleBlindedFit.ipynb

That's it! The rest is the same as using a ROOT C macro, but being in a Jupyer environment one can execute things interactively and use native Python plotting tools.

ROOT-independent analysis
*This section will be updated with more details soon *