* * Draw detector groups for PrimEx trigger logic. * * This assumes a geometry with 1661 detectors total * MACRO draw_groups opt zfl1 opt tic set plci null -60 60 -60 60 * Text color index 0=white 1=black set txci 1 for/file 44 draw_groups.ps metafile 44 -111 * fais 2=filled 0=outline only set fais 2 exec draw_grid 0 set fais 0 exec draw_grid 1 close 44 RETURN MACRO draw_grid draw_labels do x=0,33 do y=0,33 if ([x].lt.16..OR.[x].gt.17..OR.[y].lt.16..OR.[y].gt.17.) then exec draw_xtal [x] [y] [draw_labels] endif enddo enddo do x=0,29 do y=0,29 if ([x].lt.6..OR.[x].gt.23..OR.[y].lt.6..OR.[y].gt.23.) then exec draw_glass [x] [y] [draw_labels] endif enddo enddo RETURN MACRO draw_xtal x y draw_labels width = $EVAL(2.05+0.03) c=1 if [x].ge.0..and.[x].lt.6..and.[y].ge.0..and.[y].lt.6. then; c=3; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.0..and.[y].lt.6. then; c=4; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.0..and.[y].lt.6. then; c=3; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.0..and.[y].lt.6. then; c=4; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.0..and.[y].lt.6. then; c=3; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.0..and.[y].lt.6. then; c=4; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.6..and.[y].lt.12. then; c=4; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.6..and.[y].lt.12. then; c=3; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.6..and.[y].lt.12. then; c=4; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.6..and.[y].lt.12. then; c=3; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.6..and.[y].lt.12. then; c=4; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.6..and.[y].lt.12. then; c=3; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.12..and.[y].lt.17. then; c=3; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.12..and.[y].lt.17. then; c=4; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.12..and.[y].lt.17. then; c=3; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.12..and.[y].lt.17. then; c=4; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.12..and.[y].lt.17. then; c=3; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.12..and.[y].lt.17. then; c=4; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.17..and.[y].lt.22. then; c=4; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.17..and.[y].lt.22. then; c=3; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.17..and.[y].lt.22. then; c=4; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.17..and.[y].lt.22. then; c=3; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.17..and.[y].lt.22. then; c=4; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.17..and.[y].lt.22. then; c=3; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.22..and.[y].lt.28. then; c=3; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.22..and.[y].lt.28. then; c=4; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.22..and.[y].lt.28. then; c=3; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.22..and.[y].lt.28. then; c=4; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.22..and.[y].lt.28. then; c=3; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.22..and.[y].lt.28. then; c=4; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.28..and.[y].lt.34. then; c=4; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.28..and.[y].lt.34. then; c=3; endif if [x].ge.12..and.[x].lt.17..and.[y].ge.28..and.[y].lt.34. then; c=4; endif if [x].ge.17..and.[x].lt.22..and.[y].ge.28..and.[y].lt.34. then; c=3; endif if [x].ge.22..and.[x].lt.28..and.[y].ge.28..and.[y].lt.34. then; c=4; endif if [x].ge.28..and.[x].lt.34..and.[y].ge.28..and.[y].lt.34. then; c=3; endif set faci [c] x1 = $EVAL(([x]-17.0)*[width]) x2 = $EVAL([x1]+[width]) y1 = $EVAL((16.0-[y])*[width]) y2 = $EVAL([y1]+[width]) box [x1] [x2] [y1] [y2] * Draw channel id if [draw_labels].eq.1 then exec xtal_id_from_xy [x] [y] igset txal 23 * text $EVAL(([x1]+[x2])/2.0) $EVAL(([y1]+[y2])/2.0) 'G'//[@] 0.2 text $EVAL([x1]+0.25) $EVAL([y1]+1.5) 'W' 0.05 text $EVAL([x1]+0.25) $EVAL([y1]+0.5) [@] 0.05 endif RETURN MACRO draw_glass x y draw_labels xtal_width = $EVAL(2.05+0.03) width = $EVAL(3.82+0.03) c=1 if [x].ge.0..and.[x].lt.6..and.[y].ge.0..and.[y].lt.6. then; c=2; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.0..and.[y].lt.6. then; c=6; endif if [x].ge.12..and.[x].lt.18..and.[y].ge.0..and.[y].lt.6. then; c=2; endif if [x].ge.18..and.[x].lt.24..and.[y].ge.0..and.[y].lt.6. then; c=6; endif if [x].ge.24..and.[x].lt.30..and.[y].ge.0..and.[y].lt.6. then; c=2; endif if [x].ge.24..and.[x].lt.30..and.[y].ge.6..and.[y].lt.12. then; c=6; endif if [x].ge.24..and.[x].lt.30..and.[y].ge.12..and.[y].lt.18. then; c=2; endif if [x].ge.24..and.[x].lt.30..and.[y].ge.18..and.[y].lt.24. then; c=6; endif if [x].ge.24..and.[x].lt.30..and.[y].ge.24..and.[y].lt.30. then; c=2; endif if [x].ge.18..and.[x].lt.24..and.[y].ge.24..and.[y].lt.30. then; c=6; endif if [x].ge.12..and.[x].lt.18..and.[y].ge.24..and.[y].lt.30. then; c=2; endif if [x].ge.6..and.[x].lt.12..and.[y].ge.24..and.[y].lt.30. then; c=6; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.24..and.[y].lt.30. then; c=2; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.18..and.[y].lt.24. then; c=6; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.12..and.[y].lt.18. then; c=2; endif if [x].ge.0..and.[x].lt.6..and.[y].ge.6..and.[y].lt.12. then; c=6; endif set faci [c] * Odd geometry correction nudge = $EVAL([xtal_width]*34.0 - [width]*18.0) x_nudge=0.0 y_nudge=0.0 if [x].lt.24..and.[y].lt.6. then; x_nudge=$EVAL([nudge]) ; endif if [x].ge.24..and.[y].lt.24. then; y_nudge=$EVAL(-[nudge]) ; x_nudge=$EVAL([nudge]) ; endif if [x].ge.6..and.[y].ge.24. then; y_nudge=$EVAL(-[nudge]) ; endif if [x].lt.6..and.[y].ge.6. then; x_nudge=0.0 ; endif x0 = $EVAL(-17.0*[xtal_width] - 6.0*[width]) y0 = $EVAL( 17.0*[xtal_width] + 6.0*[width]) x1 = $EVAL([x]*[width]+([x0])+([x_nudge])) x2 = $EVAL([x1]+[width]) y1 = $EVAL(([y0])-[y]*[width]+([y_nudge])) y2 = $EVAL([y1]-[width]) box [x1] [x2] [y1] [y2] * Draw channel id if [draw_labels].eq.1 then exec pbglass_id_from_xy [x] [y] igset txal 23 * text $EVAL(([x1]+[x2])/2.0) $EVAL(([y1]+[y2])/2.0) 'G'//[@] 0.2 text $EVAL([x1]+0.25) $EVAL([y2]+1) 'G'//[@] 0.1 endif RETURN * Return id of PbWO4 crystal given x,y in detector units. The units * of x and y are integers from 0 to 8 inclusive. The id values start * from 1. MACRO xtal_id_from_xy x y id = $SIGMA([y]*34+[x]+1) RETURN [id] * Return id of Pb-glass crystal given x,y in detector units. The units * of x and y are integers from 0 to 10 inclusive. The id values start * from 1. MACRO pbglass_id_from_xy x y id = $SIGMA([y]*30+[x]+1) RETURN [id]