Project

General

Profile

Building artg4tk for Geant4 VMP Studies

Building Against a Moving Target

Unfortunately (or fortunately) artg4tk and the sub-package G4PhysModelParamStudy, as well as the underlying art and geant4 are under concurrent development and thus something of a moving target to build. By default artg4tk does not enable the necessary G4PhysModelParamStudy, and is also currently entangled with larcoreobj (which brings in unnecessary and/or conflicting dependencies for this study).

For this initial study we chose to fix the Geant4 version at the pre-built/installed version of v4_10_4, which also allows us to use CVMFS installed copies of the necessary Geant4 data, ala:

$ echo $GEANT4_DIR
/cvmfs/mu2e.opensciencegrid.org/artexternals/geant4/v4_10_4

$ ups_depend geant4 v4_10_4 -q e15:cl23:prof
geant4 v4_10_4 -q cl23:e15:prof
|__clhep v2_3_4_5c -q e15:prof
|  |__gcc v6_4_0
|__xerces_c v3_2_0 -q e15:prof
|  |__gcc v6_4_0
|__gcc v6_4_0
|__g4abla v3_1
|__g4emlow v7_3
|__g4neutron v4_5
|__g4neutronxs v1_4
|__g4nucleonxs v1_1
|__g4nuclide v2_2
|__g4photon v5_2
|__g4pii v1_3
|__g4radiative v5_2
|__g4surface v2_1
|__g4tendl v1_3_2

Given this choice one must find a compatible version of art to build against.

echo $ART_FQ_DIR
/cvmfs/mu2e.opensciencegrid.org/artexternals/art/v2_10_02/slf6.x86_64.e15.prof

Representative Steps (YMMV)

Do These Every Time

# define overall umbrella
export MRB_PROJECT=runartg4tk
export MYARTG4TKV="v0_03_00" 
MYTOP=/geant4/app/${USER}/mrb_${MRB_PROJECT}_${MYARTG4TKV}

# make some overall build choices
export QOPT="prof"   # "debug" or "prof" 
export EXX="e15" 
USECVMFS=yes

STARTDIR=`pwd`
# make output "pretty" 
if [ -f ~/.bash_colors ]; then source ~/.bash_colors ; fi

if [ -n "${USECVMFS}" ]; then
  source /cvmfs/oasis.opensciencegrid.org/geant4/externals/setup
  # add another location so we can use the best-est "ifdhc" 
  #    /grid/fermiapp/products/common/db
  COMMON_UPS=/cvmfs/fermilab.opensciencegrid.org/products/common/db
  LARSOFT_UPS=/cvmfs/fermilab.opensciencegrid.org/products/larsoft
  MU2E_UPS=/cvmfs/mu2e.opensciencegrid.org/artexternals

  export PRODUCTS=${PRODUCTS}:${COMMON_UPS}:${LARSOFT_UPS}:${MU2E_UPS}
else
  source /geant4/app/externals/setup
  # other locations
  COMMON_UPS=/grid/fermiapp/products/common/db
  LARSOFT_UPS=/grid/fermiapp/products/larsoft

  RWHUPS=/geant4/app/rhatcher/externals
  ALTUPS=/geant4/app/altups/

  export PRODUCTS=${RWHUPS}:${ALTUPS}:${PRODUCTS}:${COMMON_UPS}:${LARSOFT_UPS}
fi

# interact w/ PNFS only through ifdh cp & friends
setup ifdhc

# these are only need for code development, but whatever ...
# then we can use this interactively later
setup cmake v3_10_1

# mrb will setup git, gitflow, cetpkgsupport
setup mrb           v1_13_02
setup cetbuildtools v7_00_03

######### Geant4 & art
# make consistent CHOICES !!! 
setup geant4 v4_10_4    -q +${EXX}:+${QOPT}:+cl23
setup art    v2_10_02   -q +${EXX}:+${QOPT}

Check Current Dependencies


