Tips for PAW macros

Some kumac macros for our analysis are already collected under:
            /t912/macro
but are not yet well organized. Here some tips for using macros are explained and how to use collected macros will be introduced, hopefully.

Tips

!!!!

Do not open your PAW session under public directory. Especially, do not change-directory to /t912/macro when you use public macros. You can write and delete any files here!

How to use our standard environment in your PAW sessions

Please include the following line in your .pawlogon.kumac in your home directory.
      exec /t912/macro/btinit
      
This macro defines many global variables and some vectors, which can be used in your sessions or in your own macros.
If you hope to live in the world of "btinit", never execute
      v/del *
      
This command deletes all vectors which are defined in "btinit"!

How to use public macros in your PAW sessions

Please include the following line in your .pawlogon.kumac in your home directory.
      macro/defaults '/t912/macro,.'
      

How to use just "cmd" instead of "exec cmd" for macro execution.

Please include the following line in your .pawlogon.kumac again.
      macro/defaults -auto
      

How to use Macros in /t912/macro

alloc_run.kumac

Allocate logical unit number, lun, to a ntuple file with run# nnn. This command automatically searches for the file and uncompress it if necessary.
      exec /t912/macro/alloc_run  lun nnn
      lun = logical unit number
      nnn = run number
      

gzip_run.kumac

Compress the ntuple file with run# nnn. This command automatically searches for the file.
      exec /t912/macro/gzip_run  nnn
      nnn = run number
      

pid_nop.kumac

Particle identification macro for a setup without preshower detector. (by Oishi)
      exec /t912/macro/pid_nop  nnn
      nnn = run number
      

pidkk.kumac

Another particle identification macro for a setup without preshower detector. This is a version which uses "sum of normalized ADC values in ech section" instead of adchcal(13,i). Trigger counter ADC values are also normalized. Normalization and pedestal subtraction are done by Ota's scheme within this macro. (by Kawagoe)
      exec /t912/macro/pidkk  nnn
      nnn = run number
      

get_ped.kumac

Read appropriate pedestal data from pedestal files. They are read into vectors named as, xxxxxx_ped, where xxxxx is the name of ntuple variables.
      exec /t912/macro/get_ped  nnn
      nnn = run number
      

get_cc.kumac

Read appropriate calibration data from calibration files. They are read into vectors named as, xxxxxx_cc, where xxxxx is the name of ntuple variables.
      exec /t912/macro/get_cc  nnn
      nnn = run number
      

tilled.kumac, pmtled.kumac and tmpmon.kumac

Monitor time dependece of "Tile LED", "PMT LED" and "Temperature Monitors". (by Sugimoto) The first and last run numbers can be specified:
      exec /t912/macro/pmtled  mmm nnn
      mmm = the first run number
      nnn = the last run number
      

tsc.kumac

Plots TC4, TC5 and TPSD data. (by Kawagoe)
      exec /t912/macro/tsc nnn
      nnn = run number
      

pwc.kumac

Make a hitmap of PWC. (by Kawagoe)
      exec /t912/macro/pwc  nnn
      nnn = run number
      

shmax.kumac

Make a hitmap of shmax detector. The default threshold is set to 100. (by Kawagoe)
      exec /t912/macro/shmax  nnn [ith]
      nnn = run number
      ith = threshold value
      

dirift.kumac & timecal.f

With this macro, you can check shift of pedestals (or any LED data) between runs. (by Uozumi)
      exec /t912/macro/drift nnn m
      nnn = run number
      m = Trigger ID(6=pedestal,7=TIle LED,8=PMT LED)
      

long.kumac

It is to check long-term pedestal shifting.(by Uozumi)
      exec /t912/macro/long mmm nnn [aa]
      nnn = run number to start to plot
      mmm = run number to end to plot
      aa = half height of null region(default 50)
      

How to write public macros

  1. Please execute btinit at the beginning of your macro. btinit initializes our standard environment. It is recommended to include btinit into users .pawlogon.kumac, which is automatically executed at the beginnig of user's PAW session. But, for comfirmation, please include
             
          exec /t912/macro/btinit; global/import *
          
    at the beginning of your macro. btinit automatically detects that it is already executed or not, and avoids duplication.
  2. Please use positional arguments not only named arguments. By just putting argument names to the "macro" statment, they can be positional, not only named.
          macro example run
          
    This example macro can be used in both styles:
          exe example nnn
          exe example run=nnn
          
  3. Do not delete all vectors and histograms at the beginning of your macro.
          X  v/del *
          X  hi/del 0
          
    It might be necessary to close all files, because we cannot know the given unit number is already used or not.
          O  clo 0
          
  4. Please delete all vectors and histograms you create within your macro before your macro ends. Even in that case, do not use
          X  v/del *
          X  hi/del 0
          
  5. It might be better to check existance of files, vectors and histograms before you use.
          if $fexist([file_name])=1 then
            hi/file [lun] [file_name]
          endif
    
          if $vexist([vec_name])<>0 then; v/del [vec_name];endif
    
          if $hexist([hist_name])=1 then; hi/del [hist_name];endif
          
  6. Please use global variables as much as possible. Some detector parameters, lugical unit numbers and public directories etc. are already defined in btinit.kumac in /t912/macro. Please refer to it for details.
          do isec=1,[nsechcal]
            do itow=1,[ntowhcal]
              ....
            enddo 
          enddo
    
          file_ntpl=[ntpl_dir]/run[runnum].ntpl
          if $fexist([file_ntpl])=1 then
            hi/file [lun_ntpl] [file_ntpl]
          endif
          
  7. If you want to create your own postscript files, please refer to psout global flag as:
          exec /t912/macro/dispset; global/import *
          if [psout]<>[off] then
            runnum = $format([run],i4.4)
            file_ps = macroname_run[runnum].ps
            if $fexist([file_ps])=1 then
              sh rm [file_ps]
            endif
            fort/file [lun_ps] [file_ps]
          endif
          exec /t912/macro/psset;global/import *
          
    These commands enable user to control postscript output by:
          pson
          psoff
          
    Do not forget to close ps file before you leave:
          if [psout]<>[off] then
            close [lun_ps]
          endif
          
  8. If your macro needs some comis functions, they also have to be copied to /t912/macro. They can be used as:
    	call "/t912/macro/comis.for()"
    
    	nt/loop 1 "/t912/macro/comis.for"
    	
  9. Do not use histogram ID's less than 1000 in your own macro. Public ntuple already uses ID's greater than 100. In order to avoid confusion, ID's less than 1000 should be reserved for public use.
  10. If you need to use ntuple variables in your own comis function, please use:
    	include '/t912/macro/bt.inc'
    	
    This include file will be updated when ntuple structure is changed. If you include this file, you need not change your code at all.

Junichi Kanzaki < Junichi.Kanzaki@kek.jp>
Last modified: Sat Sep 25 06:23:26 CDT 1999