Skip to content

Instantly share code, notes, and snippets.

@matthewfeickert
Last active July 10, 2020 08:43
Show Gist options
  • Save matthewfeickert/e80bd22dc485ce6092a2fa7ec5ed85c1 to your computer and use it in GitHub Desktop.
Save matthewfeickert/e80bd22dc485ce6092a2fa7ec5ed85c1 to your computer and use it in GitHub Desktop.
xAH CMake FetchContent problem
*.asetup.save
build/
submitDir/

On LXPLUS or ATLAS Connect

Failing example

$ bash build.sh
$ bash example.sh

Passing example

Comment out the following lines in CMakeLists.txt

#include(FetchContent)
#
#FetchContent_Declare(
#  xAODAnaHelpers
#  GIT_REPOSITORY https://github.com/UCATLAS/xAODAnaHelpers.git
#  GIT_TAG        b3feeb1e34782478900bf060dd5a27eb8d8ed2d7
#)
#FetchContent_MakeAvailable(xAODAnaHelpers)

and add xAH as a Git submodule in the top level (a dumb place to put it but then don't have to edit anything else)

$ git submodule add https://github.com/UCATLAS/xAODAnaHelpers.git

then

$ bash build.sh
$ bash example.sh
#!/usr/bin/env bash
function print_and_run () {
printf "\n# %s\n" "${1}"
eval $(echo "$1")
}
function setNumProcessors () {
# Set the number of processors used for build
# to be 1 less than are available
if [[ -f "$(which nproc)" ]]; then
NPROC="$(nproc)"
else
NPROC="$(grep -c '^processor' /proc/cpuinfo)"
fi
echo "$(($(nproc)-1))"
}
if [ "$(basename -- $0)" = "$(basename ${BASH_SOURCE})" ]; then
# running in subshell
# Define setupATLAS and asetup
ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
function setupATLAS {
source "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"
}
fi
function envSetup {
baseDir=${PWD}
print_and_run "setupATLAS"
print_and_run "lsetup python git asetup"
}
function build {
AtlasRelease="21.2.121"
echo "Target ATLAS Release will be ${AtlasRelease}."
if [[ -f "${baseDir}/.asetup.save" ]]; then
rm "${baseDir}/.asetup.save"
fi
cd "${baseDir}"
print_and_run "asetup ${AtlasRelease},AnalysisBase"
if [[ -d "${baseDir}/build" ]]; then
rm -rf "${baseDir}/build"
fi
print_and_run "mkdir -p build run"
cd "${baseDir}"
print_and_run "cd build"
print_and_run "cmake .."
NPROC="$(setNumProcessors)"
printf "\n# %s\n" "cmake --build . -- -j${NPROC}"
cmake --build . -- -j${NPROC}
cd ..
printf "\n### Run: source "$(find ./build -iname "setup.sh" | sed 's/.\///')"\n"
source build/*/setup.sh
echo ""
}
# Run program
envSetup
build
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
# Modified version of the AnalysisBase template
# Set the minimum required CMake version:
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 14)
# Make sure that all _ROOT variables *are* used when they are set.
if( POLICY CMP0074 )
cmake_policy( SET CMP0074 NEW )
endif()
# Find the base project.
find_package( AnalysisBase 21.2 REQUIRED )
# Set up the usage of CTest.
atlas_ctest_setup()
# Make sure that the project-wide rootmap file merge would use xAODAnaHelper's
# dictionary.
set_property( GLOBAL APPEND PROPERTY ATLAS_ROOTMAP_FILES
"${CMAKE_BINARY_DIR}/_deps/xaodanahelpers-build${CMAKE_FILES_DIRECTORY}/xAODAnaHelpersLib.dsomap" )
set_property( GLOBAL APPEND PROPERTY ATLAS_ROOTMAP_TARGETS "xAODAnaHelpersLib" )
atlas_project( example 0.1.0
USE AnalysisBase 21.2 )
message("")
# Get external dependencies
include(FetchContent)
FetchContent_Declare(
xAODAnaHelpers
GIT_REPOSITORY https://github.com/UCATLAS/xAODAnaHelpers.git
GIT_TAG b3feeb1e34782478900bf060dd5a27eb8d8ed2d7
)
FetchContent_MakeAvailable(xAODAnaHelpers)
# Set up the runtime environment setup script(s):
lcg_generate_env( SH_FILE ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh )
install( FILES ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh
DESTINATION . )
# Set up CPack:
atlas_cpack_setup()
## Try to figure out what project is our parent. Just using a hard-coded list
## of possible project names. Basically the names of all the other
## sub-directories inside the Projects/ directory in the repository.
#set( _parentProjectNames Athena AthenaP1 AnalysisBase AthAnalysis
#AthSimulation AthDerivation AnalysisTop )
#set( _defaultParentProject AnalysisBase )
#foreach( _pp ${_parentProjectNames} )
#if( NOT "$ENV{${_pp}_DIR}" STREQUAL "" )
#set( _defaultParentProject ${_pp} )
#break()
#endif()
#endforeach()
#
## Set the parent project name based on the previous findings:
#set( ATLAS_PROJECT ${_defaultParentProject}
#CACHE STRING "The name of the parent project to build against" )
## Clean up:
#unset( _parentProjectNames )
#unset( _defaultParentProject )
#
## Pick up a local version of the AtlasCMake code if it exists:
#find_package( AtlasCMake QUIET )
#
#find_package( ${ATLAS_PROJECT} REQUIRED )
#
#set(ATLAS_PROJECT_VERSION "${${ATLAS_PROJECT}_VERSION}")
#message("")
#message("-- ATLAS_PROJECT: ${ATLAS_PROJECT} ${ATLAS_PROJECT_VERSION}")
#message("")
#
## Set up CTest. This makes sure that per-package build log files can be
## created if the user so chooses.
#atlas_ctest_setup()
#
#atlas_project( example 0.1.0
#USE ${ATLAS_PROJECT} ${ATLAS_PROJECT_VERSION} )
#message("")
#
#
#
## Set up the runtime environment setup script(s):
#lcg_generate_env( SH_FILE ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh )
#install( FILES ${CMAKE_BINARY_DIR}/${ATLAS_PLATFORM}/env_setup.sh
#DESTINATION . )
#
## Set up CPack:
#atlas_cpack_setup()
from xAODAnaHelpers import Config
config = Config()
# truncated example just to make a point
good_run_lists = [
"GoodRunsLists/data15_13TeV/20170619/data15_13TeV.periodAllYear_DetStatus-v89-pro21-02_Unknown_PHYS_StandardGRL_All_Good_25ns.xml",
"GoodRunsLists/data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml",
"GoodRunsLists/data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml",
"GoodRunsLists/data18_13TeV/20180906/data18_13TeV.periodAllYear_DetStatus-v102-pro22-03_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml",
]
lumi_calc_files = [
"GoodRunsLists/data18_13TeV/20190708/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root",
"GoodRunsLists/data18_13TeV/20190708/ilumicalc_histograms_None_354396-355468_OflLumi-13TeV-001.root",
"GoodRunsLists/data17_13TeV/20190708/ilumicalc_histograms_None_325713-340453_OflLumi-13TeV-010.root",
"GoodRunsLists/data17_13TeV/20190708/ilumicalc_histograms_None_341294-341649_OflLumi-13TeV-001.root",
"GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root",
"GoodRunsLists/data15_13TeV/20170619/PHYS_StandardGRL_All_Good_25ns_276262-284484_OflLumi-13TeV-008.root",
]
single_jet_triggers = [
"HLT_j0_perf_L1RD0_FILLED",
"HLT_j15",
"HLT_j25",
"HLT_j60",
"HLT_j85",
"HLT_j110",
"HLT_j175",
"HLT_j260",
"HLT_j360",
"HLT_j340",
"HLT_j380",
"HLT_j400",
"HLT_j420",
"HLT_j450",
"HLT_j420",
]
is_MC = True # for simulation
# is_MC = False # for data
config.algorithm(
"BasicEventSelection",
{
"m_name": "BasicEventSelector",
"m_isMC": is_MC,
"m_truthLevelOnly": False,
"m_doPUreweighting": True,
"m_doPUreweightingSys": True,
"m_autoconfigPRW": True,
"m_periodConfig": "auto",
"m_vertexContainerName": "PrimaryVertices",
"m_applyPrimaryVertexCut": False,
"m_applyGRLCut": False,
"m_GRLxml": ",".join(good_run_lists),
"m_lumiCalcFileNames": ",".join(lumi_calc_files),
"m_prwActualMu2017File": "GoodRunsLists/data17_13TeV/20190708/purw.actualMu.2017.root",
"m_prwActualMu2018File": "GoodRunsLists/data18_13TeV/20190708/purw.actualMu.2018.root",
"m_useMetaData": False,
"m_triggerSelection": "|".join(single_jet_triggers),
"m_applyTriggerCut": False,
"m_applyEventCleaningCut": False,
"m_applyCoreFlagsCut": True,
"m_applyJetCleaningEventFlag": False,
},
)
#!/bin/bash
if [ "$(basename -- $0)" = "$(basename ${BASH_SOURCE})" ]; then
# running in subshell
# Define setupATLAS and asetup
ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
function setupATLAS {
source "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh"
}
fi
baseDir=${PWD}
# environment setup
setupATLAS
lsetup python git asetup
AtlasRelease="21.2.121"
cd "${baseDir}" || exit
asetup "${AtlasRelease},AnalysisBase"
source "${baseDir}"/build/*/setup.sh
# Might not be $USER depending on location
SITE_USER="${USER}"
# check for any valid Kerberos tickets
klist -s
# if not, then kinit and get one
if [[ $? -eq 1 ]]; then
printf "\n### kinit ${SITE_USER}@CERN.CH\n"
kinit ${SITE_USER}@CERN.CH
printf "\n### aklog -c cern.ch -k CERN.CH\n"
aklog -c cern.ch -k CERN.CH
fi
printf "\n### klist\n"
klist
printf "\n### voms-proxy-init -voms atlas\n"
voms-proxy-init -voms atlas
printf "\n### lsetup rucio\n"
lsetup rucio
if [[ -d "${baseDir}/submitDir" ]]; then
rm -rf "${baseDir}/submitDir"
fi
xAH_run.py \
--config "${baseDir}"/example.py \
--files mc16_13TeV:mc16_13TeV.364703.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ3WithSW.deriv.DAOD_JETM1.e7142_s3126_r10201_p4049/ \
--inputRucio \
--nevents 10000 \
--force \
direct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment