#!/bin/bash
if [ "$#" = "0" ]; then
echo "Type 'trigger help' for help";
fi
if [ "$1" = "help" ]; then
if [ "$#" = "1" ]; then
echo "This is help for script trigger. It allows to control all trigger-related options";
echo "Type trigger help for more information";
echo "";
echo "Usage: trigger ";
echo "";
echo "";
echo "Option Description";
echo "";
echo "s Select a Trigger";
echo "t Change timing of Triggers";
echo "info Display configuration of Triggerunit";
echo "reset Reset Trigger-Counter";
echo "stress Change trigger rates for stresstest";
echo "mask Select a Mask for Scintillators";
echo "ila Logic Analyzer";
echo "sng_pt Configure Single Pretrigger Sequence";
echo "sng_shot Start single shot sequence";
echo "sz_cnt Start/stop/reset Counter for Scintillators";
echo "flash Reprogramm FPGA from flash";
echo "help Show this";
echo "";
echo "If you found a bug or have further questions, please contact j.anielski@uni-muenster.de";
echo "";
else
if [ "$#" = "2" ]; then
case $2 in
s)
echo "";
echo "Select trigger with: trigger s <#> or trigger s ";
echo "";
echo "";
echo "# Name Description"
echo "";
echo "0 coinc Coincidence";
echo "1 noise Noise";
echo "2 btm_gtu BTM szin. + GTU decision (4 Tracklets in one Stack)";
echo "3 off Off";
echo "4 sng_pt_seq Issues a sequence of Pretriggers";
echo "5 stress_gtu_busy Stresstest with GTU busy -use 21 for normal stresstest-";
echo "9 coinc_btmgtu Combines coinc and btm_gtu";
echo "21 stress Stresstest";
echo "48 coinc_sng Issues one coincidence trigger sequence: PT,L0,L1" ;
echo "49 noise_sng Issues one noise trigger sequence: PT,L0,L1";
echo "50 btm_gtu_sng Isues one BTM+GTU trigger sequence: PT,L0,L1";
echo "214 fnoise Fastnoise - No GTUbusy and No L0,L1";
echo "";
echo "";
echo "Special Bits - Add to <#> to activate Trigger <#> with ";
echo "Example: 1 + 16 = noise without GTU busy --> trigger s 17";
echo "";
echo "Bit Description";
echo " 16 Ignore GTU busy signal";
echo " 32 Single Shot";
echo " 64 No L0 in trigger sequence";
echo "128 No L1 in trigger sequence";
echo "256 Overwrite L1 decision internally";
echo "512 Enable Readout Delay for Triggers that care for GTU busy";
echo "";;
t)
echo "";
echo "Available Options - Usage: trigger t ";
echo "Entered Values are interpreted as number of LHC-CLK-cycles";
echo "";
echo "";
echo "Option Description";
echo "";
echo "l0 Delay between pretrigger and Level 0";
echo "l1 Delay between pretrigger and Level 1";
echo "read Delay between pretrigger and readout finished";
echo " Only important for Stresstest or if GTU-busy is broken";
echo "clear Time between L0R,L1R or readout and next possible pretrigger" ;
echo "reset Reset all timinigs to default";
echo "";;
stress)
echo "";
echo "Usage: trigger stress ";
echo "By changing e.g. l1l0 you change L0 and PT rate as well.";
echo "That is due to more dead time caused by L1A";
echo "";
echo "";
echo "Option Description";
echo "";
echo "freq Frequency for Pretriggers";
echo " Value is no. of LHC-CLK-cycles between to pulses";
echo "ptfreq Ratio of actual PT to possible PT (frequency)";
echo " Enter in percent";
echo "l0pt Ratio of L0 to PT - Enter in percent";
echo "l1l0 Ratio of L1 to L0 - Enter in percent";
echo "";;
ila)
echo "";
echo "Internal Logic Analyzer - Usage: trigger ila ";
echo "";
echo "";
echo "Option Description";
echo "";
echo "read Read content of RAM and display in Bash"
echo "ana Read content of RAM and display ROOT-Plot"
echo "arm Arm Selected Trigger";
echo "trg_mask Select Trigger - Type trigger help ila trg_mask for more info";
echo "info Display Info";
echo "mode Select Pre or Post Mode - Enter pre or post";
echo " Pre: writing to RAM is stopped immediately with trigger";
echo " Post: RAM is written for another 1023 - presamples Clk-cycles";
echo "presamples Select amount of Presamples";
echo "";;
sng_shot)
echo "";
echo "This will start single shot sequence for selected trigger";
echo "";
echo "Trigger is stopped when one L1A is issued, except you choose Single PT.";
echo "";
echo "To have exactly one PT, one L0A and one L1A";
echo "make sure that ppc is active in GTU contrib mask.";
echo "";
echo "Otherwise PT,L0A will be issued until reception";
echo "of an L1ctb from GTU.";
echo "";;
mask)
echo "";
echo "You can select a mask for the scintillators";
echo "Type trigger mask ";
echo "Value is sum of all scintillator-groups you wish to be active";
echo "To activate all groups 'type trigger mask reset'";
echo "";
echo "SC-group T1 T2 T3 T4 B1 B2 B3 B4 B5";
echo "Value 1 2 4 8 16 32 64 128 256";
echo "";;
sng_pt)
echo "";
echo "To start sequence use 'trigger sng_shot'"
echo "You can configure Single Pretrigger Sequence as follows";
echo "";
echo "Option Description";
echo "amount Amount of Pretriggers you wish to issue";
echo "time Time between two Pretriggers";
echo "";;
sz_cnt)
echo "";
echo "Control Counters for Szintillators: trigger sz_cnt ";
echo "";
echo "Option Effect";
echo "start Starts Counters";
echo "stop Stops Counters";
echo "reset Reset Counters";
echo "";;
esac
else
if [ "$#" = "3" ]; then
if [ "$2" = "ila" ]; then
if [ "$3" = "trg_mask" ]; then
echo "To select more than one Trigger, add numbers of corresponding triggers";
echo "";
echo " Description";
echo "1 Manual Trigger";
echo "2 Pretrigger";
echo "4 Different Signals for GTU and SM";
echo "8 Level 1 Accept";
echo "16 Coincidence";
echo "32 Level 1 contribution from GTU";
echo "64 Falling edge GTU-busy";
echo "128 Level 0";
echo "256 Lower Scintillator area active";
echo "512 Rising edge GTU-busy";
echo "1024 Noise stopped because SZ active";
echo "2048 Falling edge GTU-busy in State Idle";
echo "4096 L1 overwritten";
echo "8192 SM output pulse longer than 25ns";
echo "";
echo "More Triggers can be implemented easily. Please refer to j.anielski@uni-muenster.de.";
echo "Or edit Trigger Vector ILA_TRG in VHDL Design yourself";
else
echo "Invalid Argument";
fi
else
echo "Invalid Argument";
fi
fi
fi
fi
fi
#reprogramm from flash
if [ "$1" = "flash" ]; then
ssh daq00 exec vme_write_d16 /tmp/sis1100_00remote 0x32108016 1;
fi
#info
if [ "$1" = "info" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command config;
sleep 1;
mv /home/trd/trigger/txt/trigger_config* ./;
fi
#reset counter
if [ "$1" = "reset" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command reset;
fi
#single shot
if [ "$1" = "sng_shot" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setsngshot;
fi
#timing state machine
if [ "$1" = "t" ]; then
if [ "$#" = "2" ]; then
if [ $2 = "reset" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl0delay=45;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl1delay=316;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setreaddelay=20000;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setcleardelay=120 ;
echo "All timings are set to default";
fi
fi
if [ "$#" = "3" ]; then
case $2 in
l0) echo "Pretrigger to Level 0 delay is set to $3";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl0delay=$3;;
l1) echo "Pretrigger to Level 1 delay is set to $3";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl1delay=$3;;
read) echo "Pretrigger to Readout finished delay is set to $3";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setreaddelay=$3;;
clear) echo "Clear delay is set to $3";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setcleardelay=$3;;
*) echo "$2 is not available";;
esac
fi
fi
#szintillator mask
if [ "$1" = "mask" ]; then
if [ "$#" = "2" ]; then
if [ "$2" = "reset" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setmask=511;
echo "Trigger mask is resetted. All groups active.";
else
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setmask=$2;
echo "You selected Mask: $2";
fi
else
echo "No. of arguments invalid";
fi
fi
#szintillator counter
if [ "$1" = "sz_cnt" ]; then
if [ "$#" = "2" ]; then
case $2 in
reset) /home/trd/dietel/pvss_mockup/dimcmd mstrg/command rst_sz_cnt;
echo "Counters for Szintillators have been resetted";;
stop) /home/trd/dietel/pvss_mockup/dimcmd mstrg/command dis_sz_cnt;
echo "Counters for Szintillators have been stopped";;
start) /home/trd/dietel/pvss_mockup/dimcmd mstrg/command ena_sz_cnt;
echo "Counters for Szintillators have been started";;
esac
else
echo "No. of arguments invalid";
fi
fi
#stresstest
if [ "$1" = "stress" ]; then
if [ "$#" = "2" ]; then
if [ "$2" = "reset" ]; then
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setfrequency=0;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setptfreqratio=50;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl0ptratio=50;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl1l0ratio=50;
echo "Frequency and Ratios have been set to default.";
fi
fi
if [ "$#" = "3" ]; then
case $2 in
freq) echo "Frequency is set";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setfrequency=$3;;
ptfreq) echo "Ratio of actual PT/possible PT is set to $3 %";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setptfreqratio=$3;;
l0pt) echo "Ratio of L0/PT is set to $3 %";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl0ptratio=$3;;
l1l0) echo "Ratio of L1/L0 is set to $3 %";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setl1l0ratio=$3;;
*) echo "Invalid argument";;
esac
fi
fi
#logic analyzer
if [ "$1" = "ila" ]; then
if [ "$#" = "2" ]; then
case $2 in
info) ssh daq00 exec '/home/trd/j_anie01/ila/ttcvi/mstrgd info';;
help) ssh daq00 exec '/home/trd/j_anie01/ila/ttcvi/mstrgd help';;
read) ssh daq00 exec '/home/trd/j_anie01/ila/ttcvi/mstrgd read';;
arm) ssh daq00 exec '/home/trd/j_anie01/ila/ttcvi/mstrgd arm';;
ana) ssh daq00 exec '/home/trd/j_anie01/ila/ttcvi/mstrgd ana' > /home/trd/trigger/dump;
root /home/trd/trigger/ila_root.C;;
*) echo "Invalid option";;
esac
else
if [ "$#" = "3" ]; then
case $2 in
presamples) ssh daq00 exec /home/trd/j_anie01/ila/ttcvi/mstrgd presamples $3;;
mode) ssh daq00 exec /home/trd/j_anie01/ila/ttcvi/mstrgd mode $3;;
trg_mask) ssh daq00 exec /home/trd/j_anie01/ila/ttcvi/mstrgd trg_mask $3;;
*) echo "Invalid option";;
esac
else
echo "Invalid number of arguments";
fi
fi
fi
#single pretrigger sequence
if [ "$1" = "sng_pt" ]; then
if [ "$#" = "3" ]; then
case $2 in
amount) echo "You selected $3 Pretriggers";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setptamount=$3;;
time) echo "Time between two Pretriggers is set to $3";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command setpttime=$3;;
*) echo "Invalid argument";;
esac
else
echo "Invalid No. of arguments";
fi
fi
#pretrigger source
if [ "$1" = "s" ]; then
if [ "$#" = "2" ]; then
echo Trigger selected is: ;
case $2 in
0) echo "COINCIDENCE" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
coinc) echo "COINCIDENCE" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
1) echo "NOISE ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
noise) echo "NOISE ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
2) echo "BOTTOM + GTU decision -4 tracklets in one stack-" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
btm_gtu) echo "BOTTOM + GTU decision -4 tracklets in one stack-" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
3) echo "OFF" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
off) echo "OFF" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
4) echo "SINGLE PRETRIGGER SEQUENCE" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
sng_pt_seq) echo "SINGLE PRETRIGGER SEQUENCE" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
5) echo "STRESSTEST with GTU busy -use 21 for normal stresstest-";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
stress_gtu_busy) echo "STRESSTEST with GTU busy -use 21 for normal stresstest-";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
9) echo "COINC+BTM_GTU" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
coinc_btmgtu) echo "COINC+BTM_GTU" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
21) echo "STRESSTEST" ;
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
stress) echo "STRESSTEST";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
48) echo "COINCIDENCE - SINGLE SHOT -issues one coincidence trigger sequence PT,L0,L1- ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
coinc_sng) echo "COINCIDENCE - SINGLE SHOT -issues one coincidence trigger sequence PT,L0,L1- ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
49) echo "NOISE - SINGLE SHOT -issues one noise trigger sequence PT,L0,L1- ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
noise_sng) echo "NOISE - SINGLE SHOT -issues one noise trigger sequence PT,L0,L1- ";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
50) echo "BOTTOM + GTU decision - SINGLE SHOT -issues one BTM+GTU trigger sequence PT,L0,L1-";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
btm_gtu_sng) echo "BOTTOM + GTU decision - SINGLE SHOT -issues one BTM+GTU trigger sequence PT,L0,L1-";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
214) echo "FASTNOISE - GTU_BUSY_IGNORE-NO-L0-NO_L1 -"
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;;
fnoise) echo "FASTNOISE - GTU_BUSY_IGNORE-NO-L0-NO_L1 -"
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command $2;;
*) echo "WARNING: INVALID ARGUMENT - WRITTEN ANYWAY";
/home/trd/dietel/pvss_mockup/dimcmd mstrg/command mode=$2;
echo "";
echo "Select trigger with: trigger s <#> or trigger s ";
echo "";
echo "";
echo "# Name Description"
echo "";
echo "0 coinc Coincidence";
echo "1 noise Noise";
echo "2 btm_gtu BTM szin. + GTU decision (4 Tracklets in one Stack)";
echo "3 off Off";
echo "4 sng_pt_seq Issues a sequence of Pretriggers";
echo "5 stress_gtu_busy Stresstest with GTU busy -use 21 for normal stresstest-";
echo "9 coinc_btmgtu Combines coinc and btm_gtu";
echo "21 stress Stresstest";
echo "48 coinc_sng Issues one coincidence trigger sequence: PT,L0,L1" ;
echo "49 noise_sng Issues one noise trigger sequence: PT,L0,L1";
echo "50 btm_gtu_sng Isues one BTM+GTU trigger sequence: PT,L0,L1";
echo "214 fnoise Fastnoise - No GTUbusy and No L0,L1";
echo "";
echo "";
echo "Special Bits - Add to <#> to activate Trigger <#> with ";
echo "Example: 1 + 16 = noise without GTU busy --> trigger s 17";
echo "";
echo "Bit Description";
echo " 16 Ignore GTU busy signal";
echo " 32 Single Shot";
echo " 64 No L0 in trigger sequence";
echo "128 No L1 in trigger sequence";
echo "256 Overwrite L1 decision internally";
echo "512 Enable Readout Delay for Triggers that care for GTU busy";
echo "";;
esac
else
echo "No Value given";
fi
fi