% Created 2026-03-03 Tue 15:23
% Intended LaTeX compiler: pdflatex
\documentclass[usenames,dvipsnames,colorlinks,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{color}
\usepackage{listings}
\usepackage{pdfpages}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{libertine}
\usepackage{fontawesome}
\mode<beamer>{\usetheme{Boadilla}}
\setbeamertemplate{navigation symbols}{}
\setbeamerfont{alerted text}{series=\bfseries}
\setbeamercolor{alerted text}{fg=blue}
\usecolortheme{default}
\usefonttheme{serif}
\usefonttheme{professionalfonts}
\lstloadlanguages{[ISO]C++}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.50,0,0.82}
\definecolor{codeorange}{rgb}{0.95,0.3,0.1}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
commentstyle=\color{codegreen},
keywordstyle=\color{codeorange},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\usetheme{default}
\author{Brett Viren}
\date{\today}
\title{Spack-based build of edep-sim and eic-opticks}
\subtitle{And how to use it for development}
\hypersetup{
 pdfauthor={Brett Viren},
 pdftitle={Spack-based build of edep-sim and eic-opticks},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 30.1 (Org mode 9.8-pre)},
 pdflang={English}}
\begin{document}

\maketitle
\begin{frame}[label={sec:org8765d40}]{Topicks (sic)}
\begin{itemize}
\item Building the packages with Spack
\item Building a developer environment
\item Plan for initial development
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org55b4a40},fragile]{Base spack build}
 \begin{block}{Spack}
\scriptsize
\begin{verbatim}
git clone --branch v1.1.1 --depth=2 https://github.com/spack/spack.git
source spack/share/spack/setup-env.sh 
spack compiler find
spack bootstrap now
\end{verbatim}
\end{block}
\begin{block}{Our packages}
\scriptsize
\begin{verbatim}
git clone https://github.com/WireCell/edep-opticks-spack.git
spack repo add edep-opticks-spack/edep_opticks/
spack install --jobs 16 edepsim+opticks cxxstd=17
\end{verbatim}
\end{block}
\begin{block}{Comments}
\scriptsize

\begin{itemize}
\item In principle, \texttt{cxxstd=20} can be used instead (need C++20 in FNAL ecosystem).
\item This is purely a \alert{local build}, no dependencies on WCWC, UPS, CVMFS, FNAL-spack, etc.
\item The \texttt{+opticks} variant causes \texttt{eic-opticks} to build though edep-sim does not yet actually depend on it.
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[label={sec:orgae37b25},fragile]{Spack View based developer environment}
 \scriptsize
\begin{verbatim}
mkdir hack && cd hack/

spack view --dependencies yes -i local --exclude edepsim  \
      add edepsim@master+opticks cxxstd=17
git clone https://github.com/ClarkMcGrew/edep-sim.git

./local/bin/cmake -S edep-sim -B edep-sim-build \
                  -DCMAKE_INSTALL_PREFIX=$PWD/local \
                  -DCMAKE_INSTALL_RPATH='$ORIGIN/../lib' \
                  -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON                    
./local/bin/cmake --build edep-sim-build
./local/bin/cmake --install edep-sim-build
./local/bin/edep-sim
\end{verbatim}

\begin{itemize}
\item Build stays outside of source area (inside is okay if you prefer).
\item The ``view'' provides \texttt{local/\{bin,lib,include\}/} with symlinks to all dependencies.
\item We also install our developer build into the view directory.
\item The \texttt{RPATH} directives mean we don't have to mess with \texttt{LD\_LIBRARY\_PATH}.
\item May want to \texttt{-{}-{}exclude eicopticks} if you also want to develop eic-opticks.
\item Can \texttt{rm -rf local/} and remake, at will.
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org65ec2ef},fragile]{Developer shell environment with Direnv}
 By default, a Spack View does not provide any \alert{shell environment}.

My favorite is to make \texttt{hack/.envrc} file with this line:

\begin{verbatim}
load_prefix "$PWD/local"
\end{verbatim}

Can include bash-like variable settings as well.  Then add to your \texttt{\textasciitilde{}/.bashrc} or similar

\begin{verbatim}
eval $(direnv hook bash)
\end{verbatim}

Then when you \texttt{cd} to your \texttt{hack/} directory the environment settings are applied
automatically and removed when you \texttt{cd} elsewhere.  Eg, can now run without giving
explicit path:

\begin{verbatim}
$ cmake [....]
$ edep-sim [....]
\end{verbatim}
\end{frame}
\begin{frame}[label={sec:org6a6967d},fragile]{Initial development plan}
 I think we do not yet know best way to integrate and suggest a two phase approach.
\begin{block}{Phase 1: a quick, throw-away hack with no care for ``design''.}
\begin{enumerate}
\item Fork \url{https://github.com/ClarkMcGrew/edep-sim.git}
\item Replace ``vanilla'' G4 optical with calls to \texttt{G4CXOpticks}.
\end{enumerate}

In this process we will learn both edep-sim and eic-opticks / \texttt{G4CXOpticks} designs.   
\end{block}
\begin{block}{Phase 2: factored design with PR back to origin}
\begin{enumerate}
\item Develop good design blessed by Clark and Gabor.
\item Add to edep-sim a compile-time dependency on eic-opticks, default: OFF.
\item Implement a run-time choice between ``vanilla'' G4 optical and use of \texttt{G4CXOpticks}.
\end{enumerate}
\end{block}
\end{frame}
\begin{frame}[label={sec:orgc86d733}]{Links}
\begin{block}{Repos}
\begin{itemize}
\item \url{https://github.com/ClarkMcGrew/edep-sim}
\item \url{https://github.com/BNLNPPS/eic-opticks}
\item \url{https://github.com/wirecell/edep-opticks-spack} (spack repo)
\item \url{https://github.com/brettviren/winch} (containers)
\item \url{https://github.com/BNLNPPS/esi-shell} (containers)
\end{itemize}
\end{block}
\begin{block}{DeepWiki repo summaries}
\begin{itemize}
\item \url{https://deepwiki.com/ClarkMcGrew/edep-sim}
\item \url{https://deepwiki.com/BNLNPPS/eic-opticks}
\end{itemize}
\end{block}
\begin{block}{Opticks upstream}
\begin{itemize}
\item \url{https://simoncblyth.bitbucket.io}
\end{itemize}
\end{block}
\end{frame}
\end{document}
