HEXE Documentation Page

HEXE (the Hermes Event miXEr) is a program to mix records from different input files into a common outpt file. Nevertheless it can also be used to simply transform a file from one ADAMO/DAD format into an other. With it's filter expressions one can use Hexe also to run as a filter on a data sample. So to say the program is an 'Eierlegende Wollmilchsau'.

Command Syntax

hexe: syntax:
    hexe [options] infile1 [ [options] infile2 ... ] [options] 
------------
    options: --weight num
             -w num      Weight for file. Weight is by default 1
                         All Events are then mixed with equal
                         Distribution
             --driver driver 
             -d driver   specify an adamo/dad driver for next
                         file (RZ,FZ,RPIP,RFIL,RMEM,WPIP,WFIL,WMEM)
             --evcat 
             -c          use the evcat format for this dad file
                         orignally intended for the funnel operation.
             -z          enable online compression/decompression
                         for dad files
             --outfile file 
             -o file     Output file - defaults to hexe.fz
                         driver=FZ,filfor=EXCH
             --nooutfile
             -n          No output files. Useful for --print(see below)
             --seed seed
             -s seed     Set seed for random operation.
                         Defaults to time(0)+getpid()
             -append
             -a          Don't use random distribution but
                         append infiles to each other in outfile
             --print table:condition:format:value:[format:value:...] 
             -p t:c:f:v  Print the value for all elements of the
                         table which fulfill the condition. Format
                         is a valid C-printf format statement which
                         can be omitted to use a default
                         several -p statements may be given which
                         then are printed for each table row on a line
             --pnull     Don't suppress printing of lines with NULL links 
             --keytabint n 
             -k n        use n integers in the default keytable
                         if only dad input is used (def=0)
                         This number corresponds to the fields
                         between ID and cName
             --keytab    Generate a keytable in the dad output file
             --keep      don't modify existing keytables
             --expression expr
             -e expr     check expression before writing the
                         record. Expression looks like
                         Table:Good:DadExpression
                         with Table: Tablename or `none'
                              Good: Number of rows that passed
                                    the condition. Or perc% or
                                    all
             ++[--]filter expr
             +[-]f expr  Keep [remove] rows from a table
                         which fulfill a given expression:
                         Table:DadExpression
                         with Table: Tablename
 --- (C) 1995 Hermes Collaboration / Wolfgang Wander

Examples

Mixing two (or more) input files

Assumed one has two sets of monte carlo produced event files. One with positive (hmcpos.fz) and one with negative (hmcneg.fz) target polarization. Calling hexe like
   hexe -w 80 hmcpos.fz -w 20 hmcneg.fz -o hmc.fz
will generate an hmc.fz file with 60% positive target polarization. The events are randomly taken from both files with the given weights. To reproduce the distribution one can set a seed for the random number generator with the --seed option.

Appending two (or more) input files

Event mixing can be disabled by applying the --append switch.
   hexe -a hmcpos.fz hmcneg.fz -o hmc.fz
will copy the contents of hmcpos.fz to hmc.fz and append hmcneg.fz afterwards.

Converting files from different formats

Hexe can read and write Adamo and Dad format files. Adamo file drivers are specified by the drivername (plus a commaseperated list of options) and Dad drivers by RFIL for reading a file, WFIL for writing and RPIP and WPIP for reading/writing of pipes. The driver parameter --driver is always given for the next file on the commanline. Driver defaults to IE for files which end with .ie, RZ for files which end with .rz and FZ,filfor=EXCH for the rest.
   hexe hmc.fz -o hmc.rz
converts the FZ,filfor=EXCH-file hmc.fz into RZ format.
   hexe -d RPIP deco.fifo -d FZ deco.ffz
converts input from the DAD pipe deco.fifo into the native FZ file deco.ffz. As dad files normally don't use keytables in sequential IO the parameter --keytabint can be used to build a fake keytable with n integer parameters additional to ID in which the last integer is incremented with the number of read records.

Printing information on the tables

This option builds a simple printing facility for single columns of a table.
 
   hexe -n hmc.events -p 'mcEvent:::iEvent'
Prints all event numbers in an hmc event file.
   hexe -n hmc.events -p 'mcTrack:iGType=2:Energy = %f:E'
Prints the energy of all positrons (Geant Particle Type == 2):
   Energy = 5.23412
   Energy = 7.00123
   ...
  hexe -z -n -d RFIL hrc.devents.gz -p \
              'rcTrack:::P::NATREL("rcTrack","Backward","ECalor")'
prints out the momentum and the energy of the backcluster of each track.
Starting with dad version 1.5, NAFREL is also supported:
  hexe -z -n -d RFIL hrc.devents.gz -p \
              'mcTrack:::P::NAFREL("mcTrack","mcTrack","rcTrack","P")'
compares generated and reconstructed track momenta. Also new in version 1.5 is the GETROW function, which allows you to retrieve the nth row of any table. This table may be disconnected from the primary table of your print command. The function is great for accessing 1-row tables without any need for NATREL or NAFREL. For example,
  hexe -z -n -d RFIL mc.smdst.gz -p \
              'g1Track:::P::GETROW("g1MEvent",1,"weight")'
provides a list of reconstructed track momenta, together with the Monte Carlo weight for the corresponding event. GETROW is also great for accessing the mcUser and g1mcUser tables, where each row corresponds to a particular piece of information. For example, the gmc_disNG generator stores each event's depolarization factor in mcUser row #10. So this command would allow you to examine the dependence of depol on the kinematic variable y:
  hexe -z -n -d RFIL gmc.devents -p \
              'mcEvent:::Y::GETROW("mcUser",10,"Val")'

Selecting the records to be written

Hexe can filter the records written to the output file by user defined conditions. These filter conditions consist of Table:Good:DadExpression where
   hexe hrc.fz -o hrc.out.fz -e 'rcCluster:1:E>10'
lets records pass only if one cluster in the event contains more then 10 GeV energy.
   hexe hrc.fz -o hrc.out.fz -e '::counttable("rcTrack")>0'
lets records pass only if there is at least one track in the event.
   hexe hrc.fz -o hrc.out.fz -e rcTrack:1:1
this is equivalent to the above statement.
   hexe hrc.fz -o hrc.out.fz -e rcTrack:1:1 -e 'rcCluster:1:E>10'
Here only events pass which have at least one track AND a calorimeter cluster of more than 10 GeV

Filtering rows in tables

Expressions can also be used to filter rows in tables.
   hexe hrc.fz -o hrc.out.fz -f rcTreeLine:bUsed=0
removes the treelines from the input which are not used to form a track.
   hexe hrc.fz -o hrc.out.fz +f 'rcTrack:pidElec>0.5' -f rcTreeLine:1
keeps only tracks which particle id probablity for an electron is higher 50% and removes all rcTreeLines from the input.
This page is maintained by Wolfgang Wander.