Skip to content

The official LHCb run3 detector, geometry, event data modern web display at CERN

License

Notifications You must be signed in to change notification settings

andrewpap22/LHCb_WebDisplay

Repository files navigation

πŸ–₯️ LHCb Web Event && Geometry Display Project

This project was generated with Angular CLI version 12.1.0.

License Repository Size Last Commit Open Issues Open Pull Requests Open Source

Hits

πŸš€ Up on

πŸ“‚ Project Structure

.
β”œβ”€β”€ angular.json
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ karma.conf.js
β”œβ”€β”€ LICENSE
β”œβ”€β”€ nginx.conf
β”œβ”€β”€ package.json
β”œβ”€β”€ projectStructure.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ src
β”‚  β”œβ”€β”€ app
β”‚  β”‚  β”œβ”€β”€ app.component.html
β”‚  β”‚  β”œβ”€β”€ app.component.scss
β”‚  β”‚  β”œβ”€β”€ app.component.spec.ts
β”‚  β”‚  β”œβ”€β”€ app.component.ts
β”‚  β”‚  β”œβ”€β”€ app.module.ts
β”‚  β”‚  β”œβ”€β”€ gltf-exporter
β”‚  β”‚  β”‚  β”œβ”€β”€ gltf-exporter.component.html
β”‚  β”‚  β”‚  β”œβ”€β”€ gltf-exporter.component.scss
β”‚  β”‚  β”‚  β”œβ”€β”€ gltf-exporter.component.spec.ts
β”‚  β”‚  β”‚  └── gltf-exporter.component.ts
β”‚  β”‚  β”œβ”€β”€ home
β”‚  β”‚  β”‚  β”œβ”€β”€ home.component.html
β”‚  β”‚  β”‚  β”œβ”€β”€ home.component.scss
β”‚  β”‚  β”‚  β”œβ”€β”€ home.component.spec.ts
β”‚  β”‚  β”‚  └── home.component.ts
β”‚  β”‚  └── lhcb-experiment
β”‚  β”‚     β”œβ”€β”€ lhcb-experiment.component.html
β”‚  β”‚     β”œβ”€β”€ lhcb-experiment.component.scss
β”‚  β”‚     β”œβ”€β”€ lhcb-experiment.component.spec.ts
β”‚  β”‚     └── lhcb-experiment.component.ts
β”‚  β”œβ”€β”€ assets
β”‚  β”‚  β”œβ”€β”€ event-data
β”‚  β”‚  β”‚  └── LHCbEventDataV2.json
β”‚  β”‚  β”œβ”€β”€ favicon
β”‚  β”‚  β”‚  └── favicon.ico
β”‚  β”‚  β”œβ”€β”€ geometry
β”‚  β”‚  β”‚  β”œβ”€β”€ lhcb.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run2_ECAL.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run2_HCAL.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run2_MUON.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3.root
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_ECAL.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_FT.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_HCAL.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_MAGNET.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_MagnetCover.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_MUON.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_PIPE.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_Rich_AfterMagnet.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_Rich_BeforeMagnet.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_UT.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_VP.gltf
β”‚  β”‚  β”‚  β”œβ”€β”€ LHCb_run3_VP_better_Performance.gltf
β”‚  β”‚  β”‚  └── lhcbfull.root
β”‚  β”‚  β”œβ”€β”€ icons
β”‚  β”‚  β”‚  β”œβ”€β”€ add-icon.svg
β”‚  β”‚  β”‚  └── zoom-out.svg
β”‚  β”‚  └── images
β”‚  β”‚     β”œβ”€β”€ geometry.svg
β”‚  β”‚     β”œβ”€β”€ LHCb.svg
β”‚  β”‚     β”œβ”€β”€ lhcb_logo.png
β”‚  β”‚     └── playground.svg
β”‚  β”œβ”€β”€ environments
β”‚  β”‚  β”œβ”€β”€ environment.prod.ts
β”‚  β”‚  β”œβ”€β”€ environment.single.ts
β”‚  β”‚  └── environment.ts
β”‚  β”œβ”€β”€ index.html
β”‚  β”œβ”€β”€ main.ts
β”‚  β”œβ”€β”€ polyfills.ts
β”‚  β”œβ”€β”€ styles.scss
β”‚  └── test.ts
β”œβ”€β”€ tsconfig.app.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ tsconfig.spec.json
└── yarn.lock

## I've removed lot's of stuff from assets as this was getting huge.

πŸ’¬ Summary

The following project consists of an important part of my work @CERN as a Software Engineer (TECH) for the years of 2021-2022 on the LHCb the Large Hadron Collider beauty experiment.

In Particular it consists of two parts.

  1. The LHCb Web Event and Geometry display itself
  2. The .root to .gltf Exporter

Details:

πŸ–₯️ LHCb Web Event and Geometry Display

The project is mainly using the Phoenix Framework for it's UI which was selected for the years of 2019 and 2020 as a Google Summer of Code GSoC Project, to which I'm a contributor!

⌨️ Local Development

For running the project locally on your machine you will need Node.js, npm and yarn.

⬇️ Get Node.js and npm

/// Note that npm comes alongside Node.js

The recommended way to get the latest versions is to use the Node Version Manager a.k.a nvm

Please do follow the instructions on the following πŸ‘‰ README.md to get latest stable versions of Node.js and npm for the family of UNIX operating systems. (MacOS and Linux) For Windows you can follow the same instructions by using gitBash or by downloading Node.js from their website.

⬇️ Get yarn, install dependencies and run the project locally

Once you have Node.js and npm, install yarn by issuing the following command:

$ npm install --global yarn

Then, do git clone the project locally and be sure you're into the ./LHCb_WebDisplay directory and then:

### Install the required dependencies 

