B2CHARM-WEBPAGE

Google Summer Of Code 2021 Project

This project was part of Google Summer Of Code 2021 under CERN-HSF organisation. Mentors Daniel Johnson and Thomas Kuhr belong to HFLAV group in CERN. All the work done for GSoC is contained in this single repository.

Project Information

Title - Add support for in-browser interactive averaging of physics results

Project Proposal Link - https://docs.google.com/document/d/183ITuSvIMG3v7gPLlFWi2ONiAPeLQZEcs5Es1k-OSPU/edit?usp=sharing

Project Link( GSoC Website ) - https://summerofcode.withgoogle.com/projects/#5762974599348224

PreTask Repository Link - https://github.com/harshnitk17/hflav

Project Repository Link - https://gitlab.cern.ch/hflav/b2charm-webpage

Application Deployment Link - https://averages-hflav-b2charm-tst.app.cern.ch/

Student - Harsh Prakash Gupta (harshprakashgupta@gmail.com)

Mentors - Thomas Kuhr (Thomas.Kuhr@lmu.de) & Daniel Johnson (d.j@cern.ch)


Setting Up Application Locally

The application uses PostgreSQL Database to store and process data and DJANGO framework as backend. Before setting up Django application, we need to install PostgreSQL on our local machine. All python libraries including Django must be preferably run inside a virtual python environment.

Installing PostgreSQL on Ubuntu

Follow this tutorial from DigitalOcean on how to install PostgreSQL

Setting up Python Environment

Upgrade pip to latest version : python3 -m pip install --user --upgrade pip

Installing virtualenv : python3 -m pip install --user virtualenv

Creating a virtual environment : python3 -m venv <environment_name>

Activating a virtual environment : source <environment_name>/bin/activate

Cloning repository and installing dependencies

Clone b2charm-webpage repository : git clone https://gitlab.cern.ch/hflav/b2charm-webpage.git

Go inside the directory : cd b2charm-webpage

Install required dependencies : pip3 install -r requirements.txt

Setting up environment variables

Project depends upon some environment variables to figure out database connections

Open ~/.bashrc file : sudo gedit ~/.bashrc

Add the following lines in bashrc file and save it.


export DATABASE_SERVICE_NAME=postgresql
export DATABASE_ENGINE=postgresql
export DATABASE_NAME=<database_name>
export DATABASE_USER=<database_user>
export DATABASE_PASSWORD=<database_password>
export postgresql_SERVICE_HOST=127.0.0.1
export postgresql_SERVICE_PORT=5432
export DJANGO_SECRET_KEY=<django_secret_key>

Running Application Server

Run makemigrations command : python3 manage.py makemigrations

Migrate : python3 manage.py migrate

Dump data into database : python3 manage.py runscript dump_data

Generate plots for each branching fraction : python3 manage.py runscript generate_graphs

Run Development server : python3 manage.py runserver <port_number>

Go to : localhost:<port_number> , from any browser.


User Manual for the application

1. Yellow columns (Initial Particle and Type of observable) are single-select only i.e. can't select more than one option from a column at a given time.

2. Blue columns (Charm mesons,etc.) are multi-select i.e you can select more than one filter from a column at a given time.

3. You can select a filter by clicking on it, which will then turn green and then deselect the same filter by clicking again on it, which will turn it again back to grey.

4. For the multi-select filters you can also set the number of such particles present in branching fraction through "Child Particle Numbers" column. Clicking '+' increases number 1 and clicking '-' decreases number by 1.

5. To view details of an individual branching fraction, click on 'Detail' ,present on right side of each row.

6. To clear all filters i.e deselect everything, click 'Clear Filters' button present on top-right of the nav bar

7. To generate overview plot of select fractions, select the fractions you want to plot, by clicking on the checkboxes presnt at leftmost of each row, and click on 'Generate Overview Plot' button present at the bottom of the table.

Project's Initial Requirements

The Heavy Flavour AVeraging (HFLAV) group is responsible for collecting and combining measurements made at different High Energy Physics (HEP) experiments, at CERN and other particle physics laboratories, and combining them using robust statistical procedures. This group helps various scientists and researchers all over the world working in the field of particle physics to find the state of the art results from all over the field of particle physics, containing different kinds of experiments and measurements. The ‘Beauty to Charm’ subgroup is responsible for combinations of various measurements that involve the decay of a particle containing a Bottom Quark(or b-quark) to any final state where one of the particles involves a Charm Quark (or c-quark).

