#!/bin/sh esc=`echo -en "\033"` # Set colors cc_red="${esc}[0;31m" usage () { exe=`basename $0` #get the name of this executable echo -e "NAME" echo -e " $exe - Read EPICS Events and Plot Everything in ROOT" echo -e echo -e "SYNOPSIS" echo -e " $exe [OPTION]... [PV]...[formula].... \e[1;35m\\\\\mode 1\e[0m" echo -e " $exe [ROOT OPTIONS]...[file1.C ... fileN.C] \e[1;35m\\\\\mode 2\e[0m" echo -e echo -e "DESCRIPTION" echo -e echo -e " $exe [OPTION]... [PV]... \e[1;35m\\\\\mode 1\e[0m" echo -e echo -e " In this mode, make ROOT graphs by reading EPICS values periodically and plots graphs of all PVs against time." echo -e " If -x or -w option is specified, additional graphs of all PVs against the 1st PV in the list are made" echo -e " If more that one graph exists for any given x-axis, then a multigraph with all graphs using that x-axis is also created" echo -e " See EXAMPLES 1, below." echo -e echo -e " -t period" echo -e " set the period (ie time(s)) between reads. Default = 2s" echo -e echo -e " -x" echo -e " make graphs of all PVs against the 1st in the list" echo -e echo -e " -w start,stop,step" echo -e " As -x, but additionally, write to the 1st of the listed PVs to do a scan. Must be 3 comma separated values." echo -e " After each time period the next value will be written to the PV" echo -e echo -e " -W start,stop,step" echo -e " As above, but doesn't show the GUI and automatically saves the data and exits" echo -e echo -e " -T" echo -e " Force creation of additional Time Graphs when option -x or -w is chosen." echo -e echo -e " -n points" echo -e " Set no of points in the scan (not valid if -w or -W option is slected)" echo -e echo -e " -N points" echo -e " As above, but doesn't show the GUI and automatically saves all the data and exits" echo -e echo -e " -g 0/1" echo -e " Don't show, or show the GUI - this flag needs to come after -W or -n points. Default = 1" echo -e echo -e " -m" echo -e " Draw multigraphs in addition to basic graphs (ie superimposed on a single graph)" echo -e echo -e " -d outdir" echo -e " Select a directory for any output files. Default is ./epics_gr" echo -e echo -e " -l \"logbookcommand and args\" " echo -e " Use a script with arguments to send saved data to the logbook" echo -e echo -e " -s" echo -e " simulation mode. Runs a softIOC For testing" echo -e " The following PVs are available PV23004,colliX,PMT1,Fcup,Xsetting,Ysetting,BigScaler,BigScaler,AMO_SCALERS" echo -e " These are updated automatically in simulation mode" echo -e echo -e " -h" echo -e " print this help message" echo -e echo -e " -c maxcanv" echo -e " maximum number of graphs on a single canvas. Use maxcanv=1 for separate canvases." echo -e echo -e " [PV]" echo -e " EPICS PV which must be accessible with caget" echo -e echo -e " [PV--]" echo -e " As above, and the -- supresses automatic creation of graphs, and makes it available for formulae (see below)." echo -e echo -e " [PV::params] [PV##params]" echo -e " As above, with a fit and fit range(optional). For example:" echo -e " MyScalerRate::pol4 will fit 4th deg poly" echo -e " MyScalerRate##pol4,1.2,10.4 will fit 4th deg poly in the x-axis range 1.2 - 10.4" echo -e " If both PV0(Time) and PV1 graphs exist, use :: for PV0(Time) and ## for PV1" echo -e " Choosing a fit of L or C (no range needed) will join the points with a line(L) or curve(C)" echo -e echo -e " [formula]" echo -e " This is a ROOT TF1 expression, in quotes, where the numbers in the brackets refer to PV indices." echo -e " eg \"[1]/[2]\" \"TMath::Cos([1]/[2])\" " echo -e echo -e " $exe [ROOT OPTIONS]...[file1.C ... fileN.C] \e[1;35m\\\\\mode 2\e[0m" echo -e echo -e " In this mode call root with the reeper library loaded then set up customised behaviour in .C macros." echo -e " See EXAMPLES 2, below." echo -e echo -e echo -e "EXAMPLES 1" echo -e " Note. These examples use the -s flag, for simulated data. Try them" echo -e echo -e " $exe -s colliX PMT1 Fcup \e[1;35m \\\\\ graphs of PVs vs Time(PV0)\e[0m" echo -e " $exe -s -x colliX PMT1 Fcup \e[1;35m \\\\\ graphs of PVs vs colliX(PV1)\e[0m" echo -e " $exe -s -T -x colliX PMT1 Fcup \e[1;35m \\\\\ both sets of graphs (Time and colliX) \e[0m" echo -e " $exe -s -T -w -2.0,2.0,0.1 colliX PMT1 Fcup \e[1;35m \\\\\ as above, and scans colliX: -2.0->2.0 step=0.1 \e[0m" echo -e " $exe -s -w -2.0,2.0,0.1 colliX PMT1::gaus \e[1;35m\\\\\ as above, and fits gaus to both PMT1\e[0m" echo -e " $exe -s -w -2.0,2.0,0.1 colliX PMT1::gaus,-1.0,1.0 \e[1;35m\\\\\ as above with restricted fit range\e[0m" echo -e " $exe -s -x colliX PMT1-- Fcup-- \"[2]/[3]\" \e[1;35m\\\\\ exclude PMT,Fcup from graphs, but make graph of ratio\e[0m" echo -e echo -e echo -e "EXAMPLES 2" echo -e " Note. These examples use root macros to do EPICS PV plotting. All use simulated PVs in a softIOC." echo -e " The macros are templates to show how to use the GrimReeper features. Copy and hack." echo -e echo -e " $exe -l $REEPER/grBasic.C \e[1;35m \\\\\ Sets up a simple scan and plots one PV against another\e[0m" echo -e " $exe -l $REEPER/grScanFancy.C \e[1;35m \\\\\ Shows how to do a 2d scan, fill 2d histograms and read waveforms.\e[0m" echo -e echo -e echo -e "AUTHOR" echo -e " Written by Ken Livingston" echo -e echo -e "SEE ALSO" echo -e " $exe is part of the (GRIM)REEPER package. (GRIM)REEPER Implements Macros to Read EPICS Events and Plot Everything in ROOT" echo -e " Full documentation at " echo -e echo -e " June 2017" exit } #some defaults FORCETIME="0" SIM="0" PERIOD="1" GUI="1" SCAN="\"\"" LOGCOM="\"\"" OUTDIR="\"\"" SAVEANDEXIT="0" NPOINTS="0" PERCANVAS="4" MAKEMULTI="0" #check the no of args if [ "$#" -lt 1 ] then usage fi #check if there's a .C file, then pass all args to root, but insert the loader macro before the users .C file if [ -n "$(echo $@ | grep '\.C')" ]; then rootargs=`echo $@ | awk '{for(n=1;n<=NF;n++){if((l==0)&&($n~".C")){printf"%s/grLoad.C ",ENVIRON["REEPER"];l=1}printf"%s ",$n}}'` #echo "root $rootargs"; root $rootargs #otherwise process the args to construct root args to call the genReeper.C macro else while getopts ":Tsxml:d:t:g:w:W:n:N:c:h" opt; do case $opt in T ) FORCETIME="1" ;; s ) SIM="1" ;; m ) MAKEMULTI="1" ;; l ) LOGCOM="\"$OPTARG\"" ;; d ) OUTDIR="\"$OPTARG\"" ;; g ) GUI="$OPTARG";; x ) SCAN="\"1\"" ;; t ) PERIOD="$OPTARG" ;; c ) PERCANVAS="$OPTARG" ;; w ) SCAN="\"$OPTARG\"";; W ) SCAN="\"$OPTARG\"" GUI="0" SAVEANDEXIT="1" ;; n ) NPOINTS="$OPTARG";; N ) NPOINTS="$OPTARG" GUI="0" SAVEANDEXIT="1" ;; h ) usage ;; \?) usage ;; esac done shift $(($OPTIND - 1)) macroargs="$#,\"$@\",$PERIOD,$SIM,$GUI,$FORCETIME,$NPOINTS,$SAVEANDEXIT,$SCAN,$OUTDIR,$PERCANVAS,$MAKEMULTI,$LOGCOM" #echo "root $rootargs"; # echo "root -l ${REEPER}/grLoad.C \"${REEPER}/genReeper.C($macroargs)\"" root -l ${REEPER}/grLoad.C "${REEPER}/genReeper.C($macroargs)" fi exit