Tracker Tier 0


The tracker tier 0 code processes the STRW MIDAS bank from the StrawTrackerDAQ frontend and produces straw digits. These digits are now ready for the readout/reconsutruction stages (see here).

If you only want to look at straw hits (digits) and have been provided a file that has already been through tier 0 processing, see here instead.


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 paths to match your system, e.g.

  • OFFLINE_DIR - path to your offline area (your workspace will be created within this directory)
  • GM2MIDAS_DIR - path to your gm2midas installation
  • MIDAS_ONLINE_DATA - path to directory MIDAS data is in
# Setup script for g-2 offline software

#Define basic info
OFFLINE_DIR=/home/nfs/stuttard/merge                            #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

#MIDAS (create UPS product stub)
product-stub gm2midas v0_00_01 $GM2MIDAS_DIR $MRB_INSTALL
export MIDAS_ONLINE_DATA=/home/nfs/gm2/lab3TestStand/online/gm2trackerdaq/midas/online/data #MIDAS data directory

echo "" 
echo "Setup complete!" 
echo "Workspace: $WORKSPACE" 
echo "MIDAS data directory: $MIDAS_ONLINE_DATA" 
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/tier0v7 gm2midastoart

  mrb g -b feature/tier0v7 gm2unpackers

  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

  mrb g -b develop gm2trackerdaq

  cd $CURR_DIR


#Function to pull all required repositories
function git_pull_all () {


  cd $MRB_SOURCE/gm2midastoart
  git pull origin feature/tier0v7

  cd $MRB_SOURCE/gm2unpackers
  git pull origin feature/tier0v7

  cd $MRB_SOURCE/gm2geom
  git pull origin feature/strawTrackReconstruction

  cd $MRB_SOURCE/gm2dataproducts
  git pull origin feature/strawTrackReconstruction

  cd $MRB_SOURCE/gm2ringsim
  git pull origin feature/CoordSystemService

  cd $MRB_SOURCE/gm2tracker
  git pull origin feature/strawTrackReconstruction

  cd $MRB_SOURCE/gm2util
  git pull origin feature/strawTrackReconstruction

  cd $MRB_SOURCE/gm2trackerdaq
  git pull origin develop

  cd $CURR_DIR


#Check git status of everything
function git_status_all(){

  for dir in `ls | grep gm2`; do cd $dir; echo $dir; git status; echo ""; cd $MRB_SOURCE; done
  cd $tmpdir


#Check git branch of everything
function git_branch_all(){

  for dir in `ls | grep gm2`; do cd $dir; echo $dir; git branch; echo ""; cd $MRB_SOURCE; done
  cd $tmpdir


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


There are 3 stages of data processing:
  • Unpacking - gm2unpackers/fcl/StrawUnpacker.fcl
    • Produces: StrawUnpacker.root, StrawUnpackerSummary.root
  • Readout - gm2tracker/fcl/StrawReadout.fcl
    • Produces: StrawReadout.root, StrawReadoutSummary.root
  • Reco - gm2tracker/fcl/StrawReco.fcl
    • Produces: StrawReco.root, StrawRecoSummary.root

Each stage produces an output art ROOT file containing data products, as well as a second ROOT file containing summary plots.

Helper scripts

A script for processing runs called gm2tracker/fcl/ is available. Tell this what fcl files to run and what run numbers to run on. Run as:

python $MRB_SOURCE/gm2tracker/fcl/ -c <list of fcl fils to run (in order)> -r <list of run numbers> (-n <num events>) 

This assumes the following environment variables are set (they are by the script provided above):

  • MIDAS_ONLINE_DATA - Directory MIDAS files are written to
  • OFFLINE_DATA_DIR - Directory to write offline data files to

Alternatively can specify input, output and MIDAS data directories using the -i, -o and -m args respectively.

A few useful examples:

Unpack run 1:

python $MRB_SOURCE/gm2tracker/fcl/ -c $MRB_SOURCE/gm2unpackers/fcl/StrawUnpacker.fcl -r 1

Run all stages in unpacking, readout and reco chain for runs 10 and 15, and also all plotters:

python $MRB_SOURCE/gm2tracker/fcl/ -c $MRB_SOURCE/gm2unpackers/fcl/StrawUnpacker.fcl $MRB_SOURCE/gm2unpackers/fcl/StrawUnpackerPlots.fcl $MRB_SOURCE/gm2tracker/fcl/StrawReadout.fcl $MRB_SOURCE/gm2tracker/fcl/StrawReadoutPlots.fcl $MRB_SOURCE/gm2tracker/fcl/StrawReco.fcl $MRB_SOURCE/gm2tracker/fcl/StrawRecoPlots.fcl -r 10 15