Simple Example

This is a simple example of how to make a plot from real data. The assumed input is an art ROOT file resulting from the tier 0 processing (unpacking). An example art ROOT file is attached to this page (Lab3StrawDigits_00278.root).

This uses a simple example analyzer for making plots from straw digits.


Environment script

It helps to create a set up script to simplify settings up the environment.

Use the example below and name it

Update the following paths to match your system:

  • OFFLINE_DIR - path to your offline area (your workspace will be created within this directory)
# Setup script for g-2 offline code

#Define basic info
OFFLINE_DIR=/home/nfs/stuttard/digits                           #Root directory for g-2 offline software packages
VERSION=v7_01_00                                                #g-2 software version
WORKSPACE=$OFFLINE_DIR/gm2Dev_${VERSION}                        #Path to your workspace
FLAG=prof                                                       #Version flag
export OFFLINE_DATA_DIR=$WORKSPACE/data                         #Directory outside of git repositories to write output to

#Offline environment
echo "" 
echo "Setup offline environment" 
OFFLINE_ENV_SCRIPT=/cvmfs/ #Offsite
if [ ! -f "$OFFLINE_ENV_SCRIPT" ]; then
  echo ">>>ERROR<<< Offline environment script \"${OFFLINE_ENV_SCRIPT}\" does not exist" 

#Use ninja
setup ninja v1_6_0b
alias makeninja='pushd $MRB_BUILDDIR ; ninja ; popd'

#Create workspace directory ifs required
if [ ! -d "$WORKSPACE" ]; then
  echo "" 
  echo "Creating the directory \"$WORKSPACE\"" 
  mkdir -p $WORKSPACE

#If workspace has not already been initialised, do it now
if [ ! -d "$DEVELOPAREA" ]; then
  echo "" 
  echo "Creating a new workspace in \"$WORKSPACE\"" 
  setup gm2 $VERSION -q $FLAG     #Define g-2 software version
  mrb newDev                      #Create a new workspace

#Setup workspace environment
echo "" 
echo "Setup workspace" 
source localProducts_gm2_${VERSION}_prof/setup    #Setup mrb for this workspace
source mrb setEnv                                 #Set build environment for this workspace

#Create offline data directory if required
if [ ! -d "$OFFLINE_DATA_DIR" ]; then
  echo "" 
  echo "Creating the directory \"$OFFLINE_DATA_DIR\"" 
  mkdir -p $OFFLINE_DATA_DIR

echo "" 
echo "Setup complete!" 
echo "Workspace: $WORKSPACE" 
echo "Offline data directory: $OFFLINE_DATA_DIR" 
echo "" 

# Define some useful commands

#Function to clone all required repositories and the correct features
function git_clone_all () {



  mrb g -b feature/strawTrackReconstruction gm2geom

  mrb g -b feature/strawTrackReconstruction gm2dataproducts

  mrb g -b feature/CoordSystemService gm2ringsim

  mrb g -b feature/strawTrackReconstruction gm2tracker

  mrb g -b feature/strawTrackReconstruction gm2util

  cd $CURR_DIR


Get the code

Follow these steps ( refers to the file above). It will create a workspace for you if this is the first time the script has been run.

You will need a valid kerberos principal.

mrb uc

Build the code

The first time you build the code, follow these steps:

. mrb s
mrb b --generator ninja

If ". mrb s" reports any errors, the build won't work. Address these errors first.

For subsequent builds (unless files have been added/removed), you can use the following (faster):


Running the code

Follow these steps to process the data and make plots.

cd $MRB_SOURCE/gm2tracker/fcl
gm2 -c ./simpleExamplePlots.fcl -s <root file>

where <root file> is the art ROOT file you are using as a source (for example the one attached to this page).

simpleExamplePlots.fcl runs the analyzer module on the input digit collection, and creates a ROOT file with plots in called

Adding your own plots

The module doing the plotting is gm2tracker/analyses/ This gives examples of booking and filling histograms, so you can add to this if desired.