Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 56 | f9daq | 1 | #!/usr/bin/wish |
| 2 | #!/bin/sh |
||
| 3 | # the next line restarts using wish \ |
||
| 4 | # exec wish "$0" ${1+"$@"} |
||
| 5 | |||
| 6 | |||
| 7 | #*************************************************************** |
||
| 8 | # loading BLT package |
||
| 9 | #*************************************************************** |
||
| 10 | lappend auto_path "/usr/lib/blt2.4" |
||
| 11 | if [ catch {package require BLT}] exit |
||
| 12 | if { $tcl_version >= 8.0 } { |
||
| 13 | catch {namespace import blt::*} |
||
| 14 | } else { |
||
| 15 | catch { import add blt } } |
||
| 16 | |||
| 17 | #*************************************************************** |
||
| 18 | # loading EVD package |
||
| 19 | #*************************************************************** |
||
| 20 | puts [ info nameofexecutable ] |
||
| 21 | puts [ info script ] |
||
| 22 | lappend auto_path [ file dirname [ info script ] ] |
||
| 23 | package require Evd |
||
| 24 | |||
| 25 | #*************************************************************** |
||
| 26 | # setting global variables (machine dependent) |
||
| 27 | #*************************************************************** |
||
| 28 | |||
| 29 | set dump_dir "." |
||
| 30 | set data_dir "./data" |
||
| 31 | set config_dir "./config/rich00A" |
||
| 32 | set qapmt_dir "./pmtdb" |
||
| 33 | |||
| 34 | |||
| 35 | # hiding main window |
||
| 36 | wm withdraw . |
||
| 37 | |||
| 38 | set new_scan 0 |
||
| 39 | set jmove 0 |
||
| 40 | set m4color "#80FF80" |
||
| 41 | set m16color "#FFBBBB" |
||
| 42 | set evcolor "#000000" |
||
| 43 | set evrescan 0 |
||
| 44 | set evnorm 1 |
||
| 45 | set evm4norm 0 |
||
| 46 | set evreverse 0 |
||
| 47 | set evhot 0 |
||
| 48 | set evmask 1 |
||
| 49 | set evmap 1 |
||
| 50 | set evprwin 0 |
||
| 51 | set sreset 1 |
||
| 52 | |||
| 53 | |||
| 54 | array set PSfontmap {"10x20" {"Helvetica-Bold" 12} |
||
| 55 | "6x12" {"Helvetica-Bold" 8}} |
||
| 56 | lappend paltags c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 |
||
| 57 | set ovftag c16 |
||
| 58 | set ovfcol "#FF0000" |
||
| 59 | lappend BWpal "#000000" "#111111" "#222222" "#333333" \ |
||
| 60 | "#444444" "#555555" "#666666" "#777777" \ |
||
| 61 | "#888888" "#999999" "#AAAAAA" "#BBBBBB" \ |
||
| 62 | "#CCCCCC" "#DDDDDD" "#EEEEEE" "#FFFFFF" |
||
| 63 | lappend BRpal "#0022FF" "#1122EE" "#2222DD" "#3322CC" \ |
||
| 64 | "#4422BB" "#5522AA" "#662299" "#772288" \ |
||
| 65 | "#882277" "#992266" "#AA2255" "#BB2244" \ |
||
| 66 | "#CC2233" "#DD2222" "#EE2211" "#FF2200" |
||
| 67 | |||
| 68 | #*** EVENT_DISPLAY window definitions |
||
| 69 | |||
| 70 | toplevel .ev |
||
| 71 | wm title .ev "RICH Event Display" |
||
| 72 | wm protocol .ev WM_DELETE_WINDOW " " |
||
| 73 | set evmag 2. |
||
| 74 | set oldevmag 2. |
||
| 75 | set tfont "10x20" |
||
| 76 | wm geometry .ev 1016x760+10+10 |
||
| 77 | |||
| 78 | |||
| 79 | #*** DETECTOR canvas definition |
||
| 80 | |||
| 81 | canvas .ev.det \ |
||
| 82 | -scrollregion "0 0 [expr $evmag*350] [expr $evmag*300]" \ |
||
| 83 | -background "#000080" \ |
||
| 84 | -cursor draft_small \ |
||
| 85 | -yscrollcommand { .ev.detvs set } \ |
||
| 86 | -xscrollcommand { .ev.deths set } |
||
| 87 | scrollbar .ev.detvs -orient vertical -command { .ev.det yview } |
||
| 88 | scrollbar .ev.deths -orient horizontal -command { .ev.det xview } |
||
| 89 | bind .ev.det <1> {set chout [open ch.dat a] |
||
| 90 | puts $chout [evstatl 0 \ |
||
| 91 | [.ev.det canvasx %x] [.ev.det canvasy %y] $evmag] |
||
| 92 | close $chout} |
||
| 93 | bind .ev.det <Motion> {.ev.mapping configure -text [evstatl 0 \ |
||
| 94 | [.ev.det canvasx %x] [.ev.det canvasy %y] $evmag]} |
||
| 95 | |||
| 96 | #*** GRAPH canvas definition |
||
| 97 | |||
| 98 | canvas .ev.gr \ |
||
| 99 | -background "#000000" \ |
||
| 100 | -yscrollcommand { .ev.grvs set } \ |
||
| 101 | -xscrollcommand { .ev.grhs set } |
||
| 102 | scrollbar .ev.grvs -orient vertical -command { .ev.gr yview } |
||
| 103 | scrollbar .ev.grhs -orient horizontal -command { .ev.gr xview } |
||
| 104 | set grm .ev.gr |
||
| 105 | |||
| 106 | #*** FED canvas definition |
||
| 107 | |||
| 108 | canvas .ev.fed \ |
||
| 109 | -scrollregion {0 0 280 738} \ |
||
| 110 | -background "#667788" \ |
||
| 111 | -cursor draft_small \ |
||
| 112 | -yscrollcommand { .ev.fedvs set } \ |
||
| 113 | -xscrollcommand { .ev.fedhs set } |
||
| 114 | |||
| 115 | scrollbar .ev.fedvs -orient vertical -command { .ev.fed yview } |
||
| 116 | scrollbar .ev.fedhs -orient horizontal -command { .ev.fed xview } |
||
| 117 | bind .ev.fed <Motion> {.ev.mapping configure -text [evstatl 1 \ |
||
| 118 | [.ev.fed canvasx %x] [.ev.fed canvasy %y] ]} |
||
| 119 | |||
| 120 | |||
| 121 | #*** VECTORS |
||
| 122 | |||
| 123 | vector create nhx(2000) |
||
| 124 | nhx seq 5. 19995. 10. |
||
| 125 | vector create nhy(2000) |
||
| 126 | set nhy(:) 0. |
||
| 127 | vector create nbxx(220) |
||
| 128 | nbxx seq 0.5 219.5 1. |
||
| 129 | vector create nbxy(220) |
||
| 130 | set nhy(:) 0. |
||
| 131 | vector create hbxy(220) |
||
| 132 | set hbxy(:) 0. |
||
| 133 | vector create ncox(101) |
||
| 134 | ncox seq 0.5 100.5 1. |
||
| 135 | vector create nco4y(101) |
||
| 136 | set nco4y(:) 0. |
||
| 137 | vector create nco16y(101) |
||
| 138 | set nco16y(:) 0. |
||
| 139 | vector create nrepx(100) |
||
| 140 | nrepx seq 0.5 99.5 1. |
||
| 141 | vector create nrepy(100) |
||
| 142 | set nrepy(:) 0. |
||
| 143 | vector create nrep64y(100) |
||
| 144 | set nrep64y(:) 0. |
||
| 145 | |||
| 146 | #*** BARCHARTS |
||
| 147 | |||
| 148 | option add *Barchart.legend.hide yes |
||
| 149 | option add *Barchart.tickfont -*-helvetica-medium-r-normal-*-8-* |
||
| 150 | option add *Barchart.Element.relief flat |
||
| 151 | option add *Barchart.Element.foreground "#808080" |
||
| 152 | |||
| 153 | barchart $grm.nh -rightmargin 10 -title "Hits per event" |
||
| 154 | $grm.nh element create nh1 -xdata nhx -ydata nhy |
||
| 155 | $grm.nh configure -barwidth 10. |
||
| 156 | $grm.nh axis configure x -stepsize 5000. |
||
| 157 | Blt_ZoomStack $grm.nh |
||
| 158 | Blt_Crosshairs $grm.nh |
||
| 159 | |||
| 160 | barchart $grm.nbx -rightmargin 10 -title "Events per bunch" |
||
| 161 | $grm.nbx element create nbx1 -xdata nbxx -ydata nbxy |
||
| 162 | $grm.nbx configure -barwidth 1. |
||
| 163 | $grm.nbx axis configure x -stepsize 20. |
||
| 164 | Blt_ZoomStack $grm.nbx |
||
| 165 | Blt_Crosshairs $grm.nbx |
||
| 166 | |||
| 167 | barchart $grm.hbx -rightmargin 10 -title "Average hits per bunch" |
||
| 168 | $grm.hbx element create hbx1 -xdata nbxx -ydata hbxy |
||
| 169 | $grm.hbx configure -barwidth 1. |
||
| 170 | $grm.hbx axis configure x -stepsize 20. |
||
| 171 | Blt_ZoomStack $grm.hbx |
||
| 172 | Blt_Crosshairs $grm.hbx |
||
| 173 | lappend hdata hbx1 |
||
| 174 | #array set hbxa { "n" [ nbxx length ] "x" "nbxx" "y" "hbxy" } |
||
| 175 | |||
| 176 | barchart $grm.nco -rightmargin 10 -title "Channel occupancy" |
||
| 177 | $grm.nco element create nco1 -xdata ncox -ydata nco4y -foreground $m4color |
||
| 178 | $grm.nco element create nco2 -xdata ncox -ydata nco16y -foreground $m16color |
||
| 179 | $grm.nco configure -barwidth 1. -barmode overlap |
||
| 180 | $grm.nco axis configure x -stepsize 10. |
||
| 181 | Blt_ZoomStack $grm.nco |
||
| 182 | Blt_Crosshairs $grm.nco |
||
| 183 | |||
| 184 | barchart $grm.nrep -rightmargin 10 -title "Repetition freq." |
||
| 185 | $grm.nrep element create nrep1 \ |
||
| 186 | -xdata nrepx -ydata nrepy -foreground "#a0a000" |
||
| 187 | $grm.nrep element create nrep2 \ |
||
| 188 | -xdata nrepx -ydata nrep64y -foreground "#00a0a0" |
||
| 189 | $grm.nrep configure -barwidth 1. -barmode overlap |
||
| 190 | $grm.nrep axis configure x -stepsize 10. |
||
| 191 | Blt_ZoomStack $grm.nrep |
||
| 192 | Blt_Crosshairs $grm.nrep |
||
| 193 | |||
| 194 | .ev.gr create window 2 1 -window $grm.nh -width 276 -height 198 -anchor nw |
||
| 195 | .ev.gr create window 2 201 -window $grm.nbx -width 276 -height 198 -anchor nw |
||
| 196 | .ev.gr create window 2 401 -window $grm.hbx -width 276 -height 198 -anchor nw |
||
| 197 | .ev.gr create window 2 601 -window $grm.nco -width 276 -height 198 -anchor nw |
||
| 198 | .ev.gr create window 2 801 -window $grm.nrep -width 276 -height 198 -anchor nw |
||
| 199 | .ev.gr configure -scrollregion {0 0 280 1000} |
||
| 200 | |||
| 201 | |||
| 202 | #MENUBAR definitions |
||
| 203 | |||
| 204 | menu .ev.mb -type menubar -font $tfont -relief raised |
||
| 205 | |||
| 206 | menu .ev.mb.f -font $tfont |
||
| 207 | .ev.mb.f add command -label "Open" -command { set sreset 1 ; evopenp } \ |
||
| 208 | -underline 0 |
||
| 209 | lappend open_disable ".ev.mb.f entryconfigure Open" |
||
| 210 | .ev.mb.f add command -label "Append" -command { set sreset 0 ; evopenp } \ |
||
| 211 | -underline 0 |
||
| 212 | lappend open_disable ".ev.mb.f entryconfigure Append" |
||
| 213 | .ev.mb.f add command -label "Close" -command { evclosep 0 } \ |
||
| 214 | -underline 0 -state disabled |
||
| 215 | lappend open_enable ".ev.mb.f entryconfigure Close" |
||
| 216 | .ev.mb.f add command -label "CloseGzip" -command { evclosep 1 } \ |
||
| 217 | -underline 5 -state disabled |
||
| 218 | lappend open_enable ".ev.mb.f entryconfigure CloseGzip" |
||
| 219 | .ev.mb.f add separator |
||
| 220 | .ev.mb.f add command -label "Print" -underline 0 \ |
||
| 221 | -command { if { $evprwin } { |
||
| 222 | .ev.det postscript -file det.ps -pagewidth 17c -fontmap PSfontmap |
||
| 223 | } else { |
||
| 224 | .ev.det postscript -file det.ps -rotate 1 -x 0 -y 0 -pagewidth 25c \ |
||
| 225 | -width [expr $evmag*350] \ |
||
| 226 | -height [expr $evmag*300] -fontmap PSfontmap } } |
||
| 227 | .ev.mb.f add separator |
||
| 228 | .ev.mb.f add command -label "Exit" -command { evexit } -underline 0 |
||
| 229 | |||
| 230 | menu .ev.mb.t -font $tfont |
||
| 231 | .ev.mb.t add command -label "Scan" -command evscanp -underline 0 \ |
||
| 232 | -state disabled |
||
| 233 | lappend open_enable ".ev.mb.t entryconfigure Scan" |
||
| 234 | .ev.mb.t add command -label "Dump" -command evdumpp -underline 0 \ |
||
| 235 | -state disabled |
||
| 236 | lappend open_enable ".ev.mb.t entryconfigure Dump" |
||
| 237 | menu .ev.mb.t.h -font $tfont |
||
| 238 | foreach hname $hdata { |
||
| 239 | .ev.mb.t.h add command -label $hname -command { |
||
| 240 | set hid [ open hist.dat w ] |
||
| 241 | set nl 0 |
||
| 242 | foreach i [ $grm.hbx element cget hbx1 -data ] { |
||
| 243 | if $nl { puts $hid $i } else { puts -nonewline $hid "$i "} |
||
| 244 | set nl [ expr ! $nl ] } |
||
| 245 | close $hid } } |
||
| 246 | .ev.mb.t add cascade -menu .ev.mb.t.h -label "Hout" -underline 0 |
||
| 247 | menu .ev.mb.tb -font $tfont |
||
| 248 | |||
| 249 | menu .ev.mb.o -font $tfont |
||
| 250 | menu .ev.mb.o.c -font $tfont |
||
| 251 | foreach cfd [ split [ glob [file join [file dirname $config_dir] \ |
||
| 252 | "*" ] ] " " ] { |
||
| 253 | if [ file isdirectory $cfd] { |
||
| 254 | .ev.mb.o.c add radiobutton -label [ file tail $cfd ] \ |
||
| 255 | -value $cfd -variable config_dir \ |
||
| 256 | -command evinitp }} |
||
| 257 | .ev.mb.o add cascade -menu .ev.mb.o.c -label "Config" -underline 0 |
||
| 258 | lappend open_disable ".ev.mb.o entryconfigure Config" |
||
| 259 | menu .ev.mb.o.mag -font $tfont |
||
| 260 | .ev.mb.o.mag add radiobutton -value 1. -variable evmag -label "1x" \ |
||
| 261 | -command mag -underline 0 |
||
| 262 | .ev.mb.o.mag add radiobutton -value 2. -variable evmag -label "2x" \ |
||
| 263 | -command mag -underline 0 |
||
| 264 | .ev.mb.o.mag add radiobutton -value 4. -variable evmag -label "4x" \ |
||
| 265 | -command mag -underline 0 |
||
| 266 | .ev.mb.o.mag add radiobutton -value 8. -variable evmag -label "8x" \ |
||
| 267 | -command mag -underline 0 |
||
| 268 | .ev.mb.o add cascade -menu .ev.mb.o.mag -label "Magnification" -underline 0 |
||
| 269 | menu .ev.mb.o.pal -font $tfont |
||
| 270 | .ev.mb.o.pal add command -label "BWpal" -underline 0 -command { |
||
| 271 | foreach ctag $paltags cval $BWpal { |
||
| 272 | .ev.det itemconfigure $ctag -fill $cval }} |
||
| 273 | .ev.mb.o.pal add command -label "BRpal" -underline 1 -command { |
||
| 274 | foreach ctag $paltags cval $BRpal { |
||
| 275 | .ev.det itemconfigure $ctag -fill $cval }} |
||
| 276 | .ev.mb.o add cascade -menu .ev.mb.o.pal -label "Palette" -underline 0 |
||
| 277 | |||
| 278 | .ev.mb add cascade -menu .ev.mb.f -label "File" -underline 0 |
||
| 279 | .ev.mb add cascade -menu .ev.mb.t -label "Tools" -underline 0 |
||
| 280 | .ev.mb add cascade -menu .ev.mb.tb -label "Toolbar" -underline 4 |
||
| 281 | .ev.mb add cascade -menu .ev.mb.o -label "Options" -underline 0 |
||
| 282 | |||
| 283 | |||
| 284 | # TOOLBAR definitions |
||
| 285 | |||
| 286 | frame .ev.tb -height [expr $evmag*14] -background "#00AA00" |
||
| 287 | |||
| 288 | # OPEN & CLOSE button |
||
| 289 | button .ev.tb.opcl -text "Open" -command { set sreset 1 ; evopenp } \ |
||
| 290 | -font $tfont |
||
| 291 | pack .ev.tb.opcl -side left -padx 2 -pady 2 |
||
| 292 | |||
| 293 | # PREVIOUS event |
||
| 294 | button .ev.tb.prev -text "<" -command evprevplotp -state disabled \ |
||
| 295 | -font $tfont -width 0 |
||
| 296 | lappend open_enable ".ev.tb.prev configure" |
||
| 297 | pack .ev.tb.prev -side left -pady 2 |
||
| 298 | bind .ev.tb.prev <2> { set curev [expr [.ev.tb.curev get]-10] |
||
| 299 | evgoto [expr [expr $curev>0]?$curev:1] |
||
| 300 | evplotp} |
||
| 301 | bind .ev.tb.prev <3> { set curev [expr [.ev.tb.curev get]-100] |
||
| 302 | evgoto [expr [expr $curev>0]?$curev:1] |
||
| 303 | evplotp} |
||
| 304 | |||
| 305 | # CURENT event |
||
| 306 | entry .ev.tb.curev -width 5 -font $tfont -state disabled |
||
| 307 | lappend open_enable ".ev.tb.curev configure" |
||
| 308 | pack .ev.tb.curev -side left -pady 2 |
||
| 309 | bind .ev.tb.curev <KeyPress-Return> { evgoto [.ev.tb.curev get] |
||
| 310 | evplotp} |
||
| 311 | |||
| 312 | # NEXT event |
||
| 313 | button .ev.tb.next -text ">" -command evplotp -state disabled \ |
||
| 314 | -font $tfont -width 0 |
||
| 315 | lappend open_enable ".ev.tb.next configure" |
||
| 316 | pack .ev.tb.next -side left -pady 2 |
||
| 317 | bind .ev.tb.next <2> { evgoto [expr [.ev.tb.curev get]+10] |
||
| 318 | evplotp} |
||
| 319 | bind .ev.tb.next <3> { evgoto [expr [.ev.tb.curev get]+100] |
||
| 320 | evplotp} |
||
| 321 | |||
| 322 | # SCAN events |
||
| 323 | button .ev.tb.scan -text "Scan" -command { evscanp ; evscanplotp } \ |
||
| 324 | -state disabled -font $tfont -width 4 |
||
| 325 | lappend open_enable ".ev.tb.scan configure" |
||
| 326 | pack .ev.tb.scan -side left -padx 2 -pady 2 |
||
| 327 | |||
| 328 | # MAXIMUM of the scan |
||
| 329 | entry .ev.tb.scmax -width 3 -font $tfont |
||
| 330 | .ev.tb.scmax insert 0 "100" |
||
| 331 | pack .ev.tb.scmax -side left -padx 2 -pady 2 |
||
| 332 | |||
| 333 | # JOIN & SPLIT detectors |
||
| 334 | button .ev.tb.join -text "Join" -command evjoin -font $tfont |
||
| 335 | pack .ev.tb.join -side left -padx 2 -pady 2 |
||
| 336 | |||
| 337 | # AMOUNT of chenels to move |
||
| 338 | entry .ev.tb.jmove -width 3 -font $tfont |
||
| 339 | .ev.tb.jmove insert 0 "80" |
||
| 340 | pack .ev.tb.jmove -side left -padx 2 -pady 2 |
||
| 341 | |||
| 342 | # PRINT button |
||
| 343 | button .ev.tb.print -text "Print" -font $tfont \ |
||
| 344 | -command { if { $evprwin } { |
||
| 345 | .ev.det postscript -file det.ps -pagewidth 17c -fontmap PSfontmap |
||
| 346 | .ev.fed postscript -file fed.ps -pageheight 25c |
||
| 347 | } else { |
||
| 348 | .ev.det postscript -file det.ps -rotate 1 -x 0 -y 0 -pagewidth 25c \ |
||
| 349 | -width [expr $evmag*350] \ |
||
| 350 | -height [expr $evmag*300] -fontmap PSfontmap |
||
| 351 | .ev.fed postscript -file fed.ps -x 0 -y 0 -pageheight 25c \ |
||
| 352 | -width 280 -height 738 } |
||
| 353 | $grm.nh postscript output g1.eps -width 560 -height 400 |
||
| 354 | $grm.nbx postscript output g2.eps -width 560 -height 400 |
||
| 355 | $grm.hbx postscript output g3.eps -width 560 -height 400 |
||
| 356 | $grm.nco postscript output g4.eps -width 560 -height 400 |
||
| 357 | canvas .eps |
||
| 358 | .eps create eps 4 4 -file g1.eps -showimage no |
||
| 359 | .eps create eps 4 404 -file g2.eps -showimage no |
||
| 360 | .eps create eps 564 4 -file g3.eps -showimage no |
||
| 361 | .eps create eps 564 404 -file g4.eps -showimage no |
||
| 362 | .eps postscript -file gr.ps -x 0 -y 0 -pagewidth 16c \ |
||
| 363 | -width 1120 -height 800 |
||
| 364 | destroy .eps |
||
| 365 | } |
||
| 366 | pack .ev.tb.print -side left -padx 2 -pady 2 |
||
| 367 | |||
| 368 | |||
| 369 | # OPTIONS menu |
||
| 370 | menubutton .ev.tb.opt -menu .ev.tb.opt.m -text "Opt" -relief raised \ |
||
| 371 | -font $tfont |
||
| 372 | menu .ev.tb.opt.m -font $tfont |
||
| 373 | .ev.tb.opt.m add checkbutton -variable evrescan -label "allways rescan" |
||
| 374 | .ev.tb.opt.m add checkbutton -variable evnorm -label "norm. to events" |
||
| 375 | .ev.tb.opt.m add checkbutton -variable evm4norm -label "norm. M4 channels" |
||
| 376 | .ev.tb.opt.m add checkbutton -variable evreverse -label "reverse scale" |
||
| 377 | .ev.tb.opt.m add checkbutton -variable evhot -label "rescan hot" |
||
| 378 | .ev.tb.opt.m add checkbutton -variable evmask -label "remove hot" |
||
| 379 | .ev.tb.opt.m add separator |
||
| 380 | .ev.tb.opt.m add checkbutton -variable evmap -label "focal plane map" \ |
||
| 381 | -command { evinitp } |
||
| 382 | .ev.tb.opt.m add separator |
||
| 383 | .ev.tb.opt.m add checkbutton -variable evprwin -label "print only visible" |
||
| 384 | pack .ev.tb.opt -side right -padx 2 -pady 2 |
||
| 385 | |||
| 386 | |||
| 387 | # MAGNIFICATION menu |
||
| 388 | menubutton .ev.tb.mag -menu .ev.tb.mag.m -text "Mag" -relief raised \ |
||
| 389 | -font $tfont |
||
| 390 | menu .ev.tb.mag.m -font $tfont |
||
| 391 | .ev.tb.mag.m add radiobutton -value 1. -variable evmag -label "1x" -command mag |
||
| 392 | .ev.tb.mag.m add radiobutton -value 2. -variable evmag -label "2x" -command mag |
||
| 393 | .ev.tb.mag.m add radiobutton -value 4. -variable evmag -label "4x" -command mag |
||
| 394 | .ev.tb.mag.m add radiobutton -value 8. -variable evmag -label "8x" -command mag |
||
| 395 | pack .ev.tb.mag -side right -padx 2 -pady 2 |
||
| 396 | |||
| 397 | frame .ev.tb1 -height [expr $evmag*14] -background "#0000AA" |
||
| 398 | |||
| 399 | # EXIT button |
||
| 400 | button .ev.tb1.ex -text {exit} -command { evexit } -font $tfont |
||
| 401 | pack .ev.tb1.ex -side right -padx 2 -pady 2 |
||
| 402 | |||
| 403 | |||
| 404 | #*** STATUSLINE definitions |
||
| 405 | |||
| 406 | label .ev.mapping -relief ridge -anchor w -text "" -font $tfont |
||
| 407 | label .ev.evdata -relief ridge -anchor w -text "" -font $tfont |
||
| 408 | label .ev.status -relief ridge -anchor w -text "" -font $tfont |
||
| 409 | |||
| 410 | button .ev.yy -background "#000000" |
||
| 411 | |||
| 412 | |||
| 413 | #*** GEOMETRY MANAGER |
||
| 414 | table .ev \ |
||
| 415 | 0,0 .ev.mb -fill both -cspan 4 \ |
||
| 416 | 1,0 .ev.tb -fill both -cspan 2 \ |
||
| 417 | 1,2 .ev.tb1 -fill both -cspan 2 \ |
||
| 418 | 2,0 .ev.det -fill both \ |
||
| 419 | 2,1 .ev.detvs -fill both \ |
||
| 420 | 3,0 .ev.deths -fill both \ |
||
| 421 | 4,0 .ev.mapping -fill both -cspan 2 \ |
||
| 422 | 5,0 .ev.evdata -fill both -cspan 2 -rspan 2 \ |
||
| 423 | 2,2 .ev.gr -fill both -rspan 4 \ |
||
| 424 | 6,2 .ev.grhs -fill both \ |
||
| 425 | 2,3 .ev.grvs -fill both -rspan 4 \ |
||
| 426 | 6,3 .ev.yy -fill both \ |
||
| 427 | 7,0 .ev.status -fill both -cspan 4 |
||
| 428 | table configure .ev c1 c2 c3 r0 r1 r3 r4 r5 r6 r7 -resize none |
||
| 429 | table configure .ev c2 -width [expr $evmag*140] |
||
| 430 | table configure .ev c1 c3 -width [expr 8+$evmag*5] |
||
| 431 | table configure .ev r3 r6 -height [expr 8+$evmag*5] |
||
| 432 | table configure .ev r0 r1 -height [expr 10+$evmag*12] |
||
| 433 | table configure .ev r2 -height { 100 1000 } -resize both |
||
| 434 | table configure .ev c0 -width { 100 1200 } -resize both |
||
| 435 | table arrange .ev |
||
| 436 | |||
| 437 | |||
| 438 | |||
| 439 | #*** display initialisation procedure |
||
| 440 | |||
| 441 | proc evinitp {} { |
||
| 442 | global evmap evmag m4color m16color tfont config_dir |
||
| 443 | .ev.det delete all |
||
| 444 | .ev.fed delete all |
||
| 445 | set xy [expr $evmag*10] |
||
| 446 | if $evmap { |
||
| 447 | .ev.det create text $xy $xy -text "FOCAL PLANE MAP" -fill "#00AA00" \ |
||
| 448 | -anchor w -font $tfont -tags t |
||
| 449 | catch {table forget .ev.fed .ev.fedvs .ev.fedhs} |
||
| 450 | table .ev \ |
||
| 451 | 2,2 .ev.gr -fill both -rspan 4 \ |
||
| 452 | 6,2 .ev.grhs -fill both \ |
||
| 453 | 2,3 .ev.grvs -fill both -rspan 4 |
||
| 454 | } else { |
||
| 455 | .ev.det create text $xy $xy -text "PMT PLANE MAP" -fill "#AA0000" \ |
||
| 456 | -anchor w -font $tfont -tags t |
||
| 457 | catch {table forget .ev.gr .ev.grvs .ev.grhs} |
||
| 458 | table .ev \ |
||
| 459 | 2,2 .ev.fed -fill both -rspan 4 \ |
||
| 460 | 6,2 .ev.fedhs -fill both \ |
||
| 461 | 2,3 .ev.fedvs -fill both -rspan 4 |
||
| 462 | } |
||
| 463 | puts " $config_dir $evmag" |
||
| 464 | evinit .ev.det .ev.fed $evmag |
||
| 465 | .ev.det lower m4 m16 |
||
| 466 | } |
||
| 467 | evinitp |
||
| 468 | |||
| 469 | #*** FILE open procedure |
||
| 470 | |||
| 471 | proc evopenp {} { |
||
| 472 | global data_dir evmag new_scan evfile tfont evhot open_enable open_disable |
||
| 473 | set new_scan 1 |
||
| 474 | if ![file isdirectory $data_dir] { set data_dir "." } |
||
| 475 | set evfile [tk_getOpenFile -initialdir $data_dir -parent .ev \ |
||
| 476 | -filetypes { \ |
||
| 477 | {"all data" {.dat .dat.gz .daq .daq.gz \ |
||
| 478 | .daq1 .daq1.gz .dst .dst.gz \ |
||
| 479 | .ric .ric.gz}} \ |
||
| 480 | {"old data format" {.dat .dat.gz}} \ |
||
| 481 | {"common-daq" {.daq .daq.gz}} \ |
||
| 482 | {"mare-daq+rec" {.daq1 .daq1.gz}} \ |
||
| 483 | {"common-dst" {.dst .dst.gz}} \ |
||
| 484 | {"rich" {.ric .ric.gz}} \ |
||
| 485 | {"all" {*}} \ |
||
| 486 | }] |
||
| 487 | if { $evfile != "" } { |
||
| 488 | if { [set ztip [string last ".gz" $evfile]] != -1 } { |
||
| 489 | exec gunzip $evfile |
||
| 490 | set evfile [string range $evfile 0 [expr $ztip-1]] |
||
| 491 | } |
||
| 492 | set data_dir [file dirname $evfile] |
||
| 493 | evopen $evfile |
||
| 494 | foreach com $open_enable { eval $com -state normal } |
||
| 495 | foreach com $open_disable { eval $com -state disabled } |
||
| 496 | .ev.tb.opcl configure -text "Close" -command {evclosep 0} |
||
| 497 | .ev.tb.curev delete 0 end |
||
| 498 | .ev.det delete ev sc |
||
| 499 | .ev.fed delete sc |
||
| 500 | .ev.det delete tf |
||
| 501 | .ev.det create text [expr $evmag*10] [expr $evmag*293] \ |
||
| 502 | -text [file tail $evfile] -fill "#00c0c0" \ |
||
| 503 | -anchor w -font $tfont -tags tf |
||
| 504 | bind .ev.tb.opcl <2> {evclosep 1} |
||
| 505 | } |
||
| 506 | } |
||
| 507 | |||
| 508 | #*** FILE close procedure |
||
| 509 | |||
| 510 | proc evclosep {gzipit} { |
||
| 511 | global evfile gzip_stat withBLT open_enable open_disable |
||
| 512 | set gzip_stat {} |
||
| 513 | # use of middle button will gzip file after close |
||
| 514 | bind .ev.tb.opcl <2> {} |
||
| 515 | evclose |
||
| 516 | foreach com $open_enable { eval $com -state disabled } |
||
| 517 | foreach com $open_disable { eval $com -state normal } |
||
| 518 | if { $gzipit } { |
||
| 519 | .ev.tb.opcl configure -state disabled |
||
| 520 | if { $withBLT } { |
||
| 521 | bgexec gzip_stat gzip $evfile } else { |
||
| 522 | exec gzip $evfile } |
||
| 523 | .ev.tb.opcl configure -state normal } |
||
| 524 | .ev.tb.opcl configure -text "Open" -command evopenp |
||
| 525 | } |
||
| 526 | |||
| 527 | #*** FILE dump procedure |
||
| 528 | |||
| 529 | proc evdumpp {} { |
||
| 530 | global dump_dir |
||
| 531 | if ![file isdirectory $dump_dir] { set dump_dir "." } |
||
| 532 | set dumpfile [tk_getSaveFile -initialdir $dump_dir -parent .ev \ |
||
| 533 | -filetypes { \ |
||
| 534 | {"rich" {.ric}} \ |
||
| 535 | {"all" {*}} \ |
||
| 536 | }] |
||
| 537 | if { $dumpfile != "" } { |
||
| 538 | set dump_dir [file dirname $dumpfile] |
||
| 539 | evdump $dumpfile |
||
| 540 | } |
||
| 541 | } |
||
| 542 | |||
| 543 | #*** procedure to produce occupancy plot |
||
| 544 | |||
| 545 | proc evscanp {} { |
||
| 546 | global evmag new_scan evrescan evnorm evreverse evmask |
||
| 547 | # global nhy nbxy hbxy nco4y nco16y nrepy nrep64y |
||
| 548 | if { $new_scan || $evrescan} { |
||
| 549 | uplevel #0 { evscan } |
||
| 550 | set new_scan 0 |
||
| 551 | } |
||
| 552 | } |
||
| 553 | |||
| 554 | proc evscanplotp {} { |
||
| 555 | .ev.det delete ev sc |
||
| 556 | .ev.fed delete ev sc |
||
| 557 | .ev.status configure -text \ |
||
| 558 | [ uplevel #0 { evscanplot .ev.det $evmag [ .ev.tb.scmax get ] .ev.fed } ] |
||
| 559 | } |
||
| 560 | |||
| 561 | #*** procedure to join detector halfs |
||
| 562 | |||
| 563 | proc evjoin {} { |
||
| 564 | global evmag jmove |
||
| 565 | .ev.tb.jmove configure -state disabled |
||
| 566 | .ev.tb.scan configure -state disabled |
||
| 567 | set jmove [.ev.tb.jmove get] |
||
| 568 | .ev.det addtag ld enclosed 0 [expr $evmag*150] [expr $evmag*350] \ |
||
| 569 | [expr $evmag*300] |
||
| 570 | .ev.det move ld 0 [expr -$evmag*$jmove] |
||
| 571 | .ev.tb.join configure -text "Split" -command evsplit |
||
| 572 | } |
||
| 573 | |||
| 574 | #*** procedure to split detector halfs |
||
| 575 | |||
| 576 | proc evsplit {} { |
||
| 577 | global evmag jmove |
||
| 578 | .ev.tb.jmove configure -state normal |
||
| 579 | .ev.tb.scan configure -state normal |
||
| 580 | .ev.det move ld 0 [expr $evmag*$jmove] |
||
| 581 | set jmove 0 |
||
| 582 | .ev.tb.join configure -text "Join" -command evjoin |
||
| 583 | } |
||
| 584 | |||
| 585 | #*** procedure to plot previose event |
||
| 586 | |||
| 587 | proc evprevplotp {} { |
||
| 588 | set curev [expr [.ev.tb.curev get]-1] |
||
| 589 | evgoto [expr [expr $curev>0]?$curev:1] |
||
| 590 | evplotp |
||
| 591 | } |
||
| 592 | |||
| 593 | #*** procedure to plot next event |
||
| 594 | |||
| 595 | proc evplotp {} { |
||
| 596 | global evmag evcolor jmove tfont evmask |
||
| 597 | .ev.det delete ev sc ri |
||
| 598 | .ev.fed delete ev sc |
||
| 599 | .ev.evdata configure -text [evplot .ev.det $evmag .ev.fed] |
||
| 600 | } |
||
| 601 | |||
| 602 | #*** called when magnification factor is changed |
||
| 603 | |||
| 604 | proc mag {} { |
||
| 605 | global evmag oldevmag |
||
| 606 | set sc [expr $evmag/$oldevmag] |
||
| 607 | set xf [lindex [.ev.det xview] 0] |
||
| 608 | set yf [lindex [.ev.det yview] 0] |
||
| 609 | .ev.det configure -scrollregion "0 0 [expr $evmag*350] [expr $evmag*300]" |
||
| 610 | .ev.det xview moveto $xf |
||
| 611 | .ev.det yview moveto $yf |
||
| 612 | .ev.det scale all 0 0 $sc $sc |
||
| 613 | set oldevmag $evmag |
||
| 614 | } |
||
| 615 | |||
| 616 | proc evexit {} { |
||
| 617 | exit |
||
| 618 | } |
||
| 619 | |||
| 620 | proc center {x y} { |
||
| 621 | puts [table cget .ev c0 -width] |
||
| 622 | } |
||
| 623 |