$ yarn install

### Run the project in development / watch mode

$ yarn start

Now, LHCb_WebDisplay will start in development / watch mode. Any change made to the source code while the local server is running, will rebuild and hot reload the project itself.

You can access and view the LHCb_WebDisplay as well as the GUI for the gltf_exporter (which we'll analyse later on) by heading into the browser of your choice and typing into the address bar: http://localhost:4200/


For detailed documentation and demos about the usage of the Phoenix UI you can head over to this πŸ‘‰ URL or have a look on my πŸ–ΌοΈ final presentation given at the 102th LHCb week 2021 at CERN.

As of 2022 you will be able as well to read the published paper and poster of the project at ACAT2021


πŸ–ΌοΈ ROOT to Gltf Exporter

Introduction

It seems that a need has arose to convert GDML geometry files to a particular file format that describes a geometry, that can be supported and visualized properly by Phoenix. Hopefully by following the steps bellow you will be able to achieve it. Please do open an issue in case of problems, where friendly folks can try and help.

Convert GDML to ROOT

Root will serve as a middleman for our purpose. Root is a C++ Data Analysis Framework. One needs to install it first locally by heading into Root's πŸ‘‰ Documentation and following the steps listed over there.

Once that is done, one can write a simple C++ function that will loop over the contents of the GDML file and with the help of some of the ROOT's Framework methods it will output a proper .root file with the name specified, which we will later on use to convert it into GLTF format and visualize it into Phoenix.

The following C++ code works and serves for the above mentioned purpose. In case of problems please do open an issue and someone will try and help!

void gdml_to_root_export() 
{
    // Loading the library and geometry
    gSystem->Load("libGeom");
    TGeoManager::Import("./path_of_your_gdml_file.gdml");
    gGeoManager->SetVisLevel(4); /// the number here can be changed based on the depth of the visibility level of your gdml file and the detail that you want to visualize it. 

    // Export the geometry
    gGeoManager->Export("filename.root");
}

Keep in mind that in order for the above function to work, you should have installed the C++ ROOT Framework on your machine.

Compiling and running the above code should result in outputting the .root file from your .gdml input.

Verify that the .root file is extracted properly.

One can visualize the .root file itself to be sure that it was extracted properly. We'll provide 2 tools one can use here and one of them is Phoenix itself.

But why convert to .gltf since Phoenix supports .root visualization?

.root visualization will result into kinda a poor visualization image and also not that great of performance. Also another good reason to not stick with .root is that one can not split the .root file itself into multiple sub-parts / sub-geometries thus eliminating one of the core functionalities of Phoenix into geometry visualization. And thus a new tool was created for this very purpose.

πŸ“ ROOT to GLTF web-based tool

On the following πŸ‘‰ website you will find the new web-based tool that was created so you can first verify that your .root file was extracted properly and then translate it into .gltf so you can visualize it properly inside Phoenix.

There is enough information in the website itself, so you won't get lost but some quick steps to follow in order, would be:

  1. Import your local .root file.
  2. Do type the particular root object string in the empty box and click the button Import root.
  3. Do wait a couple of seconds and it should load automatically and you'll be able to see it visualized properly.
  4. If you don't know where to find the root object name just scroll a bit down on the page and you'll find relevant info.
  5. Go at the bottom of the page and press the button export to gltf (only if you import your root file via a URL. Importing it from your local machine will translate it automatically to gltf)
  6. It might take a couple of seconds or minutes (depending on the file size) and then your .gltf file will get downloaded locally automatically.
  7. Upload your .gltf file to the GLTF viewer at the bottom of the page and verify that it was extracted properly.
  8. Go and visualize your file inside Phoenix and play with it!

Below you can find useful gifs demonstrating the above steps!

Convert the geometry while importing the file locally from your machine

export-from-local-file

Convert the geometry while importing the file via a web browser URL

export-from-url

How to find the ROOT object name

find-root-object-name

Split your GLTF geometry into multiple parts

After extracting our geometry and visualizing into Phoenix we might want to split it into multiple subparts to visualize and play with each part of our geometry seperately.

To do that one might need to modify some code for his .gltf file but extensive documentation is written for the ease of that purpose over πŸ‘‰ here and πŸ‘‰ here!

Just follow the documentation in ether of the above links and you should be good to split your whole geometry into multiple subparts and be able to visualize into Phoenix each one of them seperately or all together with the option to enable and disable each part from the UI!

Again feel free to open an issue if stuck and some friendly folk will try and help!

πŸš€ Deployment

The project is deployed under paas.cern.ch which is the open source version of OpenShift 4 (namely okd4)

Detailed documentation on how to solve any problem that might occur with the deployment of this project can be found on the following πŸ‘‰ URL.

What we mostly care for at this point is on to how to push new changes made inside the application to the deployment.

Since the deployment of this application is linked to my CERN GitLab profile but no GitLab CI is used, you'll have to manually update the changes to the deployment after committing and pushing your new changes to the project. To do that:

Push new changes to the deployment

  1. Docker Login
docker login gitlab-registry.cern.ch
  1. Build the docker image
docker build -t gitlab-registry.cern.ch/anpappas/lhcb_webdisplay .
  1. Push the image
docker push gitlab-registry.cern.ch/anpappas/lhcb_webdisplay

After the above 3 steps, your new changes should get updated on the deployment side as well!

To verify that the changes have been applied you can of course visit the application's πŸ‘‰ webiste or head over to the repository in GitLab and under, Packages & Registries/Container Registry you should be able to diagnose if the root image has been built successfully or not and check the errors in case it's not.


Β© CERN 2021 by <Andreas> <\A. Pappas> @LHCb

About

The official LHCb run3 detector, geometry, event data modern web display at CERN

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published