#!/bin/bash echo "test04: tracking mu+ through Aluminum (2 sec)" cat >test04.in <<-! param histoFile="" physics QGSP disable=Decay beam gaussian meanMomentum=400 particle=mu+ nEvents=1000 box Al height=200 width=200 length=200 material=Al place Al z=200 virtualdetector format=BLTrackFile AF radius=200 length=1 color=1,1,1 file=test04.txt place AF z=400 ! cat >test04.check <<-\! #!/usr/bin/tclsh # reads stdin, summing up columns $px and $py; # exits successfully if both mean and sigma are within # tolerance of the given values. # In any case, mean and sigma are written to stdout. set px 3 set py 4 set pid 7 set muplus -13 # units for mean, sigma, and tolerance are MeV/c #meanpx=0.277 sigmapx=18.7 meanpy=-1.66 sigmapy=19.6 entries=1000 set mean 0.0 set sigma 18.0 set tolerance 2.0 set input [split [read stdin] "\n"] set sumpx "0.0" set sumsqpx "0.0" set sumpy "0.0" set sumsqpy "0.0" set n 0 foreach line $input { if {[string index $line 0] == "#"} { continue } set fields [split $line " "] if {[lindex $fields $pid] != $muplus} { continue } set x [lindex $fields $px] set y [lindex $fields $py] if {"$x" == "" || "$y" == ""} { continue } set sumpx [expr $sumpx+$x] set sumsqpx [expr $sumsqpx+$x*$x] set sumpy [expr $sumpy+$y] set sumsqpy [expr $sumsqpy+$y*$y] set n [expr $n+1] } if {$n==0} { exit 99 } set tcl_precision 3 set mpx [expr $sumpx/$n] set spx [expr sqrt($sumsqpx/$n-$mpx*$mpx)] set mpy [expr $sumpy/$n] set spy [expr sqrt($sumsqpy/$n-$mpy*$mpy)] puts "meanpx=$mpx sigmapx=$spx meanpy=$mpy sigmapy=$spy entries=$n" if {[expr abs($mpx-$mean)<$tolerance && abs($mpy-$mean)<$tolerance && \ abs($spx-$sigma)<$tolerance && abs($spy-$sigma)<$tolerance]} \ { exit 0 } exit 1 ! chmod +x test04.check if ! g4bl test04.in >test04.out then echo "****** test04: g4bl FAILED! -- test04.* files left intact" exit 1 fi if ! ./test04.check test04.check.out then echo "****** test04: mean & sigma test FAILED -- test04.* files left intact" exit 1 fi # clean up and exit rm test04.* exit 0