From c77e54cd38a42685ff46d163bc68511ca2f9ea3c Mon Sep 17 00:00:00 2001 From: Andrew Gilbert Date: Tue, 18 Jun 2019 13:28:33 +0200 Subject: [PATCH] Updating standalone compilation to work in 10_2_X, and optionally with the ROOT master --- Makefile | 24 ++++++++++++++---------- env_standalone.sh | 15 +++++++-------- env_standalone_root_master.sh | 10 ++++++++++ src/CachingNLL.cc | 4 ++++ src/CascadeMinimizer.cc | 3 +++ src/Combine.cc | 6 ++++++ 6 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 env_standalone_root_master.sh diff --git a/Makefile b/Makefile index 032f3eb2393..8a38578f240 100644 --- a/Makefile +++ b/Makefile @@ -22,20 +22,24 @@ ####################################################################### # Boost -BOOST = /cvmfs/cms.cern.ch/slc6_amd64_gcc491/external/boost/1.51.0-cms -VDT = /cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/vdt/v0.3.2-cms - +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 # Compiler and flags ----------------------------------------------------------- -CC = g++ - +CC = c++ ROOTCFLAGS = $(shell root-config --cflags) ROOTLIBS = $(shell root-config --libs --glibs) ROOTINC = $(shell root-config --incdir) -CCFLAGS = -D STANDALONE $(ROOTCFLAGS) -I$(BOOST)/include -I$(VDT)/include -g -fPIC +# CCFLAGS = -D STANDALONE $(ROOTCFLAGS) -I$(BOOST)/include -I$(VDT)/include -I$(PCRE)/include -I$(GSL)/include -I$(LIBXML)/include/libxml2 -I$(XZ)/include -I$(ZLIB)/include -g -fPIC +CCFLAGS = -D STANDALONE $(ROOTCFLAGS) -I$(BOOST)/include -I$(VDT)/include -I$(GSL)/include -g -fPIC # CMSSW CXXFLAGS plus -Wno-unused-local-typedefs (otherwise we get a flood of messages from BOOST) plus -Wno-unused-function -CCFLAGS += -O2 -pedantic -pthread -pipe -Wno-vla -Werror=overflow -Wstrict-overflow -std=c++0x -msse3 -ftree-vectorize -Wno-strict-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 -fipa-pta -felide-constructors -fmessage-length=0 -ftemplate-depth-300 -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=maybe-uninitialized -Werror=strict-aliasing -Werror=narrowing -Werror=uninitialized -Werror=unused-but-set-variable -Werror=reorder -Werror=unused-variable -Werror=conversion-null -Werror=switch -fdiagnostics-show-option -DBOOST_DISABLE_ASSERTS -Wno-unused-local-typedefs -Wno-unused-function -LIBS = $(ROOTLIBS) -L$(BOOST)/lib -L$(VDT)/lib -l RooFit -lRooFitCore -l RooStats -l Minuit -l Foam -lHistFactory -lboost_filesystem -lboost_program_options -lboost_system -lvdt +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$(BOOST)/lib -L$(VDT)/lib -L$(GSL)/lib -lgsl -l RooFit -lRooFitCore -l RooStats -l Minuit -lMathMore -l Foam -lHistFactory -lboost_filesystem -lboost_program_options -lboost_system -lvdt # Library name ----------------------------------------------------------------- LIBNAME=HiggsAnalysisCombinedLimit @@ -45,7 +49,7 @@ DICTNAME=$(LIBNAME)_xr # Linker and flags ------------------------------------------------------------- LD = g++ ROOTLDFLAGS = $(shell root-config --ldflags) -LDFLAGS = $(ROOTLDFLAGS) -rdynamic -shared -Wl,-soname,$(SONAME) -fPIC +LDFLAGS = $(ROOTLDFLAGS) -shared -Wl,-soname,$(SONAME) -Wl,-E -Wl,-z,defs -fPIC # Directory structure ---------------------------------------------------------- PARENT_DIR = $(shell pwd)/../../ @@ -122,7 +126,7 @@ ${LIB_DIR}/$(SONAME):$(addprefix $(OBJ_DIR)/,$(OBJS)) $(OBJ_DIR)/a/$(DICTNAME).o exe: $(addprefix $(EXE_DIR)/,$(EXES)) # @echo "\n*** Compiling executables ..." -$(addprefix $(EXE_DIR)/,$(EXES)) : $(addprefix $(PROG_DIR)/,$(PROGS)) +$(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: diff --git a/env_standalone.sh b/env_standalone.sh index 86656ba3b3c..53f4344b8bd 100644 --- a/env_standalone.sh +++ b/env_standalone.sh @@ -1,11 +1,10 @@ - . /cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/gcc/5.3.0/etc/profile.d/init.sh - cd /cvmfs/cms.cern.ch/slc6_amd64_gcc530/lcg/root/6.06.00-cms/ - . ./bin/thisroot.sh - cd - - . /cvmfs/cms.cern.ch/slc6_amd64_gcc530/cms/vdt/v0.3.2-giojec/etc/profile.d/init.sh - . /cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/boost/1.57.0-giojec/etc/profile.d/init.sh - . /cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/xz/5.2.1/etc/profile.d/init.sh - export LD_LIBRARY_PATH=/cvmfs/cms.cern.ch/slc6_amd64_gcc530/external/pcre/8.37/lib/:${LD_LIBRARY_PATH} + . /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 export PATH=${PATH}:${PWD}/exe:${PWD}/scripts export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/lib export PYTHONPATH=${PYTHONPATH}:${PWD}/lib/python:${PWD}/lib diff --git a/env_standalone_root_master.sh b/env_standalone_root_master.sh new file mode 100644 index 00000000000..da071e918dd --- /dev/null +++ b/env_standalone_root_master.sh @@ -0,0 +1,10 @@ + . /cvmfs/cms.cern.ch/slc7_amd64_gcc700/external/gcc/7.0.0-omkpbe2/etc/profile.d/init.sh + . /afs/cern.ch/work/a/agilbert/public/root_master/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 + export PATH=${PATH}:${PWD}/exe:${PWD}/scripts + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/lib + export PYTHONPATH=${PYTHONPATH}:${PWD}/lib/python:${PWD}/lib diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index 387c46d0ba5..bd424129779 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -472,6 +472,10 @@ cacheutils::makeCachingPdf(RooAbsReal *pdf, const RooArgSet *obs) { } else if (histNll && typeid(*pdf) == typeid(FastVerticalInterpHistPdf2)) { return new CachingHistPdf2(pdf, obs); } else if (gaussNll && typeid(*pdf) == typeid(RooGaussian)) { + if (runtimedef::get("DBG_GAUSS")) { + std::cout << "Creating CachingGaussPdf for " << pdf->GetName() << "\n"; + pdf->Print("v"); + } return new CachingGaussPdf(pdf, obs); } else if (cbNll && typeid(*pdf) == typeid(RooCBShape)) { return new CachingCBPdf(pdf, obs); diff --git a/src/CascadeMinimizer.cc b/src/CascadeMinimizer.cc index 21b66a7d22d..0e7c7e922c0 100644 --- a/src/CascadeMinimizer.cc +++ b/src/CascadeMinimizer.cc @@ -104,6 +104,9 @@ bool CascadeMinimizer::improve(int verbose, bool cascade) minimizer_->setEps(tol); minimizer_->setStrategy(approxPreFitStrategy_); improveOnce(verbose-1, true); + if (runtimedef::get("DBG_QUICKEXIT")) { + exit(0); + } minimizer_->setEps(nominalTol); minimizer_->setStrategy(strategy_); } while (autoBounds_ && !autoBoundsOk(verbose-1)); diff --git a/src/Combine.cc b/src/Combine.cc index 553de0b981b..58f9baeb9ae 100644 --- a/src/Combine.cc +++ b/src/Combine.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -304,6 +305,11 @@ void Combine::run(TString hlfFile, const std::string &dataset, double &limit, do garbageCollect.tfile = fIn; // request that we close this file when done w = dynamic_cast(fIn->Get(workspaceName_.c_str())); + + if (fIn->GetCacheRead()) { + fIn->GetCacheRead()->Close(); + } + if (w == 0) { std::cerr << "Could not find workspace '" << workspaceName_ << "' in file " << fileToLoad << std::endl; fIn->ls(); throw std::invalid_argument("Missing Workspace");