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

ROOT 6.22 compatibility (CMSSW 11_2) #648

Merged
merged 21 commits into from
Apr 23, 2021
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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI/CD

on:
workflow_dispatch:
pull_request:
push:
branches:
- 112x

jobs:
build:
runs-on: ubuntu-latest
name: Test compilation using conda env

steps:
- uses: actions/checkout@master
with:
path: HiggsAnalysis/CombinedLimit # Required to match compile instructions
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2.1.1
with:
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
environment-file: HiggsAnalysis/CombinedLimit/conda_env.yml
activate-environment: combine
- name: Set up conda env variables
shell: bash -l {0}
run: |
cd HiggsAnalysis/CombinedLimit
bash set_conda_env_vars.sh
- name: Build
shell: bash -l {0}
run: |
cd HiggsAnalysis/CombinedLimit
make -f Makefile_conda -j 2
22 changes: 6 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@
################################################################################

#### SET UP YOUR ENVIRONMENT FIRST WITH ##############################
# . /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/gcc/4.9.1-cms/etc/profile.d/init.sh
# . /cvmfs/cms.cern.ch/slc6_amd64_gcc491/lcg/root/6.02.00-odfocd5/bin/thisroot.sh
# . /cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/vdt/v0.3.2-cms/etc/profile.d/init.sh
# . /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/boost/1.51.0-cms/etc/profile.d/init.sh
# . /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/xz/5.2.1/etc/profile.d/init.sh
# export PATH=${PATH}:${PWD}/exe:${PWD}/scripts
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/lib
# export PYTHONPATH=${PYTHONPATH}:${PWD}/lib/python
# source env_standalone.sh
#######################################################################

# Boost
BOOST = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/boost/1.63.0-gnimlf
VDT = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/cms/vdt/0.4.0-gnimlf
# PCRE = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/pcre/8.37-omkpbe2
GSL = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/gsl/2.2.1-omkpbe2
# LIBXML = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/libxml2/2.9.1-omkpbe2/include/libxml2
# XZ = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/xz/5.2.2-omkpbe2
# ZLIB = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/zlib-x86_64/1.2.11-omkpbe2
EIGEN = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/eigen/64060da8461a627eb25b5a7bc0616776068db58b
BOOST = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/boost/1.72.0-gchjei
VDT = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/cms/vdt/0.4.0-ghbfee
PCRE = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/pcre/8.43-bcolbf
GSL = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/gsl/2.6-bcolbf3
EIGEN = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/eigen/d812f411c3f9-ghbfee
# Compiler and flags -----------------------------------------------------------
CC = c++
ROOTCFLAGS = $(shell root-config --cflags)
Expand Down
138 changes: 138 additions & 0 deletions Makefile_conda
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
################################################################################
# HiggsAnalysis/Combined Limit Makefile #
# #
# Authors: Danilo Piparo, Giovanni Petrucciani, Mingshui Chen #
# #
# o Automatic compilation of new programs and classes*. #
# o Now generate dictionaries by genreflex #
# #
# * progs should have cpp extension, classes .cc or .cxx, and headers .h #
# #
################################################################################

#### SET UP YOUR ENVIRONMENT FIRST WITH ##############################
# conda install --name base mamba # faster conda
# mamba env create -f conda_env.yml
# conda activate combine2
# source env_conda.sh
# make -f Makefile_conda -j 8
#######################################################################

# Boost
CONDA = ${CONDA_PREFIX}
# Compiler and flags -----------------------------------------------------------
CC = c++
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs --glibs)
ROOTINC = $(shell root-config --incdir)

CCFLAGS = -D STANDALONE $(ROOTCFLAGS) -I$(CONDA)/include/boost -I$(CONDA)/include/vdt -I$(CONDA)/include/gsl -I$(CONDA)/include/eigen3 -g -fPIC
# CMSSW CXXFLAGS plus -Wno-unused-local-typedefs (otherwise we get a flood of messages from BOOST) plus -Wno-unused-function
CCFLAGS += -O2 -pthread -pipe -Werror=main -Werror=pointer-arith -Werror=overlength-strings -Wno-vla -Werror=overflow -std=c++1z -ftree-vectorize -Wstrict-overflow -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 -Xassembler --compress-debug-sections -msse3 -felide-constructors -fmessage-length=0 -Wall -Wno-non-template-friend -Wno-long-long -Wreturn-type -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=delete-non-virtual-dtor -Werror=strict-aliasing -Werror=narrowing -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=return-local-addr -Wnon-virtual-dtor -Werror=switch -fdiagnostics-show-option -Wno-unused-local-typedefs -Wno-attributes -Wno-psabi -Wno-error=unused-variable -DBOOST_DISABLE_ASSERTS -DGNU_GCC -D_GNU_SOURCE -DBOOST_SPIRIT_THREADSAFE -DPHOENIX_THREADSAFE
LIBS = $(ROOTLIBS) -L$(CONDA)/lib -lgsl -l RooFit -lRooFitCore -l RooStats -l Minuit -lMathMore -l Foam -lHistFactory -lboost_filesystem -lboost_program_options -lboost_system -lvdt -lquadmath

# Library name -----------------------------------------------------------------
LIBNAME=HiggsAnalysisCombinedLimit
SONAME=lib$(LIBNAME).so
DICTNAME=$(LIBNAME)_xr

# Linker and flags -------------------------------------------------------------
LD = g++
ROOTLDFLAGS = $(shell root-config --ldflags)
LDFLAGS = $(ROOTLDFLAGS) -shared -Wl,-soname,$(SONAME) -Wl,-E -Wl,-z,defs -fPIC

