Project

General

Profile

Tracker Tier 0

Overview

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.

Installation

Environment script

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

Use the example below and name it *setup.sh".

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/gm2.opensciencegrid.org/prod7/g-2/setup #Offsite
if [ ! -f "$OFFLINE_ENV_SCRIPT" ]; then
  echo ">>>ERROR<<< Offline environment script \"${OFFLINE_ENV_SCRIPT}\" does not exist" 
  return
fi
source $OFFLINE_ENV_SCRIPT

#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
fi

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

#Setup workspace environment
echo "" 
echo "Setup workspace" 
cd $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
fi

#MIDAS (create UPS product stub)
GM2MIDAS_DIR=/home/nfs/stuttard/online7/gm2midas
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

#Done
echo "" 
echo "Setup complete!" 
echo "Workspace: $WORKSPACE" 
echo "MIDAS : $GM2MIDAS_DIR" 
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 () {

  CURR_DIR=`pwd`

  cd $MRB_SOURCE

  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 () {

  CURR_DIR=`pwd`

  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(){

  tmpdir=`pwd`
  cd $MRB_SOURCE
  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(){

  tmpdir=`pwd`
  cd $MRB_SOURCE
  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 (setup.sh 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.

. setup.sh
git_clone_all
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):

makeninja

Running the code

Stages

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/ProcessRuns.py is available. Tell this what fcl files to run and what run numbers to run on. Run as:

python $MRB_SOURCE/gm2tracker/fcl/ProcessRuns.py -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 setup.sh 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/ProcessRuns.py -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/ProcessRuns.py -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