ups_depend ()
{
    ups depend $* | sed -e 's%-f Linux[a-z0-9.+-]*%%g' \
                        -e 's% -z [/.a-zA-Z0-9]*%%g' \
                        -e 's%  -q% -q%g' \
                        -e 's%-f NULL%%g'
}
ups_depend `echo ${SETUP_GEANT4}`
ups_depend `echo ${SETUP_ART}`

Initialize mrb area (do only once)


if [ ! -d ${MYTOP} ]; then
  echo -e "${OUTLTRED}create ${MYTOP}${OUTNOCOL}" 
  mkdir -p ${MYTOP}
fi

echo -e "${OUTGREEN}cd ${MYTOP}${OUTNOCOL}" 
cd ${MYTOP}

if [ ! -d srcs ]; then
  echo -e "${OUTLTRED}mrb newDev ${MYTOP}${OUTNOCOL}" 
  mrb newDev -v ${MYARTG4TKV} -q ${EXX}:${QOPT}
fi

Do This Every Time (after initial mrb area setup)


MYMRB_SETUP_DIR=localProducts_${MRB_PROJECT}_${MYARTG4TKV}_${EXX}_${QOPT}
echo -e "${OUTCYAN}source ${MYTOP}/${MYMRB_SETUP_DIR}/setup${OUTNOCOL}" 
source ${MYTOP}/${MYMRB_SETUP_DIR}/setup
DIDSETUP=1

Checkout artg4tk (do once)


if [ ! -d srcs/artg4tk ]; then
  echo -e "${OUTGREEN}cd srcs${OUTNOCOL}" 
  cd srcs        # equiv to cd ${MRB_SOURCE}
  echo -e "${OUTLTRED}mrb g artg4tk${OUTNOCOL}" 
  mrb g artg4tk  # check out git + update src/CMakeLists.txt
  DIDSETUP=0
fi

Hack Up artg4tk For Our Version Choices (do once)


echo -e "${OUTLTRED}" 
if [ ! -f ${MRB_SOURCE}/artg4tk/ups/product_deps.original ]; then
  echo "edit ups/product_deps" 
  # remove the geant4 if non-UPS custom build
  # "art" qualifier (2nd _column_ ) needs ${EXX}:<prof|debug>:nu
  sed -i.original \
    -e "/^art/s/.*/art             ${ART_VERSION}/g" \
    -e "/^cetbuildtools/s/.*/cetbuildtools   ${CETBUILDTOOLS_VERSION}     -  only_for_build/g" \
    -e "/^geant4/s/.*/geant4          ${GEANT4_VERSION}/g" \
    -e "s/e7:debug/${EXX}:debug/g"  -e "s/e7:prof/${EXX}:prof/g" \
    -e "s/e9:debug/${EXX}:debug/g"  -e "s/e9:prof/${EXX}:prof/g" \
    -e "s/e10:debug/${EXX}:debug/g" -e "s/e10:prof/${EXX}:prof/g" \
    -e "s/e12:debug/${EXX}:debug/g" -e "s/e12:prof/${EXX}:prof/g" \
    -e "s/e14:debug/${EXX}:debug/g" -e "s/e14:prof/${EXX}:prof/g" \
    -e "s/${EXX}:debug *${EXX}:debug *${EXX}:debug/${EXX}:debug ${EXX}:debug:nu ${EXX}:debug/g" \
    -e "s/${EXX}:prof *${EXX}:prof *${EXX}:prof/${EXX}:prof ${EXX}:prof:nu ${EXX}:prof/g" \
    ${MRB_SOURCE}/artg4tk/ups/product_deps
  DIDSETUP=0
fi