HFLAV averages are published periodically in peer-reviewed publications and journals. The HFLAV website provides a live snapshot of the latest data obtained from these latest publications. So the scientists and researchers all over the world can have quick access to these averages essential to their work anytime. The website contains numerous branching fractions i.e different configurations of b quarks transforming into c quarks. The biggest issue present was that the website was static i.e. written in pure HTML and had no backend framework or a database to store data. Also the website was hosted using CERN's EOS service which could only handle static websites. Need grew for the website to support user input i.e dynamic website which can respond back on basis of user input. Present framework that was only HTML could not support such behaviour thus there was a need to switch framework. Framework used for this project is Django.

This project aims to improve the experience of users using the HFLAV website. These averages could be of greater value to the particle physics community if the accessibility, interactivity and visibility of the current website can be improved. Thus this project seeks to transform user interaction with HFLAV’s ‘Beauty to Charm’ averages. The plan to increase the accessibility is by redesigning the whole user interface, making it easier to find a relevant data point ( branching fraction), by making use of dynamic tables using the DataTables plugin in jQuery which would enable easier searching of a particular data point through various filters like Initial Particle, Final Particle, etc. Interactivity and visibility will be increased by allowing the user to pick various branching fractions and plot their overview plot ( a plot showing combined averages of selected fractions). Also earlier data was stored directly in HTML pages which was unsafe as well as inefficient , introducing a backend framework like Django allows us to use a Database system like PostgreSQL to store data in.

Technologies Used

Changes Made (Work Done)

Week Work Done Corresponding Commits
Week 1
  • Understanding Averaging tool.
  • Initialising Django project with a PostgreSQL database
  • Writing a python script to add data to PostgreSQL database, generating data from Averaging Tool using its "--dump" option.
Week 2
  • Add form for filters, add first and second filter columns
  • Write controller function for processing AJAX call made by filter form
Week 3
  • Add more fields in Filter Form for multi select columns.
  • Write Controller logic on how to filter data from database according to Filter data being sent through the Ajax call, Send response back to the Ajax function.
Week 4
  • Upon succesful response from a Ajax call, use that response to fill a DataTable
  • Configure MathJAX settings, to display Branching Fraction equations in Latex inside the browser.
  • Make Value and Error of a branching fraction according to MathJAX's required format, so that they can be displayed in LATEX in the browser.
Week 5
  • UI Changes for Filter buttons, use CSS and jQuery to design buttons and their behaviour when selected and deselected.
Week 6
  • Design a REGEX pattern such that it can be used for pattern matching in Django routes for individual detail page of a branching fraction.
  • Write controller function and template to render the details page of an individual branching fraction, details of a branching fraction is fetched from database.
Week 7
  • Use jquery-datatables-checkboxes plugin of jQuery to create checkboxes and a form which can submit selected fractions to the controller using a Ajax call.
  • Write controller function to process incoming request of the Ajax call and draw overview plot using functions from Averaging tool and send back the location of saved plot as Ajax response.
  • Write a auto-delete function for overview plots which will deleted saved plots after specific time
Week 8
  • Refactored code in such a way that now the application uses specified configuration in particles.py in Averaging Tool to generate filters, earlier filters were hardcoded inside the Django application.
  • Refactored jQuery code and reduced code redundancy
  • Added download button for generated overview plot
  • Added clear all filters button and its corresponding logic.
Week 9
  • Read openshift documentation
  • Added specific openshift scripts , deployed temprorary application by manually configuring many settings.
  • Added assemble script which creates neccesary python virtual environment and install dependencies in the container.
  • Added run script which is ran immediately after an image is started in a pod, contains commands to migrate database,generate plots, dump data and run server.
  • Added Dockerfile which specifies how to run 'assemble' and 'run' scripts.
  • Finished application deployment on OpenShift
Week 10
  • Completed Inline documentation
  • Bug Fixes
  • Updated Readme

Deployment on CERN Openshift cluster

CERN's Platform-as-a-Service (PaaS) can be used to deploy and host applications in the CERN computing environment. The latest generation of CERN's PaaS is based on the newest community version of OpenShift: OKD4 (a.k.a. Openshift 4). You need a CERN username and password to access this service. [Link to OKD Web UI](https://paas.cern.ch/). Detailed documentation about this service and steps for deployment can be found [here](https://paas.docs.cern.ch/).

Work Left