# Directory structure ----------------------------------------------------------
PARENT_DIR = $(shell pwd)/../../
SRC_DIR = src
INC_DIR = interface
LIB_DIR = lib
PROG_DIR = bin
EXE_DIR = exe
OBJ_DIR = obj


# Useful shortcuts -------------------------------------------------------------
SRCS = $(notdir $(shell ls $(SRC_DIR)/*.cc ))
SRXS = $(notdir $(shell ls $(SRC_DIR)/*.cxx ))
OBJS = $(SRCS:.cc=.o)
OBJS += $(SRXS:.cxx=.o)
PROGS = $(notdir $(wildcard ${PROG_DIR}/*.cpp))
EXES = $(PROGS:.cpp=)

#Makefile Rules ---------------------------------------------------------------
.PHONY: clean dirs dict obj lib exe debug


all: dirs dict obj lib exe compile_python

#---------------------------------------

dirs:
@mkdir -p $(OBJ_DIR)/a
@mkdir -p $(SRC_DIR)
@mkdir -p $(LIB_DIR)
@mkdir -p $(EXE_DIR)
@mkdir -p $(LIB_DIR)/python/HiggsAnalysis
@ln -sd ../../../python $(LIB_DIR)/python/HiggsAnalysis/CombinedLimit || /bin/true
@touch $(LIB_DIR)/python/__init__.py
@touch $(LIB_DIR)/python/HiggsAnalysis/__init__.py
@touch $(LIB_DIR)/python/HiggsAnalysis/CombinedLimit/__init__.py

#---------------------------------------

dict: dirs $(OBJ_DIR)/a/$(DICTNAME).cc
$(OBJ_DIR)/a/$(DICTNAME).cc : $(SRC_DIR)/classes_def.xml
# @echo "\n*** Generating dictionaries ..."
genreflex $(SRC_DIR)/classes.h -s $(SRC_DIR)/classes_def.xml -o $(OBJ_DIR)/a/$(DICTNAME).cc --deep --fail_on_warnings --rootmap=$(OBJ_DIR)/a/$(DICTNAME).rootmap --rootmap-lib=$(SONAME) -I$(PARENT_DIR)
mv $(OBJ_DIR)/a/$(DICTNAME).rootmap $(LIB_DIR)/
mv $(OBJ_DIR)/a/$(DICTNAME)_rdict.pcm $(LIB_DIR)/

#---------------------------------------

obj: dict
# @echo "\n*** Compiling ..."
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc $(INC_DIR)/%.h
$(CC) $(CCFLAGS) -I $(INC_DIR) -I $(SRC_DIR) -I $(PARENT_DIR) -c $< -o $@
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc $(SRC_DIR)/%.h
$(CC) $(CCFLAGS) -I $(INC_DIR) -I $(SRC_DIR) -I $(PARENT_DIR) -c $< -o $@
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx $(INC_DIR)/%.h
$(CC) $(CCFLAGS) -I $(INC_DIR) -I $(SRC_DIR) -I $(PARENT_DIR) -c $< -o $@
$(OBJ_DIR)/a/%.o : $(OBJ_DIR)/a/%.cc
$(CC) $(CCFLAGS) -I . -I $(SRC_DIR) -I $(PARENT_DIR) -c $< -o $@


# this has no header
$(OBJ_DIR)/tdrstyle.o: $(SRC_DIR)/tdrstyle.cc
$(CC) $(CCFLAGS) -I $(INC_DIR) -c $< -o $@

#---------------------------------------

lib: dirs ${LIB_DIR}/$(SONAME)
${LIB_DIR}/$(SONAME):$(addprefix $(OBJ_DIR)/,$(OBJS)) $(OBJ_DIR)/a/$(DICTNAME).o
# @echo "\n*** Building $(SONAME) library:"
$(LD) $(LDFLAGS) $(BOOST_INC) $(addprefix $(OBJ_DIR)/,$(OBJS)) $(OBJ_DIR)/a/$(DICTNAME).o $(SOFLAGS) -o $@ $(LIBS)

#---------------------------------------

exe: $(addprefix $(EXE_DIR)/,$(EXES))
# @echo "\n*** Compiling executables ..."
$(EXE_DIR)/% : $(PROG_DIR)/%.cpp lib
$(CC) $< -o $@ $(CCFLAGS) -L $(LIB_DIR) -l $(LIBNAME) -I $(INC_DIR) -I $(SRC_DIR) -I $(PARENT_DIR) $(BOOST_INC) $(LIBS)

compile_python:
@python -m compileall -q python

#---------------------------------------

clean:
# @echo "*** Cleaning all directories and dictionaries ..."
@rm -rf $(OBJ_DIR)
@rm -rf $(EXE_DIR)
@rm -rf $(LIB_DIR)
@rm -rf python/*pyc python/*/*pyc

#---------------------------------------

debug:
@echo "OBJS: $(OBJS)"
@echo "SRCS: $(SRCS)"
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,26 @@ cd HiggsAnalysis/CombinedLimit
source env_standalone.sh
make -j 8; make # second make fixes compilation error of first
```

### Standalone compilation with `conda`
```
git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
cd HiggsAnalysis/CombinedLimit
git checkout 112x

conda install --name base mamba # faster conda
mamba env create -f conda_env.yml

conda activate combine
bash set_conda_env_vars.sh
# Need to reactivate
conda deactivate
conda activate combine

make -f Makefile_conda -j 8
```

Using combine from then on should only require sourcing the conda environment
```
conda activate combine
```
15 changes: 15 additions & 0 deletions conda_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: combine
channels:
- conda-forge
- defaults
dependencies:
- python==2.7.18
- pip
- root
- gsl
- tbb
- vdt
- boost
- pcre
- eigen
- certifi[version='>=2017.4.17']
Loading