if [ ! -f ${MRB_SOURCE}/artg4tk/CMakeLists.txt.original ]; then
  echo "edit CMakeLists.txt" 
  # note special form for find_ups_geant4( ... don't make it find_ups_product(
  sed -i.original \
    -e "/^find_ups_product(cetbuildtools/s/.*/find_ups_product(cetbuildtools ${CETBUILDTOOLS_VERSION})/g" \
    -e "/find_ups_geant4(/s/.*/find_ups_geant4(${GEANT4_VERSION})/g" \
    -e "/find_ups_product(geant4/s/.*/find_ups_product(geant4 ${GEANT4_VERSION})/g" \
    -e "/find_ups_product(xerces_c/s/.*/find_ups_product(xerces_c ${XERCES_C_VERSION})/g" \
    -e "/find_ups_product(art/s/.*/find_ups_product(art ${ART_VERSION})/g" \
    -e "/find_ups_product(canvas/s/.*/find_ups_product(canvas ${CANVAS_VERSION})/g" \
    -e "/find_ups_product(fhiclcpp/s/.*/find_ups_product(fhiclcpp ${FHICLCPP_VERSION})/g" \
    -e "/find_ups_product(messagefacility/s/.*/find_ups_product(messagefacility ${MESSAGEFACILITY_VERSION})/g" \
    ${MRB_SOURCE}/artg4tk/CMakeLists.txt
  # also if "canvas" isn't there already then we need to add it
  hasCanvas=`grep -c "find_ups_product(canvas" ${MRB_SOURCE}/artg4tk/CMakeLists.txt`
  if [ ${hasCanvas} -eq 0 ]; then
    sed -i.addcanvas \
    -e "/find_ups_product(art/s/)/)\nfind_ups_product(canvas ${CANVAS_VERSION})/g" \
    ${MRB_SOURCE}/artg4tk/CMakeLists.txt
  fi
  #
  # in case source was still for ART v1
  echo -e "${OUTRED}skipping \${CANVAS_DIR}/tools/canvas_refactor/update_for_art.sh `pwd` ${OUTNOCOL}" 
  #### ${CANVAS_DIR}/tools/canvas_refactor/update_for_art.sh `pwd`
  #
  DIDSETUP=0
fi
echo -e "${OUTNOCOL}" 

if [ ${DIDSETUP} -eq 0 ]; then
  source ${MYTOP}/${MYMRB_SETUP_DIR}/setup
fi

Checkout and Build ROOT6 Compatible RooMUHistos (do once)


if [ ! -d ${MYTOP}/srcs/RooMUHistos ]; then
  echo -e "${OUTRED}missing ${MYTOP}/srcs/RooMUHistos${OUTNOCOL}" 
  cd ${MYTOP}/srcs
  # git clone https://github.com/ManyUniverseAna/RooMUHistos
  # my version w/ ROOT 6 fixes
  echo git clone https://github.com/nusense/RooMUHistos
       git clone https://github.com/nusense/RooMUHistos
fi

if [ -d ${MYTOP}/srcs/RooMUHistos ]; then
  echo -e "${OUTGREEN}sourcing ${MYTOP}/srcs/RooMUHistos env_set.sh${OUTNOCOL}" 
  cd ${MYTOP}/srcs/RooMUHistos
  source ./env_set.sh
  export ROOT_INCLUDE_PATH=${ROOT_INCLUDE_PATH}:${MYTOP}/srcs/RooMuHistos/PlotUtils
else
  echo -e "${OUTRED}STILL missing ${MYTOP}/srcs/RooMUHistos${OUTNOCOL}" 
fi

Checkout Scripts (do once)


if [ ! -d ${MYTOP}/srcs/runartg4tk ]; then
  echo -e "${OUTRED}missing ${MYTOP}/srcs/runartg4tk${OUTNOCOL}" 
  cd ${MYTOP}/srcs
  echo git clone https://github.com/nusense/runartg4tk
       git clone https://github.com/nusense/runartg4tk
  # add this to the things mrb should build
cat >> CMakeLists.txt <<EOF
# DO NOT DELETE
# artg4tk package block
set(runartg4tk_not_in_ups true)
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR}/runartg4tk )
include_directories ( $ENV{MRB_BUILDDIR}/runartg4tk )

# DO NOT DELETE
ADD_SUBDIRECTORY(runartg4tk)
EOF

