PAW macros

  • VDC drift time to distance
    macro main
      hid1=gtdcx1
      hid2=gtdcu1
      hid3=gtdcx2
      hid4=gtdcu2
      do i = 1, 4
        if ($hexist([hid[i]]) .ne. 1) then
          hrin [hid[i]]
        endif
      enddo
      mess 'exec hout#hout4 gtdcx1'
      exec hout#hout4 gtdcx1
      mess temp.hst was created!
    
      do i = 1, 4
        ymax  = $hinfo([hid[i]],'max')
        ymaxq = [ymax] / 6.
        str = 'sub1 '//[hid[i]]//' '//[ymaxq]//' '//1
        x1  = $exec($unquote([str]))
        str = 'sub1 '//[hid[i]]//' '//[ymaxq]//' '//2
        x2  = $exec($unquote([str]))
        xm  = 0.5*(([x1])+([x2]))
        str = 'hx('//[hid[i]]//','//$rsigma([xm])//')'
        ym  = $call([str])
        ym10 = ([ym]) / 10.
        selnt [i]0
        exe draw_line_y [ym] [ym10]
        str = 'sub1 '//[hid[i]]//' '//[ym10]//' '//1
        x1  = $exec($unquote([str]))
        str = 'sub1 '//[hid[i]]//' '//[ym10]//' '//2
        x2  = $exec($unquote([str]))
        exe draw_line_x [x1] [x2] [xm]
        mess {$FORMAT([x1],I1),$FORMAT([x2],I1)}
      enddo
      wait
      zon 2 2
      hi/pl gdlx1
      hi/pl gdlu1
      hi/pl gdlx2
      hi/pl gdlu2
    return
    
    macro sub1 hid val nn
      if [hid] = '' then
         message
         message 'Usage wtdc HID'
         message
         exitm
      endif
      if ($hexist([hid]) .ne. 1) then
         message
         message 'No such histgram (HID: '//[hid]//')!!'
         message
         exitm
      endif
    
      xbins = $hinfo([hid],'xbins')
      xmax  = $hinfo([hid],'xmax')
      xmin  = $hinfo([hid],'xmin')
      xdiv  = ([xmax] - [xmin])/[xbins]
    
      vec/cre xx([xbins]) r
      vec/cre yy([xbins]) r
      get/abs [hid] xx
      get/con [hid] yy
    
      k = 1
      do i = 1, [xbins]-1
        ip = [i] + 1
        xxi  = xx([i])
        xxip = xx([ip])
        yyi  = yy([i])
        yyip = yy([ip])
    
        if (((([val] .ge. [yyi])) .and. ([val] .lt. [yyip])) .or. (([val] .le. [yyi]) .and. ([val] .gt. [yyip]))) then      
          slope  = (([yyip])-([yyi]))/(([xxip])-([xxi]))
          offset = ([yyi])-([slope])*([xxi])
          x[k]  = (([val])-([offset]))/([slope])
          k = [k] + 1
        endif
      enddo
      
      vec/del xx,yy
    return [x[nn]]
    
    macro sub2 hid val
      if [hid] = '' then
         message
         message 'Usage wtdc HID'
         message
         exitm
      endif
      if ($hexist([hid]) .ne. 1) then
         message
         message 'No such histgram (HID: '//[hid]//')!!'
         message
         exitm
      endif
    
      xbins = $hinfo([hid],'xbins')
      xmax  = $hinfo([hid],'xmax')
      xmin  = $hinfo([hid],'xmin')
      xdiv  = ([xmax] - [xmin])/[xbins]
    
      vec/cre xx([xbins]) r
      vec/cre yy([xbins]) r
      get/abs [hid] xx
      get/con [hid] yy
    
      k = 1
      do i = 1, [xbins]-1
        ip = [i] + 1
        xxi  = xx([i])
        xxip = xx([ip])
        yyi  = yy([i])
        yyip = yy([ip])
    
        if (((([val] .ge. [yyi])) .and. ([val] .lt. [yyip])) .or. (([val] .le. [yyi]) .and. ([val] .gt. [yyip]))) then      
          slope  = (([yyip])-([yyi]))/(([xxip])-([xxi]))
          offset = ([yyi])-([slope])*([xxi])
          x[k]  = (([val])-([offset]))/([slope])
          k = [k] + 1
        endif
      enddo
      vec/del xx,yy
    return [x[nn]]
    
    macro draw_line_x
      ymin = $GRAFINFO('WNYMIN')
      ymax = $GRAFINFO('WNYMAX')
    
      if $OPTION('LOGY') = 1 then
        ymin = $sigma(10**([ymin]))
        ymax = $sigma(10**([ymax]))
      endif
    
      do i = 1,[#]
        dline [[i]] [[i]] [ymin] [ymax]
      enddo
    return
    
    macro draw_line_y
      xmin = $GRAFINFO('WNXMIN')
      xmax = $GRAFINFO('WNXMAX')
    
      if $OPTION('LOGX') = 1 then
        xmin = $sigma(10**([xmin]))
        xmax = $sigma(10**([xmax]))
      endif
    
      do i = 1,[#]
        dline [xmin] [xmax] [[i]] [[i]]
      enddo
    return
    
    MACRO hout4 id1=1011 file=temp.hst 
    nbin=1024
    vec/cre hist1([nbin])
    vec/cre hist2([nbin])
    vec/cre hist3([nbin])
    vec/cre hist4([nbin])
    id = [id1]
    hi/get/cont [id]   hist1
    id = [id1]+1
    hi/get/cont [id]   hist2
    id = [id1]+2
    hi/get/cont [id]   hist3
    id = [id1]+3
    hi/get/cont [id]   hist4
    vec/write hist1,hist2,hist3,hist4 [file] 4(F8.0)
    vec/del hist1,hist2,hist3,hist4
    RETURN
research/memos/macros/paw.txt · 最終更新: 2017/12/05 22:22 by kobayash
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0