Skip to content

Installation

Gourab Saha edited this page Jun 5, 2024 · 7 revisions

A quick guide to create and link properly your CPinHToTauTau working repository πŸ‘Ύ

  1. Clone the analysis repository :
[https] git clone --recursive https://github.com/<your_git_username>/CPinHToTauTau.git
[ssh]   git clone --recursive [email protected]:<your_git_username>/CPinHToTauTau.git
  • or, git clone directly
git clone --recursive https://github.com/DesyTau/CPinHToTauTau.git
  1. Then set cmsdb as follows:

If you have not forked the cmsdb, you can do the following

cd CPinHToTauTau/modules/cmsdb
git checkout master
git remote remove origin
git remote add desytau https://github.com/DesyTau/cmsdb.git
git remote add upstream https://github.com/uhh-cms/cmsdb.git

else, in addition, inside CPinHToTauTau/modules/cmsdb, do

git remote add origin <link_to_your_forked_repo>
  1. Check if everything is in place by:
git remote -v

You should see something like this:

desytau https://github.com/DesyTau/cmsdb.git (fetch)
desytau https://github.com/DesyTau/cmsdb.git (push)
origin  <link_to_your_forked_repo> (fetch)  # if use forked repo remote
origin  <link_to_your_forked_repo> (push)   # if use forked repo remote
upstream        https://github.com/uhh-cms/cmsdb.git (fetch)
upstream        https://github.com/uhh-cms/cmsdb.git (push)
  1. Besides, you need to pull the current cmsdb version from DesyTau/cmsdb:
git pull desytau master

You may encounter some conflicts between DesyTau/cmsdb and uhh-cms/cmsdb that need to be resolved each time you pull... it is what it is! In case, if you do not see the conflicts, you can use git pull desytau master --no-ff... resolve the conflicts manually and cmsdb done !

  1. Everything should be in a good shape now, go back to your local CPinHToTauTau repository:
cd ../..
# run the setup.sh. 
# warning!!! want to use ROOT / SVFit / FastMTT? Do not source the environment here !!! skip this step ...
source setup.sh <your_favorite_name> e.g. babushcha
# Please follow the instructions below 

Enjoy your perfectly github-linked local repository πŸ₯‡


Let's dive deep ... 🀿

Do you want to use SVFit and (/or) FastMTT inside Columnflow ? πŸ‘©β€πŸ”¬

You have to install ClassicSVfit first. The ClassicSVFit package is used for di-tau mass reconstruction.
Version used : fastMTT_19_02_2019.

Installation path in the analysis:

cd modules
mkdir extern 
cd extern

Installation instructions:

The installation is done without CMSSW because of incompatibility of Columnflow (using gfal) and CMSSW. It is possible to build the software without CMSSW framework if the following prerequisites are satisfied (oldest software version the instructions were tested with):

ROOT (6.10/3 or newer)
GCC (6.3 or newer)

In order to install the code, execute:

# git clone https://github.com/SVfit/ClassicSVfit TauAnalysis/ClassicSVfit -b fastMTT_19_02_2019
git clone https://github.com/oponcet/ClassicSVfit.git TauAnalysis/ClassicSVfit -b fastMTT_19_02_2019
# It will become the same as the above commented line after a PR
export LIBRARY_PATH=$LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib
make -f TauAnalysis/ClassicSVfit/Makefile -j4

You can try running SVFit with :

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib
./TauAnalysis/ClassicSVfit/exec/testClassicSVfit

If everything goes right, this should produce a root file.

ClassicSVFit/FastMTT in Columnflow from C++ needs a Wrapper 🎁

In order to use ClassicSVFit in Columnflow, the pybind11 wrapper has been used. The wrapper for the different classes can be found here : pybind_wrapper.cpp [the last link will be updated soon]

The cloned ClassicSVFit already contains the pybind11 and the wrapper itself. A few more things to modify [hard-coded, please be patient !!!]

open TauAnalysis/ClassicSVfit/wrapper/CMakeList.txt
change L10 and L33

Now, this wrapper needs to be compiled with :

export LIBRARY_PATH=$LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/
cmake -S TauAnalysis/ClassicSVfit/wrapper/ -B TauAnalysis/ClassicSVfit/wrapper/
make -C TauAnalysis/ClassicSVfit/wrapper/

It should produce a .so file which can be used as a module in Columnflow. For example you can import it like :

from modules.extern.TauAnalysis.ClassicSVfit.wrapper.pybind_wrapper import *

How to use ROOT in Columnflow 🌲

Before starting each session and before configuring your ColumnFlow setup, ensure that you import the necessary library. For ROOT, if you're working in lxplus, you can execute the following command:

LD_LIBRARY_PATH=/usr/local/lib
CPPYY_BACKEND_LIBRARY=/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/libcppyy_backend3_9.so
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/bin/thisroot.sh 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/
source setup.sh enveos 
CPPYY_BACKEND_LIBRARY=/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/libcppyy_backend3_9.so
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/bin/thisroot.sh 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/

and then in one of your producer/selector/calibrator, import the ROOT module :

root = maybe_import("ROOT")

You can check if the module has succesfully been imported by just printing :

print("root module : ", root)

Then you can simply use it to plot some awkward array like :

# Convert your awkward array to numpy array : 
leps1_mass = ak.to_numpy(leps1["mass"])
# Create a TH1D histogram for metx
hist1 = root.TH1D("hist_mass_leps1", "mass", 50, 0, 5)
# Fill the histogram with metx values
for mass in leps1_mass: hist1.Fill(mass)
# Draw the histogram
hist1.Draw()
# Save the histogram in a root file
root_file = root.TFile("hist_mass1.root", "RECREATE")
hist1.Write()
root_file.Close()

See example of a producer using ROOT : svfit.py

To access ROOT, SVFit and FastMTT:

Do the following before starting each session :

LD_LIBRARY_PATH=/usr/local/lib
CPPYY_BACKEND_LIBRARY=/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/libcppyy_backend3_9.so
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/bin/thisroot.sh 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/modules/extern/TauAnalysis/ClassicSVfit/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/
export LIBRARY_PATH=$LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib
source setup.sh hcp
CPPYY_BACKEND_LIBRARY=/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/libcppyy_backend3_9.so
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/bin/thisroot.sh 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/modules/extern/TauAnalysis/ClassicSVfit/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.30.04/x86_64-centosstream9-gcc113-opt/lib/
export LIBRARY_PATH=$LIBRARY_PATH:$PWD/TauAnalysis/ClassicSVfit/lib