From 1cbe9b725a67d58d781dd23b6ea163ab8f71782b Mon Sep 17 00:00:00 2001 From: Ulascan Sarica Date: Mon, 5 Sep 2022 09:18:32 -0700 Subject: [PATCH 1/4] Resolve compilation issues, remove explicit CMSSW workflow --- MELA/BuildFile.xml | 21 ------------- MELA/fortran/makefile | 18 ++++------- MELA/makefile | 17 ++++++----- MELA/setup.sh | 71 ++++++++++++++++--------------------------- MELA/test/loadMELA.C | 19 +++++++----- 5 files changed, 52 insertions(+), 94 deletions(-) delete mode 100755 MELA/BuildFile.xml diff --git a/MELA/BuildFile.xml b/MELA/BuildFile.xml deleted file mode 100755 index 969d880..0000000 --- a/MELA/BuildFile.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - -# - - - - - - - diff --git a/MELA/fortran/makefile b/MELA/fortran/makefile index aa22120..6a79e5d 100644 --- a/MELA/fortran/makefile +++ b/MELA/fortran/makefile @@ -7,8 +7,10 @@ else RM = /bin/rm MAINDIR = $(shell pwd)/ +MELALIBDIR = ${MELA_LIB_PATH} OBJECTSDIR= LIB = libjhugenmela.so +LIBRULE = $(MELALIBDIR)/$(LIB) INCLUDE = -I$(MAINDIR) Comp = gfort @@ -64,16 +66,7 @@ ifeq ($(Comp),ifort) endif -all: libs - @echo " Compiling $(LIB)" - g++ -Wl,-soname,$(LIB) -shared -o $(LIB) *.o - @echo " " - @echo " WARNING: if you updated the fortran code," - @echo " you need to move libjhugenmela.so" - @echo ' to the appropriate folder in data/' - @echo " and then gmake/scram. Otherwise your changes" - @echo " will not apply to any code you run." - @echo " If you are running setup.sh this is done automatically." +all: $(LIBRULE) .SILENT: @@ -130,10 +123,11 @@ $(OBJECTSDIR)mod_JHUGen.o: mod_JHUGen.F90 $(OBJECTSDIR)mod_HashCollection.o $(OB @echo " Compiling $< with $(Comp)"; \ $(fcomp) -c $< -libs: $(OBJECTS) +$(LIBRULE): $(OBJECTS) + @echo "Linking $(LIB)"; \ + g++ -Wl,-rpath=$(MELALIBDIR),-soname,$(LIB) -L$(MELALIBDIR) -shared *.o -o $@ clean: - @echo " Deleting MELA fortran object files and library" rm -f *.so $(OBJECTSDIR)*.o $(OBJECTSDIR)*.mod diff --git a/MELA/makefile b/MELA/makefile index 0be66c7..659e44e 100644 --- a/MELA/makefile +++ b/MELA/makefile @@ -17,10 +17,9 @@ RM = /bin/rm MELADIR = $(shell pwd) MELASRCDIR = $(MELADIR)/src -MELADATADIR = $(MELADIR)/data MELAOBJDIR = $(MELADIR)/obj # Modify MELALIBDIR for the gcc version as needed -MELALIBDIR = $(MELADATADIR)/${SCRAM_ARCH} +MELALIBDIR = ${MELA_LIB_PATH} # _melapkgpath_ should refer to the root compilation path just like MELADIR with an extra '/'. # If environment variables need to be inserted without expansion for portability, # you can use '.oODOLLAROo..oOOPEN_BRACKETOo.[YOUR_ENV_VARIABLE].oOCLOSE_BRACKETOo.', @@ -54,19 +53,20 @@ SOURCESCC = $(wildcard $(MELASRCDIR)/*.cc) SOURCESCXX = $(wildcard $(MELASRCDIR)/*.cxx) OBJECTSPRIM = $(SOURCESCC:.cc=.o) $(SOURCESCXX:.cxx=.o) OBJECTS = $(subst $(MELASRCDIR),$(MELAOBJDIR),$(OBJECTSPRIM)) +DEPS = $(OBJECTS:.o=.d) .PHONY: all help compile clean -.SILENT: alldirs $(OBJECTS) $(MELAOBJDIR)/LinkDef_out.o $(LIBRULE) python/__init__.py clean +.SILENT: alldirs $(OBJECTS) $(DEPS) $(MELAOBJDIR)/LinkDef_out.o $(LIBRULE) python/__init__.py clean all: $(LIBRULE) python/__init__.py $(MELAOBJDIR)/%.d: $(MELASRCDIR)/%.c* | alldirs echo "Checking dependencies for $<"; \ - $(CC) -MM -MT $@ -MT ${@:.d=.o} $(CPPFLAGS) $< > $@; \ + $(CC) -MM -MT $@ $(CPPFLAGS) $< > $@; \ [ -s $@ ] || rm -f $@ -$(MELAOBJDIR)/%.o: $(MELASRCDIR)/%.c* | alldirs +$(MELAOBJDIR)/%.o: $(MELASRCDIR)/%.c* $(MELAOBJDIR)/%.d | alldirs echo "Compiling $<"; \ $(CC) $(CPPFLAGS) $< -c -o $@ @@ -89,9 +89,10 @@ python/__init__.py: touch python/__init__.py clean: - rm -v -r -f \ - $(MELAOBJDIR) $(MELASRCDIR)/LinkDef_out* $(MELALIBDIR)/$(LIB) $(MELALIBDIR)/LinkDef_out_rdict.pcm; \ - echo "Done cleaning MELA" + rm -rf $(MELAOBJDIR) $(MELASRCDIR)/LinkDef_out* $(MELALIBDIR)/$(LIB) $(MELALIBDIR)/LinkDef_out_rdict.pcm + + +include $(DEPS) endif diff --git a/MELA/setup.sh b/MELA/setup.sh index eeb2994..2bb8137 100755 --- a/MELA/setup.sh +++ b/MELA/setup.sh @@ -28,20 +28,17 @@ cd $(dirname ${BASH_SOURCE[0]}) MELADIR="$(readlink -f .)" MCFMVERSION=mcfm_707 -declare -i forceStandalone=0 declare -i doDeps=0 declare -i doPrintEnv=0 declare -i doPrintEnvInstr=0 -declare -i usingCMSSW=0 +declare -i hasCMSSW=0 declare -i needSCRAM=0 declare -i needROOFITSYS_ROOTSYS=0 declare -a setupArgs=() for farg in "$@"; do fargl="$(echo $farg | awk '{print tolower($0)}')" - if [[ "$fargl" == "standalone" ]]; then - forceStandalone=1 - elif [[ "$fargl" == "deps" ]]; then + if [[ "$fargl" == "deps" ]]; then doDeps=1 elif [[ "$fargl" == "env" ]]; then doPrintEnv=1 @@ -56,9 +53,9 @@ nSetupArgs=${#setupArgs[@]} SARCH=$(getSCRAMVERSION) -if [[ ${forceStandalone} -eq 0 ]] && [[ ! -z "${CMSSW_BASE+x}" ]]; then +if [[ ! -z "${CMSSW_BASE+x}" ]]; then - usingCMSSW=1 + hasCMSSW=1 eval $(scram ru -sh) @@ -81,12 +78,15 @@ if [[ -z "${ROOFITSYS+x}" ]] && [[ $doDeps -eq 0 ]]; then fi fi + +mela_lib_path="${MELADIR}/data/${SCRAM_ARCH}" + printenv () { - if [[ ${usingCMSSW} -eq 1 ]]; then - return 0 + if [[ -z "${MELA_LIB_PATH+x}" ]] || [[ "${MELA_LIB_PATH}" != "${mela_lib_path}" ]]; then + echo "export MELA_LIB_PATH=${mela_lib_path}" fi - ldlibappend="${MELADIR}/data/${SCRAM_ARCH}" + ldlibappend="${mela_lib_path}" end="" if [[ ! -z "${LD_LIBRARY_PATH+x}" ]]; then end=":${LD_LIBRARY_PATH}" @@ -113,11 +113,12 @@ printenv () { fi } doenv () { - if [[ ${usingCMSSW} -eq 1 ]]; then - return 0 + if [[ -z "${MELA_LIB_PATH+x}" ]] || [[ "${MELA_LIB_PATH}" != "${mela_lib_path}" ]]; then + export MELA_LIB_PATH="${mela_lib_path}" + echo "Temporarily using MELA_LIB_PATH as ${MELA_LIB_PATH}" fi - ldlibappend="${MELADIR}/data/${SCRAM_ARCH}" + ldlibappend="${mela_lib_path}" end="" if [[ ! -z "${LD_LIBRARY_PATH+x}" ]]; then end=":${LD_LIBRARY_PATH}" @@ -148,20 +149,17 @@ dodeps () { ${MELADIR}/downloadNNPDF.sh } printenvinstr () { - if [[ ${usingCMSSW} -eq 1 ]]; then - return 0 - fi echo echo "remember to do" echo - echo 'eval $(./setup.sh env standalone)' + echo 'eval $('${BASH_SOURCE[0]}' env)' echo "or" - echo 'eval `./setup.sh env standalone`' + echo 'eval `'${BASH_SOURCE[0]}' env`' echo echo "if you are using a bash-related shell, or you can do" echo - echo './setup.sh env standalone' + echo ${BASH_SOURCE[0]}' env' echo echo "and change the commands according to your shell in order to do something equivalent to set up the environment variables." echo @@ -185,17 +183,13 @@ if [[ $doDeps -eq 1 ]]; then : ok elif [[ "$nSetupArgs" -eq 1 ]] && [[ "${setupArgs[0]}" == *"clean"* ]]; then #echo "Cleaning C++" - if [[ ${usingCMSSW} -eq 1 ]];then - scramv1 b "${setupArgs[@]}" - else - make clean - fi + make clean #echo "Cleaning FORTRAN" - pushd ${MELADIR}/fortran + pushd ${MELADIR}/fortran &> /dev/null make clean rm -f ../data/${SCRAM_ARCH}/libjhugenmela.so - popd + popd &> /dev/null #echo "Cleaning COLLIER" ${MELADIR}/COLLIER/setup.sh "${setupArgs[@]}" @@ -225,24 +219,11 @@ if [[ $doDeps -eq 1 ]]; then exit fi -pushd ${MELADIR}/fortran +pushd ${MELADIR}/fortran &> /dev/null make "${setupArgs[@]}" -if mv libjhugenmela.so ../data/${SCRAM_ARCH}/; then - echo - echo "...and you are running setup.sh, so this was just done." - echo - popd - if [[ ${usingCMSSW} -eq 1 ]]; then - scramv1 b "${setupArgs[@]}" - else - make "${setupArgs[@]}" - fi - printenvinstr -else - echo - echo "ERROR: something went wrong in mv, see ^ error message" - echo - popd - exit 1 -fi +popd &> /dev/null + +make "${setupArgs[@]}" +printenvinstr + ) diff --git a/MELA/test/loadMELA.C b/MELA/test/loadMELA.C index 6651d0b..43e15f5 100644 --- a/MELA/test/loadMELA.C +++ b/MELA/test/loadMELA.C @@ -4,16 +4,19 @@ TString LIBJHUGENMELA = "libjhugenmela.so"; TString LIBMELA = "libJHUGenMELAMELA.so"; - TString loadMELA = __FILE__; - TString testdir = loadMELA(0, loadMELA.Last('/')); - if (!testdir.BeginsWith(".") && testdir.EndsWith(".")) testdir = testdir(0, testdir.Last('/')); - TString LIBPATH = testdir+"/../data/$SCRAM_ARCH/"; + TString LIBPATH = "${MELA_LIB_PATH}/"; TString LIBMELADIR = LIBPATH; if (gSystem->FindDynamicLibrary(LIBMELA)) LIBMELADIR = ""; - gInterpreter->AddIncludePath("$ROOFITSYS/include/"); - gInterpreter->AddIncludePath(testdir+"/../interface/"); + TString LIBCOLLIERDIR = LIBPATH; + if (gSystem->FindDynamicLibrary(LIBCOLLIER)) LIBCOLLIERDIR = ""; + + TString LIBMCFMDIR = LIBPATH; + if (gSystem->FindDynamicLibrary(LIBMCFM)) LIBMCFMDIR = ""; + + gInterpreter->AddIncludePath("${ROOFITSYS}/include/"); + gInterpreter->AddIncludePath(LIBPATH+"../../interface/"); ////////////////////////////////////// //these explicit loads are required on //some machines but not others @@ -23,7 +26,7 @@ gSystem->Load("libPhysics"); gSystem->Load("libgfortran"); ////////////////////////////////////// - gSystem->Load(LIBPATH + LIBCOLLIER); + gSystem->Load(LIBCOLLIERDIR + LIBCOLLIER); gSystem->Load(LIBMELADIR + LIBMELA); - gSystem->Load(LIBPATH + LIBMCFM); + gSystem->Load(LIBMCFMDIR + LIBMCFM); } From 1c81f75fbbbdd209d98279615eff079fcd438132 Mon Sep 17 00:00:00 2001 From: Ulascan Sarica Date: Mon, 5 Sep 2022 09:35:40 -0700 Subject: [PATCH 2/4] Fix minor remaining issue --- MELA/setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MELA/setup.sh b/MELA/setup.sh index 2bb8137..18b94f0 100755 --- a/MELA/setup.sh +++ b/MELA/setup.sh @@ -15,11 +15,11 @@ getSCRAMVERSION(){ elif [[ "$GCCVERSION" == "8.0"* ]] || [[ "$GCCVERSION" == "8.1"* ]] || [[ "$GCCVERSION" == "8.2"* ]]; then # v4 of MCFM library echo slc7_amd64_gcc820 elif [[ "$GCCVERSION" == "8"* ]]; then - echo slc6_amd64_gcc830 - elif [[ "$GCCVERSION" == "9"* ]]; then - echo slc6_amd64_gcc920 + echo slc7_amd64_gcc830 else - echo slc7_amd64_gcc10 # Same as v7_920 + #elif [[ "$GCCVERSION" == "9"* ]]; then + echo slc7_amd64_gcc920 + #else fi } From 439b7365e5d33e9d8f6de68a684e18714ecfdb66 Mon Sep 17 00:00:00 2001 From: Ulascan Sarica Date: Mon, 5 Sep 2022 19:54:33 -0700 Subject: [PATCH 3/4] Remove file that is not supposed to have been committed, also remove CMSSW dependence completely --- MELA/COLLIER/makefile | 12 +++-- MELA/COLLIER/setup.sh | 5 +-- MELA/data/slc7_amd64_gcc10/download.url | 1 - MELA/fortran/makefile | 12 ++--- MELA/setup.sh | 59 +++++++++---------------- 5 files changed, 38 insertions(+), 51 deletions(-) delete mode 100644 MELA/data/slc7_amd64_gcc10/download.url diff --git a/MELA/COLLIER/makefile b/MELA/COLLIER/makefile index d54c318..58ab60e 100644 --- a/MELA/COLLIER/makefile +++ b/MELA/COLLIER/makefile @@ -3,6 +3,7 @@ AUXDIR = $(MAINDIR)/Aux COLIDIR = $(MAINDIR)/COLI TENSORSDIR = $(MAINDIR)/tensors DDLIBDIR = $(MAINDIR)/DDlib +MELALIBDIR = ${MELA_LIB_PATH} MODULES=$(MAINDIR) OBJECTS=$(MAINDIR) @@ -34,6 +35,7 @@ endif LIB = libcollier.so +LIBRULE = $(MELALIBDIR)/$(LIB) Deps = $(MAINDIR)/collier_global.F90 \ $(AUXDIR)/Combinatorics.F90 \ @@ -102,17 +104,21 @@ Objs = collier_global.o \ DDlib_DD_to_COLLIER.o -${Objs}: $(Deps) +.PHONY: all help clean + +all: $(LIBRULE) + +$(LIBRULE): $(Deps) @echo " " @echo " Compiling COLLIER dependencies" $(fcomp) -c $(Deps) @echo " " @echo " Compiling COLLIER library" - g++ -Wl,-soname,$(LIB) -shared -o $(LIB) *.o + g++ -Wl,-rpath=$(MELALIBDIR),-soname,$(LIB) -L$(MELALIBDIR) -shared *.o -o $@ clean: @echo " Deleting COLLIER object files and library" - rm -f *.so $(OBJECTS)/*.o $(MODULES)/*.mod + rm -f *.so $(LIBRULE) $(OBJECTS)/*.o $(MODULES)/*.mod # supresses command calls diff --git a/MELA/COLLIER/setup.sh b/MELA/COLLIER/setup.sh index 4177f57..bdf49ce 100755 --- a/MELA/COLLIER/setup.sh +++ b/MELA/COLLIER/setup.sh @@ -30,11 +30,11 @@ if [[ $# > 0 ]] && [[ "$1" == *"clean"* ]]; then fi done - rm -f ../data/*/$libname + rm -f ${MELA_LIB_PATH}/../*/$libname else - if [[ ! -f "../data/$SCRAM_ARCH/$libname" ]]; then + if [[ ! -f "${MELA_LIB_PATH}/$libname" ]]; then rm -rf $tmpdir rm -f $tarname wget --no-check-certificate $tarweb @@ -45,7 +45,6 @@ else rm -rf $tmpdir make $@ - mv $libname "../data/$SCRAM_ARCH/$libname" fi fi diff --git a/MELA/data/slc7_amd64_gcc10/download.url b/MELA/data/slc7_amd64_gcc10/download.url deleted file mode 100644 index ccde6bd..0000000 --- a/MELA/data/slc7_amd64_gcc10/download.url +++ /dev/null @@ -1 +0,0 @@ -http://spin.pha.jhu.edu/Generator/MCFM-precompiled/v7_920/ diff --git a/MELA/fortran/makefile b/MELA/fortran/makefile index 6a79e5d..8ddabfa 100644 --- a/MELA/fortran/makefile +++ b/MELA/fortran/makefile @@ -19,12 +19,12 @@ Comp = gfort # link pdfs via LHA library ('Yes' or 'No') UseLHAPDF=No # directory which contains libLHAPDF.a, libLHAPDF.la, libLHAPDF.so -MyLHADir=/./ +LHAPDFLIBDIR=/./ # remember to export # LD_LIBRARY_PATH=/.../LHAPDF-x.y.z/lib/:${LD_LIBRARY_PATH} # LHAPDF_DATA_PATH=/.../LHAPDF-x.y.z/share/LHAPDF/:${LHAPDF_DATA_PATH} ifeq ($(UseLHAPDF),Yes) - LHAPDFflags = -L$(MyLHADir) -lLHAPDF -DuseLHAPDF=1 + LHAPDFflags = -L$(LHAPDFLIBDIR) -lLHAPDF -DuseLHAPDF=1 else LHAPDFflags = -DuseLHAPDF=0 endif @@ -32,13 +32,13 @@ endif # Linking the Collier library UseCOLLIER=Yes # directory which contains libLHAPDF.a, libLHAPDF.la, libLHAPDF.so -MyCOLLIERDir=$(MAINDIR)../data/${SCRAM_ARCH}/ -MyCOLLIERInc=$(MAINDIR)../COLLIER/ +COLLIERLIBDIR=$(MAINDIR)../data/${MELA_ARCH}/ +COLLIERINCDIR=$(MAINDIR)../COLLIER/ # remember to export # LD_LIBRARY_PATH=/.../LHAPDF-x.y.z/lib/:${LD_LIBRARY_PATH} # LHAPDF_DATA_PATH=/.../LHAPDF-x.y.z/share/LHAPDF/:${LHAPDF_DATA_PATH} ifeq ($(UseCOLLIER),Yes) - COLLIERflags = -L$(MyCOLLIERDir) -lcollier -DuseCollier=1 -I$(MyCOLLIERInc) + COLLIERflags = -L$(COLLIERLIBDIR) -lcollier -DuseCollier=1 -I$(COLLIERINCDIR) else COLLIERflags = -DuseCollier=0 endif @@ -128,7 +128,7 @@ $(LIBRULE): $(OBJECTS) g++ -Wl,-rpath=$(MELALIBDIR),-soname,$(LIB) -L$(MELALIBDIR) -shared *.o -o $@ clean: - rm -f *.so $(OBJECTSDIR)*.o $(OBJECTSDIR)*.mod + rm -f *.so $(LIBRULE) $(OBJECTSDIR)*.o $(OBJECTSDIR)*.mod endif diff --git a/MELA/setup.sh b/MELA/setup.sh index 18b94f0..e49bef9 100755 --- a/MELA/setup.sh +++ b/MELA/setup.sh @@ -4,7 +4,7 @@ set -euo pipefail -getSCRAMVERSION(){ +getMELAARCH(){ GCCVERSION=$(gcc -dumpversion) if [[ "$GCCVERSION" == "4.3"* ]] || [[ "$GCCVERSION" == "4.4"* ]] || [[ "$GCCVERSION" == "4.5"* ]]; then # v1 of MCFM library echo slc5_amd64_gcc434 @@ -31,8 +31,6 @@ MCFMVERSION=mcfm_707 declare -i doDeps=0 declare -i doPrintEnv=0 declare -i doPrintEnvInstr=0 -declare -i hasCMSSW=0 -declare -i needSCRAM=0 declare -i needROOFITSYS_ROOTSYS=0 declare -a setupArgs=() @@ -51,23 +49,14 @@ done declare -i nSetupArgs nSetupArgs=${#setupArgs[@]} -SARCH=$(getSCRAMVERSION) - -if [[ ! -z "${CMSSW_BASE+x}" ]]; then - - hasCMSSW=1 - - eval $(scram ru -sh) - -else - - if [[ -z "${SCRAM_ARCH+x}" ]]; then - needSCRAM=1 - - export SCRAM_ARCH="${SARCH}" - fi - +# Determine the MELA_ARCH string +# If CMS SCRAM_ARCH is set as an environment variable and it is present in data/, +# use SCRAM_ARCH as MELA_ARCH. +mela_arch=$(getMELAARCH) +if [[ ! -z "${SCRAM_ARCH+x}" ]] && [[ -d ${MELADIR}/data/${SCRAM_ARCH} ]]; then + mela_arch=${SCRAM_ARCH} fi +mela_lib_path="${MELADIR}/data/${mela_arch}" if [[ -z "${ROOFITSYS+x}" ]] && [[ $doDeps -eq 0 ]]; then if [[ $(ls ${ROOTSYS}/lib | grep -e libRooFitCore) != "" ]]; then @@ -78,10 +67,11 @@ if [[ -z "${ROOFITSYS+x}" ]] && [[ $doDeps -eq 0 ]]; then fi fi - -mela_lib_path="${MELADIR}/data/${SCRAM_ARCH}" - printenv () { + if [[ -z "${MELA_ARCH+x}" ]] || [[ "${MELA_ARCH}" != "${mela_arch}" ]]; then + echo "export MELA_ARCH=${mela_arch}" + fi + if [[ -z "${MELA_LIB_PATH+x}" ]] || [[ "${MELA_LIB_PATH}" != "${mela_lib_path}" ]]; then echo "export MELA_LIB_PATH=${mela_lib_path}" fi @@ -104,15 +94,16 @@ printenv () { echo "export PYTHONPATH=${pythonappend}${end}" fi - if [[ $needSCRAM -eq 1 ]]; then - echo "export SCRAM_ARCH=${SCRAM_ARCH}" - fi - if [[ $needROOFITSYS_ROOTSYS -eq 1 ]]; then echo "export ROOFITSYS=${ROOTSYS}" fi } doenv () { + if [[ -z "${MELA_ARCH+x}" ]] || [[ "${MELA_ARCH}" != "${mela_arch}" ]]; then + export MELA_ARCH="${mela_arch}" + echo "Temporarily using MELA_ARCH as ${MELA_ARCH}" + fi + if [[ -z "${MELA_LIB_PATH+x}" ]] || [[ "${MELA_LIB_PATH}" != "${mela_lib_path}" ]]; then export MELA_LIB_PATH="${mela_lib_path}" echo "Temporarily using MELA_LIB_PATH as ${MELA_LIB_PATH}" @@ -145,11 +136,10 @@ doenv () { } dodeps () { ${MELADIR}/COLLIER/setup.sh "${setupArgs[@]}" - tcsh ${MELADIR}/data/retrieve.csh $SCRAM_ARCH $MCFMVERSION + tcsh ${MELADIR}/data/retrieve.csh ${MELA_ARCH} $MCFMVERSION ${MELADIR}/downloadNNPDF.sh } printenvinstr () { - echo echo "remember to do" echo @@ -179,6 +169,8 @@ if [[ $nSetupArgs -eq 0 ]]; then fi +doenv + if [[ $doDeps -eq 1 ]]; then : ok elif [[ "$nSetupArgs" -eq 1 ]] && [[ "${setupArgs[0]}" == *"clean"* ]]; then @@ -188,16 +180,12 @@ elif [[ "$nSetupArgs" -eq 1 ]] && [[ "${setupArgs[0]}" == *"clean"* ]]; then #echo "Cleaning FORTRAN" pushd ${MELADIR}/fortran &> /dev/null make clean - rm -f ../data/${SCRAM_ARCH}/libjhugenmela.so + rm -f ../data/${MELA_ARCH}/libjhugenmela.so popd &> /dev/null #echo "Cleaning COLLIER" ${MELADIR}/COLLIER/setup.sh "${setupArgs[@]}" - if [[ -e data/${SCRAM_ARCH}/TEMP ]]; then - rm -rf data/${SCRAM_ARCH} - fi - exit elif [[ "$nSetupArgs" -ge 1 ]] && [[ "$nSetupArgs" -le 2 ]] && [[ "${setupArgs[0]}" == *"-j"* ]]; then : ok @@ -209,11 +197,6 @@ else fi -if [[ ! -d data/${SCRAM_ARCH} ]]; then - cp -r data/${SARCH} data/${SCRAM_ARCH} - touch data/${SCRAM_ARCH}/TEMP -fi -doenv dodeps if [[ $doDeps -eq 1 ]]; then exit From 85a4cb20b95a3f3dc35a4966f9cf68aed32289d0 Mon Sep 17 00:00:00 2001 From: Ulascan Sarica Date: Mon, 5 Sep 2022 19:54:48 -0700 Subject: [PATCH 4/4] Remove obsolete file --- MELA/test/addProdProbtoTree.C | 282 ---------------------------------- 1 file changed, 282 deletions(-) delete mode 100644 MELA/test/addProdProbtoTree.C diff --git a/MELA/test/addProdProbtoTree.C b/MELA/test/addProdProbtoTree.C deleted file mode 100644 index 08a3596..0000000 --- a/MELA/test/addProdProbtoTree.C +++ /dev/null @@ -1,282 +0,0 @@ -#include "TLorentzVector.h" -#include "TLorentzRotation.h" -#include -#include "math.h" - -using namespace RooFit; -bool includePathIsSet = false; - -vector Calculate4Momentum(double Mx,double M1,double M2,double theta,double theta1,double theta2,double Phi1,double Phi); - -void addProdProbtoTree(){ - char* inputFile = (char *)"/scratch0/hep/ianderso/CJLST/130720d/PRODFSR_8TeV/4mu/HZZ4lTree_ZZTo4mu"; - int flavor=1; - int max=-1; - int LHCsqrts=8; - bool jhugen=false; - - gSystem->Load("$CMSSW_BASE/src/JHUGenMELA/MELA/data/$SCRAM_ARCH/libmcfm.so"); - gSystem->Load("$CMSSW_BASE/lib/slc5_amd64_gcc462/libZZMatrixElementMELA.so"); - - // set up path for local cmssw includes - // as well as roofit - if (!includePathIsSet) { - TString path = gSystem->GetIncludePath(); - path += "-I$CMSSW_BASE/src/ "; - path += "-I$ROOFITSYS/include/ "; - gSystem->SetIncludePath(path.Data()); - - // this is awkward, but want to protect against - // multiple additions to the base include path - // if this function is invoked multiple times per session - includePathIsSet = true; - } - - gROOT->LoadMacro("$CMSSW_BASE/src/JHUGenMELA/MELA/interface/Mela.h+"); - - Mela myMELA(LHCsqrts,flavor); - - char inputFileName[500]; - char outputFileName[500]; - sprintf(inputFileName,"%s.root",inputFile); - sprintf(outputFileName,"%s_withProbabilities.root",inputFile); - - TFile* sigFile = new TFile(inputFileName); - TTree* sigTree=0; - if(sigFile) - sigTree = (TTree*) sigFile->Get("SelectedTree"); - if(!sigTree){ - //2nd try with the name of data obs tree - sigTree = (TTree*) sigFile->Get("data_obs"); - if(!sigTree){ - cout<<"ERROR could not find the tree!"< *JetPt=0; - vector *JetEta=0; - vector *JetPhi=0; - vector *JetMass=0; - - float dXsec_HJJ_JHU = 0.; - float dXsec_HJJVBF_JHU = 0.; - float dXsec_HJJVH_JHU = 0.; - float dXsec_PSHJJ_JHU = 0.; - float dXsec_PSHJJVBF_JHU = 0.; - float dXsec_PSHJJVH_JHU = 0.; - - // -------- JHUGen TREES --------------- - if ( sigTree->GetBranchStatus("Jet1Px") ) - sigTree->SetBranchAddress("Jet1Px",&jet1px); - if ( sigTree->GetBranchStatus("Jet1Py") ) - sigTree->SetBranchAddress("Jet1Py",&jet1py); - if ( sigTree->GetBranchStatus("Jet1Pz") ) - sigTree->SetBranchAddress("Jet1Pz",&jet1pz); - if ( sigTree->GetBranchStatus("Jet1E") ) - sigTree->SetBranchAddress("Jet1E",&jet1E); - if ( sigTree->GetBranchStatus("Jet2Px") ) - sigTree->SetBranchAddress("Jet2Px",&jet2px); - if ( sigTree->GetBranchStatus("Jet2Py") ) - sigTree->SetBranchAddress("Jet2Py",&jet2py); - if ( sigTree->GetBranchStatus("Jet2Pz") ) - sigTree->SetBranchAddress("Jet2Pz",&jet2pz); - if ( sigTree->GetBranchStatus("Jet2E") ) - sigTree->SetBranchAddress("Jet2E",&jet2E); - if ( sigTree->GetBranchStatus("ZZPx") ) - sigTree->SetBranchAddress("ZZPx",&ZZPx); - if ( sigTree->GetBranchStatus("ZZPy") ) - sigTree->SetBranchAddress("ZZPy",&ZZPy); - if ( sigTree->GetBranchStatus("ZZPz") ) - sigTree->SetBranchAddress("ZZPz",&ZZPz); - if ( sigTree->GetBranchStatus("ZZE") ) - sigTree->SetBranchAddress("ZZE",&ZZE); - if ( sigTree->GetBranchStatus("deltaR") ) - sigTree->SetBranchAddress("deltaR",&dR); - //----------- CJLST TREES --------------- - if(!jhugen){ - if ( sigTree->GetBranchStatus("JetPt") ) - sigTree->SetBranchAddress( "JetPt" , &JetPt); - if ( sigTree->GetBranchStatus("JetEta") ) - sigTree->SetBranchAddress( "JetEta" , &JetEta); - if ( sigTree->GetBranchStatus("JetPhi") ) - sigTree->SetBranchAddress( "JetPhi" , &JetPhi); - if ( sigTree->GetBranchStatus("JetMass") ) - sigTree->SetBranchAddress( "JetMass" , &JetMass); - sigTree->SetBranchAddress( "Z1Mass" , &m1 ); - sigTree->SetBranchAddress( "Z2Mass" , &m2 ); - sigTree->SetBranchAddress( "helcosthetaZ1" , &h1 ); - sigTree->SetBranchAddress( "helcosthetaZ2" , &h2 ); - sigTree->SetBranchAddress( "costhetastar" , &hs ); - sigTree->SetBranchAddress( "helphi" , &phi ); - sigTree->SetBranchAddress( "phistarZ1" , &phi1 ); - sigTree->SetBranchAddress( "ZZMass" , &mzz ); - } - //--------------------------------------- - - TFile* newFile = new TFile(outputFileName,"RECREATE"); - TTree* newTree = sigTree->CloneTree(0);//new TTree("newTree","SelectedTree"); - - newTree->Branch("dXsec_HJJ_JHU" , &dXsec_HJJ_JHU ,"dXsec_HJJ_JHU/F"); - newTree->Branch("dXsec_HJJVBF_JHU" , &dXsec_HJJVBF_JHU ,"dXsec_HJJVBF_JHU/F"); - newTree->Branch("dXsec_HJJVH_JHU" , &dXsec_HJJVH_JHU ,"dXsec_HJJVH_JHU/F"); - newTree->Branch("dXsec_PSHJJ_JHU" , &dXsec_PSHJJ_JHU ,"dXsec_PSHJJ_JHU/F"); - newTree->Branch("dXsec_PSHJJVBF_JHU" , &dXsec_PSHJJVBF_JHU ,"dXsec_PSHJJVBF_JHU/F"); - newTree->Branch("dXsec_PSHJJVH_JHU" , &dXsec_PSHJJVH_JHU ,"dXsec_PSHJJVH_JHU/F"); - - if(max==-1) max=sigTree->GetEntries(); - - cout<GetEntries()<=sigTree->GetEntries()) break; - - //if ( iEvt != 112442 ) continue; - if(iEvt%1000==0) { - cout<<"event: "<GetEntry(iEvt); - - TLorentzVector jet1,jet2,higgs; - TLorentzVector p4[3]; - int NJets=0; - double energy, p3sq, ratio, rdiff; - if(jhugen){ - jet1.SetPxPyPzE(jet1px,jet1py,jet1pz,jet1E); - jet2.SetPxPyPzE(jet2px,jet2py,jet2pz,jet2E); - higgs.SetPxPyPzE(ZZPx,ZZPy,ZZPz,ZZE); - p4[0]=jet1; - p4[1]=jet2; - for(int f=0;f<2;f++){ - energy = p4[f].Energy(); - p3sq = sqrt( p4[f].Px()*p4[f].Px() + p4[f].Py()*p4[f].Py() + p4[f].Pz()*p4[f].Pz()); - ratio = energy / p3sq; - p4[f].SetPxPyPzE ( p4[f].Px()*ratio, p4[f].Py()*ratio, p4[f].Pz()*ratio, energy); - if(p4[f].Pt()>30. && fabs(p4[f].Eta())<4.7) NJets++; - } - rdiff=jet1.DeltaR(jet2); - if(rdiff<0.5) NJets--; - p4[2]=higgs; - } - if(!jhugen){ - //Gather jets - double jetptc=0.; - double jetetac=0.; - vector p; - TLorentzVector jets[10]; - NJets=0; - if ( JetPt != 0 ) { - for (unsigned int k=0; ksize();k++){ - if (NJets==10) continue; - jetptc=JetPt->at(k); - jetetac=JetEta->at(k); - //cout<at(k),JetEta->at(k),JetPhi->at(k),JetMass->at(k)); - double energy = jets[NJets].Energy(); - double p3sq = sqrt( jets[NJets].Px()*jets[NJets].Px() + jets[NJets].Py()*jets[NJets].Py() + jets[NJets].Pz()*jets[NJets].Pz()); - double ratio = energy / p3sq; - jets[NJets].SetPxPyPzE ( jets[NJets].Px()*ratio, jets[NJets].Py()*ratio, jets[NJets].Pz()*ratio, energy); - if (jetptc>30. && fabs(jetetac)<4.7){ - NJets++; - } - } - } - p4[0]=jets[0]; - p4[1]=jets[1]; - - //Build Higgs object - p=Calculate4Momentum(mzz,m1,m2,acos(hs),acos(h1),acos(h2),phi1,phi); - TLorentzVector Z1_minus = p[0]; - TLorentzVector Z1_plus = p[1]; - TLorentzVector Z2_minus = p[2]; - TLorentzVector Z2_plus = p[3]; - p4[2] = p[0]+p[1]+p[2]+p[3]; - } - - if(NJets>1){ - myMELA.setProcess(TVar::HJJVBF,TVar::JHUGen,TVar::QQB); - myMELA.computeProdP(p4[0],2,p4[1],2,p4[2],25,0.,0,dXsec_HJJVBF_JHU); - myMELA.setProcess(TVar::PSHJJVBF,TVar::JHUGen,TVar::QQB); - myMELA.computeProdP(p4[0],2,p4[1],2,p4[2],25,0.,0,dXsec_PSHJJVBF_JHU); - myMELA.setProcess(TVar::HJJNONVBF,TVar::JHUGen,TVar::QQB); - myMELA.computeProdP(p4[0],2,p4[1],2,p4[2],25,0.,0,dXsec_HJJ_JHU); - myMELA.setProcess(TVar::PSHJJNONVBF,TVar::JHUGen,TVar::QQB); - myMELA.computeProdP(p4[0],2,p4[1],2,p4[2],25,0.,0,dXsec_PSHJJ_JHU); - } - - newTree->Fill(); - - } - - newFile->cd(); - newTree->Write("SelectedTree"); - newFile->Close(); -} - -vector Calculate4Momentum(double Mx,double M1,double M2,double theta,double theta1,double theta2,double Phi1,double Phi){ - double phi1,phi2; - phi1=TMath::Pi()-Phi1; - phi2=Phi1+Phi; - - double gamma1,gamma2,beta1,beta2; - - gamma1=(Mx*Mx+M1*M1-M2*M2)/(2*Mx*M1); - gamma2=(Mx*Mx-M1*M1+M2*M2)/(2*Mx*M2); - beta1=sqrt(1-1/(gamma1*gamma1)); - beta2=sqrt(1-1/(gamma2*gamma2)); - - //gluon 4 vectors - TLorentzVector p1CM(0,0,Mx/2,Mx/2); - TLorentzVector p2CM(0,0,-Mx/2,Mx/2); - - //vector boson 4 vectors - TLorentzVector kZ1(gamma1*M1*sin(theta)*beta1,0, gamma1*M1*cos(theta)*beta1,gamma1*M1*1); - TLorentzVector kZ2(-gamma2*M2*sin(theta)*beta2,0, -gamma2*M2*cos(theta)*beta2,gamma2*M2*1); - - //Rotation and Boost matrices. Note gamma1*beta1*M1=gamma2*beta2*M2. - - TLorentzRotation Z1ToZ,Z2ToZ; - - Z1ToZ.Boost(0,0,beta1); - Z2ToZ.Boost(0,0,beta2); - Z1ToZ.RotateY(theta); - Z2ToZ.RotateY(TMath::Pi()+theta); - - - //fermion 4 vectors in vector boson rest frame - - TLorentzVector p3Z1((M1/2)*sin(theta1)*cos(phi1),(M1/2)*sin(theta1)*sin(phi1),(M1/2)*cos(theta1),(M1/2)*1); - TLorentzVector p4Z1(-(M1/2)*sin(theta1)*cos(phi1),-(M1/2)*sin(theta1)*sin(phi1),-(M1/2)*cos(theta1),(M1/2)*1); - TLorentzVector p5Z2((M2/2)*sin(theta2)*cos(phi2),(M2/2)*sin(theta2)*sin(phi2),(M2/2)*cos(theta2),(M2/2)*1); - TLorentzVector p6Z2(-(M2/2)*sin(theta2)*cos(phi2),-(M2/2)*sin(theta2)*sin(phi2),-(M2/2)*cos(theta2),(M2/2)*1); - - // fermions 4 vectors in CM frame - - TLorentzVector p3CM,p4CM,p5CM,p6CM; - - p3CM=Z1ToZ*p3Z1; - p4CM=Z1ToZ*p4Z1; - p5CM=Z2ToZ*p5Z2; - p6CM=Z2ToZ*p6Z2; - - vector p; - - p.push_back(p3CM); - p.push_back(p4CM); - p.push_back(p5CM); - p.push_back(p6CM); - - return p; -}