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 15 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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#######################################################################

# 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
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_gcc700/external/pcre/8.37-omkpbe2
GSL = /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/gsl/2.2.1-omkpbe2
GSL = /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/gsl/2.6-bcolbf3
nsmith- marked this conversation as resolved.
Show resolved Hide resolved
# 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
Expand Down
141 changes: 141 additions & 0 deletions Makefile_conda
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
################################################################################
# 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 ##############################
# . /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
#######################################################################

# Boost
CONDA = $(shell conda info --base)/envs/combine2
# 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 -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)"
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ 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 fetch origin pull/648/head:r622conda # until merged
git checkout r622conda

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
```

14 changes: 14 additions & 0 deletions conda_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: combine2
channels:
- conda-forge
- defaults
dependencies:
- python==2.7.18
- pip
- root
- gsl
- tbb
- vdt
- boost
- pcre
- certifi[version='>=2017.4.17']
3 changes: 3 additions & 0 deletions env_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export PATH=${PATH}:${PWD}/exe:${PWD}/scripts
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/lib
export PYTHONPATH=${PYTHONPATH}:${PWD}/lib/python:${PWD}/lib
16 changes: 8 additions & 8 deletions env_standalone.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/gcc/7.0.0-omkpbe2/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/lcg/root/6.12.07-gnimlf5/bin/thisroot.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/gsl/2.2.1-omkpbe2/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/tbb/2018_U1-omkpbe2/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/cms/vdt/0.4.0-gnimlf/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/boost/1.63.0-gnimlf/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/pcre/8.37-omkpbe2/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/eigen/64060da8461a627eb25b5a7bc0616776068db58b/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/gcc/8.2.0-bcolbf/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/lcg/root/6.22.00/bin/thisroot.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/gsl/2.6-bcolbf3/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/tbb/2020_U2-ghbfee/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/cms/vdt/0.4.0-ghbfee/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/boost/1.72.0-gchjei/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/pcre/8.43-bcolbf/etc/profile.d/init.sh
. /cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/eigen/d812f411c3f9-ghbfee/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:${PWD}/lib
1 change: 1 addition & 0 deletions interface/HZZ4L_RooCTauPdf_1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"


class HZZ4L_RooCTauPdf_1D : public RooAbsPdf {
Expand Down
1 change: 1 addition & 0 deletions interface/HZZ4L_RooCTauPdf_1D_Expanded.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"


class HZZ4L_RooCTauPdf_1D_Expanded : public RooAbsPdf {
Expand Down
1 change: 1 addition & 0 deletions interface/HZZ4L_RooCTauPdf_2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"


class HZZ4L_RooCTauPdf_2D : public RooAbsPdf {
Expand Down
1 change: 1 addition & 0 deletions interface/HZZ4L_RooSpinZeroPdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"
using namespace RooFit;
class HZZ4L_RooSpinZeroPdf : public RooAbsPdf {
protected:
Expand Down
1 change: 1 addition & 0 deletions interface/HZZ4L_RooSpinZeroPdf_1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"
using namespace RooFit;

class HZZ4L_RooSpinZeroPdf_1D : public RooAbsPdf {
Expand Down
1 change: 1 addition & 0 deletions interface/HZZ4L_RooSpinZeroPdf_2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"

using namespace RooFit;

Expand Down
2 changes: 2 additions & 0 deletions interface/HZZ4L_RooSpinZeroPdf_phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "TH1.h"
#include "RooDataHist.h"
#include "RooHistFunc.h"
#include "RooListProxy.h"

using namespace RooFit;
class HZZ4L_RooSpinZeroPdf_phase : public RooAbsPdf {
protected:
Expand Down
2 changes: 2 additions & 0 deletions interface/MultiDimFit.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
*/
#include "HiggsAnalysis/CombinedLimit/interface/FitterAlgoBase.h"
#include <RooRealVar.h>
#include "TFile.h"
#include <vector>
#include <TFile.h>

class MultiDimFit : public FitterAlgoBase {
public:
Expand Down
5 changes: 0 additions & 5 deletions interface/RooMultiPdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#include <iostream>
#include <vector>

class RooAbsArg;
class RooAbsPdf;
class RooAbsReal;
class RooRealProxy;
class RooArgList;

using namespace std;

Expand Down
4 changes: 3 additions & 1 deletion interface/SimpleCacheSentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ class SimpleCacheSentry : public RooAbsArg {
virtual RooAbsArg *createFundamental(const char* newname=0) const { return 0; }
virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) { return false; }
virtual void writeToStream(std::ostream& os, Bool_t compact) const { }
virtual Bool_t operator==(const RooAbsArg& other) const { return this == &other; }
virtual Bool_t operator==(const RooAbsArg& other) { return this == &other; }
virtual void syncCache(const RooArgSet* nset=0) {}
virtual void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) {}
virtual void attachToTree(TTree& t, Int_t bufSize=32000) {}
virtual void attachToVStore(RooVectorDataStore& vstore) {}
virtual void setTreeBranchStatus(TTree& t, Bool_t active) {}
virtual void fillTreeBranch(TTree& t) {}
virtual Bool_t isIdentical(const RooAbsArg& other, Bool_t assumeSameType=kFALSE) ;
virtual Bool_t isIdentical(const RooAbsArg& other, Bool_t assumeSameType=kFALSE) const;
virtual Bool_t isIdentical(const RooAbsArg& other, Bool_t assumeSameType=kFALSE) { return const_cast<SimpleCacheSentry*>(this)->isIdentical(other, assumeSameType); };
nsmith- marked this conversation as resolved.
Show resolved Hide resolved
private:
RooSetProxy _deps;
ClassDef(SimpleCacheSentry,1)
Expand Down
7 changes: 5 additions & 2 deletions interface/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ namespace utils {
RooArgSet returnAllVars(RooWorkspace *);
bool freezeAllDisassociatedRooMultiPdfParameters(const RooArgSet & multiPdfs, const RooArgSet & allRooMultiPdfParams, bool freeze=true);

#if ROOT_VERSION_CODE < ROOT_VERSION(6,20,0)
// This is a workaround for a bug (?) in RooAddPdf that limits the number of elements
// to 100 when de-serialised from a TFile. We have to access a protected array and reallocate
// it with the correct size
// https://sft.its.cern.ch/jira/browse/ROOT-6008
class RooAddPdfFixer : public RooAddPdf {
public:
RooAddPdfFixer() : RooAddPdf() {}
RooAddPdfFixer(RooAddPdfFixer const& other) : RooAddPdf(other) {}

void Fix(RooAddPdf & fixme);
void FixAll(RooWorkspace & w);
static void Fix(RooAddPdf & fixme);
static void FixAll(RooWorkspace & w);
};
#endif
}
#endif
4 changes: 2 additions & 2 deletions src/CMSHistErrorPropagator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ CMSHistErrorPropagator::CMSHistErrorPropagator(
coeffs_("coeffs", this, other.coeffs_),
binpars_("binpars", this, other.binpars_),
bintypes_(other.bintypes_),
sentry_(name ? TString(name) + "_sentry" : TString(other.sentry_.GetName()), ""),
binsentry_(name ? TString(name) + "_binsentry" : TString(other.binsentry_.GetName()), ""),
sentry_(name ? TString(name) + "_sentry" : TString(other.GetName())+"_sentry", ""),
binsentry_(name ? TString(name) + "_binsentry" : TString(other.GetName())+"_binsentry", ""),
initialized_(false),
last_eval_(-1) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/CMSHistFunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ CMSHistFunc::CMSHistFunc(CMSHistFunc const& other, const char* name)
hmorphs_("hmorphs", this, other.hmorphs_),
hpoints_(other.hpoints_),
vmorph_sentry_(name ? TString(name) + "_vmorph_sentry"
: TString(other.vmorph_sentry_.GetName()),
: TString(other.GetName())+"_vmorph_sentry",
""),
hmorph_sentry_(name ? TString(name) + "_hmorph_sentry"
: TString(other.hmorph_sentry_.GetName()),
: TString(other.GetName())+"_hmorph_sentry",
""),
cache_(other.cache_),
rebin_cache_(other.rebin_cache_),
Expand Down
2 changes: 1 addition & 1 deletion src/CMSHistFuncWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CMSHistFuncWrapper::CMSHistFuncWrapper(CMSHistFuncWrapper const& other, const ch
err_("err", this, other.err_),
cache_(other.cache_),
idx_(other.idx_),
sentry_(name ? TString(name) + "_sentry" : TString(other.sentry_.GetName()), ""),
sentry_(name ? TString(name) + "_sentry" : TString(other.GetName())+"_sentry", ""),
pfunc_(nullptr),
perr_(nullptr),
initialized_(false) {
Expand Down
Loading