Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update standalone LCG setup instructions #1021

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
cmake_minimum_required( VERSION 3.11 FATAL_ERROR )
set(CMAKE_CXX_STANDARD 17)
project(CMSCombine VERSION 0.0.1)
project(HiggsAnalysisCombinedLimit VERSION 0.0.1)

option( MODIFY_ROOTMAP "Modify generated Rootmap to take out classes already bundled in StatAnalysis" FALSE )
option( INSTALL_PYTHON "Install the Python library and scripts" TRUE )

# Can build with CMake after e.g. setting up StatAnalysis release like this:
# export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
Expand All @@ -25,7 +26,7 @@ include_directories(${ROOT_INCLUDE_DIRS})
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(${ROOT_CXX_FLAGS})

set(LIBNAME CMSCombine)
set(LIBNAME HiggsAnalysisCombinedLimit)

file(GLOB HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} interface/*.h*)
file(GLOB SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.c*)
Expand Down Expand Up @@ -103,9 +104,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/HiggsAnalysis/CombinedLimit/src/classe
# Install the "combine" executable in the bin directory.
install(TARGETS combine DESTINATION bin)

# Install the scripts like "text2workspace" to the bin directory.
install(DIRECTORY scripts/ DESTINATION bin)

# This block is commented out for now, while using the less sophisticated location below
# Check if the Python library installation directory is outside the install
# prefix. If it is, we error out because CMake should not install files outside
Expand All @@ -123,16 +121,20 @@ install(DIRECTORY scripts/ DESTINATION bin)
## The the Python library installation directory relative to the install prefix.
#file(RELATIVE_PATH Python_SITELIB_IN_PREFIX ${CMAKE_INSTALL_PREFIX} ${Python_SITELIB})

set(Python_SITELIB_IN_PREFIX "python")
if(INSTALL_PYTHON)
# Install the scripts like "text2workspace" to the bin directory.
install(DIRECTORY scripts/ DESTINATION bin)

set(Python_SITELIB_IN_PREFIX "python")

message (STATUS "Using Python install location:" ${Python_SITELIB_IN_PREFIX})
# The python package will be installed in such a way that the original
# CMSSW-style directory structure is kept, for maximal compatibility.
install(DIRECTORY python/ DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)
message (STATUS "Using Python install location:" ${Python_SITELIB_IN_PREFIX})
# The python package will be installed in such a way that the original
# CMSSW-style directory structure is kept, for maximal compatibility.
install(DIRECTORY python/ DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)

# Create empty __init__.py files in the Python package subdirectories such that
# the Python imports work.
file(TOUCH ${empty_init_py})
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis)
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)
# Create empty __init__.py files in the Python package subdirectories such that
# the Python imports work.
file(TOUCH ${empty_init_py})
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis)
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)
endif()
31 changes: 31 additions & 0 deletions demo_lcg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Need to run with "./demo_lcg.sh" on lxplus9

# Setup LGC release and paths
source ./env_lcg.sh

# For the python part, it is recommended to install it as a python package
# into your virtual environment (see setup.py). Do this AFTER the LCG
# environment setup to use a consistent Python version.

mkdir -p .python/HiggsAnalysis
ln -s $PWD/python $PWD/.python/HiggsAnalysis/CombinedLimit
touch $PWD/.python/HiggsAnalysis/__init__.py
touch $PWD/.python/HiggsAnalysis/CombinedLimit/__init__.py

python3 -m venv virtualenv
source virtualenv/bin/activate

python3 -m pip install -e .

# Now, build the C++ part of combine
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install -DINSTALL_PYTHON=FALSE ..
make install -j4
cd ..

# Run the following combine "hello world" example
text2workspace.py data/tutorials/CAT23001/datacard-3-parametric-analysis.txt
combine -M MultiDimFit -m 125.38 data/tutorials/CAT23001/datacard-3-parametric-analysis.root
12 changes: 8 additions & 4 deletions env_lcg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
. /cvmfs/sft.cern.ch/lcg/views/LCG_102/x86_64-centos7-gcc11-opt/setup.sh
export PATH=${PATH}:${PWD}/build/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/build/lib
export PYTHONPATH=${PYTHONPATH}:${PWD}/build/lib/python
LCG_RELEASE=dev4 # or dev3 for ROOT master (dev4 is the latest ROOT stable branch)
LCG_PATH=/cvmfs/sft.cern.ch/lcg/views/$LCG_RELEASE/latest/x86_64-el9-gcc13-opt

source $LCG_PATH/setup.sh
source $LCG_PATH/bin/thisroot.sh

export PATH=$PWD/install/bin:$PATH
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
10 changes: 0 additions & 10 deletions env_standalone_root_master.sh

This file was deleted.

51 changes: 51 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import setuptools

# This setup script lets you install the Python part of combine like a standard
# Python package. The big advantage of it is you can make an in-place
# installation into your virtual environment, which means you can change the
# Python files in this repo, and the changes will be effective immediately
# without any recompilation or reinstallation.

# Before installing the package, run in this repo:
# mkdir -p .python/HiggsAnalysis
# ln -s $PWD/python $PWD/.python/HiggsAnalysis/CombinedLimit
# touch $PWD/.python/HiggsAnalysis/__init__.py
# touch $PWD/.python/HiggsAnalysis/CombinedLimit/__init__.py

# To do an in-place installation, it's best to create and activate a virtual
# environment, if you don't have done so already:
# python3 -m venv <directory>
# source <directory>/bin/activate

# Finally, the in-place installation (for regular installation, drop the "-e"):
# python3 -m pip install -e .

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

scripts = [
"combineCards.py",
"plotGof.py",
"pruneUncerts.py",
"combineTool.py",
"plotImpacts.py",
"text2workspace.py",
"commentUncerts.py",
"plot1DScan.py",
"plotLimitGrid.py",
"plotBSMxsBRLimit.py",
"plotLimits.py",
]

setuptools.setup(
name="HiggsAnalysisCombinedLimit",
version="1.0",
description="CMS Combine",
author="The CMS Collaboration",
long_description=long_description,
long_description_content_type="text/markdown",
package_dir={"": ".python"},
packages=setuptools.find_packages(where=".python"),
python_requires=">=3.8",
scripts=["scripts/" + filename for filename in scripts],
)
82 changes: 0 additions & 82 deletions test/compile-standalone.sh

This file was deleted.

Loading