fi

??


cd ${MRB_SOURCE}/..
# this should be an alias for source ${MRB_DIR}/bin/mrbSetEnv
echo -e "${OUTGREEN}mrbsetenv${OUTNOCOL}" 
# mrbsetenv
source ${MRB_DIR}/bin/mrbSetEnv

############################################################################

ARTG4TK_QUAL_UNDERSCORE=${EXX}_${QOPT}
echo -e "${OUTGREEN}MRB_TOP=${MRB_TOP}${OUTNOCOL}" 
cd ${MRB_TOP}
source ./localProducts_${MRB_PROJECT}_${MYARTG4TKV}_${ARTG4TK_QUAL_UNDERSCORE}/setup

Build RooMUHistos (should only need to be done once)


echo -e "${OUTGREEN}cd ${MRB_TOP}/srcs/RooMUHistos${OUTNOCOL}" 
cd ${MRB_TOP}/srcs/RooMUHistos
source ./env_set.sh
if [ ! -f lib/libplotutils_rdict.pcm ]; then
  echo -e "${OUTGREEN}cd PlotUtils ; make all${OUTNOCOL}" 
  cd PlotUtils
  make all
fi

echo -e "${OUTGREEN}cd ${MRB_TOP}${OUTNOCOL}" 
cd ${MRB_TOP}

Prepare to build & "install" mrb products


# mrbsetenv is an alias for the complete command below;
# it will NOT work if issued from a script - one has to "source" it explicitly
# and this should be done AFTER source-ing this ./localProducts...../setup thing
# such deps on MRB are NOT super convenient, and at some point we might want
# to explore alternatives ^_^
#
echo -e "${OUTGREEN}source ${MRB_DIR}/bin/mrbSetEnv${OUTNOCOL}" 
source ${MRB_DIR}/bin/mrbSetEnv

cd ${STARTDIR}
echo MYARTG4TKV=${MYARTG4TKV}

echo -e "${OUTGREEN}cd ${MRB_BUILDDIR}${OUTNOCOL}" 
cd ${MRB_BUILDDIR}

echo -e "${OUTRED}at this point you might: ${OUTCYAN}mrb i${OUTNOCOL}" 

# end-of-script

Changes for Choice of art, Geant4, and Removing larcoreobj Dependency

cd $MRB_SOURCE/artg4tk
$ git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   CMakeLists.txt
    deleted:    artg4tk/Analysis/CheckSimEnergyDepositHit_module.cc
    deleted:    artg4tk/Analysis/CheckSimEnergyDepositHit_module.hh
    modified:   artg4tk/CMakeLists.txt
    modified:   artg4tk/pluginDetectors/gdml/GDMLDetector_service.cc
    deleted:    artg4tk/pluginDetectors/gdml/SimEnergyDepositHit.hh
    deleted:    artg4tk/pluginDetectors/gdml/SimEnergyDepositSD.cc
    deleted:    artg4tk/pluginDetectors/gdml/SimEnergyDepositSD.hh
    modified:   artg4tk/pluginDetectors/gdml/classes.h
    modified:   artg4tk/pluginDetectors/gdml/classes_def.xml
    modified:   ups/product_deps

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    CMakeLists.txt.original
    CMakeLists.txt_save_postreorg_origin
    CMakeLists.txt_save_prereorg
    artg4tk/Analysis/CheckSimEnergyDepositHit_module.cc_skip
    artg4tk/Analysis/CheckSimEnergyDepositHit_module.hh_skip
    artg4tk/pluginDetectors/gdml/SimEnergyDepositHit.hh_skip
    artg4tk/pluginDetectors/gdml/SimEnergyDepositSD.cc_skip
    artg4tk/pluginDetectors/gdml/SimEnergyDepositSD.hh_skip
    ups/product_deps.original
    ups/product_deps_save_postreorg_origin
    ups/product_deps_save_prereorg

no changes added to commit (use "git add" and/or "git commit -a")

The diffs are attached below.