Back to home page

EIC code displayed by LXR

 
 

    


Warning, /epic/scripts/view12/generate_eps is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env bash
0002 
0003 #trignometry
0004 sin ()
0005 {
0006     echo "scale=5;s($1)" | bc -l
0007 }
0008 
0009 cos ()
0010 {
0011     echo "scale=5;c($1)" | bc -l
0012 }
0013 
0014 tan ()
0015 {
0016     echo "scale=5;s($1)/c($1)" | bc -l
0017 }
0018 
0019 
0020 function print_the_help {
0021   echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
0022   echo "  OPTIONS: "
0023   echo "            -t,--tag           filename tag (default: view1)"
0024   exit
0025 }
0026 
0027 FILE_TAG="view12"
0028 INPUT_FILE="../../g4_0000.prim"
0029 
0030 
0031 POSITIONAL=()
0032 while [[ $# -gt 0 ]]
0033 do
0034   key="$1"
0035 
0036   case $key in
0037     -h|--help)
0038       shift # past argument
0039       print_the_help
0040       ;;
0041     -t|--tag)
0042       FILE_TAG="$2"
0043       shift # past argument
0044       shift # past value
0045       ;;
0046     -i|--input)
0047       INPUT_FILE="$2"
0048       shift # past argument
0049       shift # past value
0050       ;;
0051     -[a-zA-Z]*) # unknown option
0052       POSITIONAL+=("$1") # save it in an array for later
0053       echo "unknown option $1"
0054       print_the_help
0055       shift # past argument
0056       ;;
0057     *)     # positional options
0058       POSITIONAL+=("$1") # save it in an array for later
0059       shift # past argument
0060       ;;
0061   esac
0062 done
0063 set -- "${POSITIONAL[@]}" # restore positional parameters
0064 
0065 # units are mm
0066 
0067 echo "view12 produces a series of slightly rotated XY slices a different z locations. Along beamline"
0068 
0069 original_file_tag="${FILE_TAG}"
0070 
0071 make_slice(){
0072   local zpos="$1"
0073   local tagnum=$(printf "%04d" ${zpos})
0074   local FILE_TAG="${original_file_tag}a${tagnum}"
0075   dawncut 0 0 1 $(( 10 * ${zpos} + 1 )) ${INPUT_FILE} ${FILE_TAG}_temp0.prim
0076   dawncut 0 0 -1 $(( -10 * ${zpos} )) ${FILE_TAG}_temp0.prim  ${FILE_TAG}.prim
0077   dawn -d ${FILE_TAG}.prim
0078   ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_full.pdf
0079   gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
0080     -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0081     -f ${FILE_TAG}_full.pdf
0082       pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox
0083   rm "${FILE_TAG}_temp0.prim"
0084   rm "${FILE_TAG}.prim"
0085 }
0086 
0087 for zzz in $@ ;
0088 do
0089   make_slice ${zzz}
0090 done
0091 
0092 wait
0093 
0094 
0095 
0096 #dawncut 0  1 0 10 ${INPUT_FILE} ${FILE_TAG}c_temp0.prim
0097 #dawncut 0 -1 0 0 ${FILE_TAG}c_temp0.prim  ${FILE_TAG}c.prim
0098 #dawn -d ${FILE_TAG}c.prim
0099 #ps2pdf ${FILE_TAG}c.eps ${FILE_TAG}c_full.pdf
0100 #gs -o ${FILE_TAG}c.pdf -sDEVICE=pdfwrite \
0101 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0102 #  -f ${FILE_TAG}c_full.pdf
0103 #pdftoppm ${FILE_TAG}c.pdf ${FILE_TAG}c -png -singlefile -cropbox
0104 #
0105 ## slice at z = -1m
0106 #dawncut 0 0 1 -1000 ${INPUT_FILE} ${FILE_TAG}d_temp0.prim
0107 #dawncut 0 0 -1 1001 ${FILE_TAG}d_temp0.prim  ${FILE_TAG}d.prim
0108 #dawn -d ${FILE_TAG}d.prim
0109 #ps2pdf ${FILE_TAG}d.eps ${FILE_TAG}d_full.pdf
0110 #gs -o ${FILE_TAG}d.pdf -sDEVICE=pdfwrite \
0111 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0112 #  -f ${FILE_TAG}d_full.pdf
0113 #pdftoppm ${FILE_TAG}d.pdf ${FILE_TAG}d -png -singlefile -cropbox
0114 #
0115 ## slice at z = -2m
0116 #dawncut 0 0 1 -2000 ${INPUT_FILE} ${FILE_TAG}e_temp0.prim
0117 #dawncut 0 0 -1 2001 ${FILE_TAG}e_temp0.prim  ${FILE_TAG}e.prim
0118 #dawn -d ${FILE_TAG}e.prim
0119 #ps2pdf ${FILE_TAG}e.eps ${FILE_TAG}e_full.pdf
0120 #gs -o ${FILE_TAG}e.pdf -sDEVICE=pdfwrite \
0121 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0122 #  -f ${FILE_TAG}e_full.pdf
0123 #pdftoppm ${FILE_TAG}e.pdf ${FILE_TAG}e -png -singlefile -cropbox
0124 
0125 
0126 #https://geant4.kek.jp/~tanaka/DAWN/About_DAWNCUT.html
0127 # % dawncut a b c d input-file [output-file]
0128 #
0129 #       input-file : Source DAWN-format file describing a 3D scene.
0130 #
0131 #       output-file: Output DAWN-format file describing a plane-clipped
0132 #                    3D scene.  The default output stream is stdout.
0133 #
0134 #       a, b, c, d : Parameters  a, b, c, and d  are double values to
0135 #                    define a clipping plane described with the following
0136 #                    equation:
0137 #
0138 #                       ax + by + cz + d = 0.
0139 #
0140 #                    Vector (a,b,c) defines the normal vector of
0141 #                    the clipping plane.
0142 #                    3D scene data in the half space at the front side
0143 #                    of the clipping plane are clipped out and erased.
0144 #                    The normal vector (a,b,c) needs not be a unit vector.
0145 #                    If it is a unit vector, parameter "d" gives distance
0146 #                    between the clipping plane and origin (0,0,0).