permalink: /aio/index.html —
Basic Setup - tested on OSX
Overview
Teaching: 30 min
Exercises: 30 minQuestions
How do I get started in scientific programing
Objectives
Learn how to use command line tools
Install software you need to do scientific programing
0. Back up your machine
We are going to be messing with your operating system at some level so it is extremely wise to do a complete backup of your machine to an external drive right now.
Also turn off automatic updates. Operating system updates can mess with your setup. Generally, back up before doing updates so you can revert if necessary.
1. Open a unix terminal window
First figure out how to open a terminal on your system. The Carpentries Shell Training has a section that explains this
This should be easy on Linux and OSX but a bit more complicated in Windows.
2. Learn how to use the Unix Shell
There is a nice tutorial from the Carpentries at: Unix Shell Basics.
It tells you how to start a terminal session in Windows, Mac OSX and Unix systems.
Please do the unix shell tutorial to learn about the basic command line.
3. Install some basic tools
You are going to need to install some common tools on your local machine
1. Install Git
Github is a repository for shared code. It is also a good place to back up your code and share with others. You will need to set up an account if you want to store things there. For now we are just going to use it to grab other people’s software so you don’t need to set up an account yet.
Start out by doing the setup/install section of the tutorial at https://swcarpentry.github.io/git-novice/02-setup.html to get started. You can come back and do the full tutorial later.
2. Get a compiler/code editor
Although you will mainly be using python to code to begin with, most HEP code is actually C++ and it is good to have access to a C++ compiler. Bonus is that you normally get a good editor as well.
OSX
Compiler/editor: On OSX, you should install Xcode from the App store. It will take a lot of disk space. When you try to use it it will ask you to install command line tools. Do so.
Compiler/editor: Even though Xcode is what you use to compile and has an editor, many people prefer to use the Visual Studio Code application from Microsoft for editing/testing code.
You can also use vim or emacs if you are old school.
Unix
-
Compiler: your compiler will be gcc
-
Editor: Heck - just use vim. Or emacs, or VSCode.
Windows
Likely you should load up the full Visual Studio as it has a nice C++ compiler
3. Install an x-windows emulator
OSX
Install XQuartz
test it out by typing
xterm &
You should get a terminal window. You can close it.
Unix
Already have one
test by doing
xterm &
Windows
See the information about putty and xming.
4. Install Conda
See Next lesson
Useful Links
Key Points
This will be useful for a lot of projects
It is also something almost all people who get paid to program are expected to know well
Use Conda to install root
Overview
Teaching: 30 min
Exercises: 0 minQuestions
How do I get root and jupyter-lab for simple analysis
Objectives
get miniconda set up on your machine
install root and jupyter-lab
Here are instruction on how to set up a package manager (conda) and install ROOT.
Why do we need a package manager? ROOT is a complicated program that needs to have consistent versions of python and other products to work properly. By using a package manager, we can maintain consistency.
Installing conda and root
This is derived from the excellent https://iscinumpy.gitlab.io/post/root-conda/ by Henry Schreiner
Currently this has been tested on OSX and Linux distributions SL7 and AL9
1. Download miniconda (or Anacoda)
Miniconda is a free subset of the Anaconda package manager. Anaconda is free for individual use but can run into licensing issues so many people go with Miniconda.
Miniconda
- Do you have wget on your system? If not, get it
- Download the miniconda installer
# Download the Linux installer
wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
# Or download the macOS installer
wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
Install conda
# Install Conda (same for macOS and Linux)
bash miniconda.sh -b -p $HOME/miniconda
- add this to your .bashrc or .profile to start it up when you log in
source $HOME/miniconda/etc/profile.d/conda.sh # Add to bashrc - similar files available for fish and csh
Making an environment with root in it
conda create -n my_root_env root -c conda-forge
This will take a while. In the end you have an environment which contains root and a lot of other useful things
You can repeat step 1 to make different conda enviroments which you can use for different projects!
Try out your new environment
To activate a particular environment you do:
conda activate my_root_env
First time you use your environment you can do
conda config --add --env channels conda-forge
the config command tells conda to use conda-forge as a default. You should now have a conda environment with root in it.
You can use conda to install other code (for example I have installed, ruby, jupyterlab and jsoncpp for various projects).
Testing
(my_root_env) wngr405-mac3:utilities schellma$ root
------------------------------------------------------------------
| Welcome to ROOT 6.28/00 https://root.cern |
| (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosx64 on Mar 21 2023, 08:18:00 |
| From tag , 3 February 2023 |
| With |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [1] .q
To get out of root type
root> .q
Try this
root -l -q $ROOTSYS/tutorials/dataframe/df013_InspectAnalysis.C
You should see a plot that updates.
Key Points
useful mainly for simple tuple analysis
Documentation notes
Overview
Teaching: 30 min
Exercises: 30 minQuestions
References on documenting code
Objectives
Learn how do document procedures, python and C++
General text formatting in Markdown
https://github.com/hsf-training/carpentry-cookiecutter
Generating lessons like this
Documenting complex python packages with sphinx and readthedocs
sphinx is a documentation system for python code that can be used with rst or with Markdown. You can set up github actions to build custom <organization>.github.io pages from repository github.com/<organization>.
Alternatively readthedocs is a semi-commercial system that uses sphinx/rst and provides the build infrastructure.
C++
Key Points
This will be useful for a lot of projects
It is also something almost all people who get paid to program are expected to know well