VTVZ bank


VTVZ contains VTPC/VTX and CTC information on primary vertices, most importantly
the z position of the vertices. The bank is initially produced by V2VERT using
the octant track segments in the VTOA bank. It may subsequently be updated by
CTVTVZ to include beam position information.

VTVZ is unpacked by VTGZZT. Unless you are willing to keep up with occasional
changes in format, you should use VTGZZT to access VTVZ information. The bank
format is described in detail below. VTGZZT's usage is given in the source
code. The classifications are described later in this document. One
additional point to keep in mind: The X,Y position returened by VTGZZT is NOT a
reconstructed vertex position. It is based on the line fit to the beam
position and the measured vertex Z.

Whether you choose to access VTVZ directly or through VTGZZT, you should set up
bank pointers by calling TREVIN. (CTEVIN and VTEVIN can perform the same
function, but TREVIN is the simplest to use.)  This needs to be done once per
event. Note TRKSMAKE calls TREVIN, so if you run this upstream of your code,
the initialization is taken care of. TREVIN places the following bank VTVZ
related information in C$INC:VTCAUX.INC
    DVTVZ: offset from bank to data index
    WVTVZ: link to VTVZ, i.e. IW(WVTVZ) always contains the VTVZ bank index or
        zero if the bank is not present. You should verify that IW(WVTVZ)>0.
    IVTVZ: data index to VTVZ. Note this is only valid until the next YBOS
        garbage collection.
	    IVTVZ = IW(WVTVZ) + DVTVZ
	gets the data index with very little overhead, so scatter these around
	your code approprirately.
    LVTVZ: number of words per vertex
    NVTVZ: total number of vertices present (including secondaries)
In addition, the following beam spot information is placed in C$INC:CTCALB.INC
    XBEAM: beam X position at Z=0
    BMXLIN: beam slope, dX/dZ
    YBEAM: beam Y position at Z=0
    BMYLIN: beam slope, dY/dZ

The availability and updating of beam position information in VTVZ is somewhat
complicated. The source of beam position information is the CDF data base (DB)
CDF_COND/PRM/CTC/BPO (BPO). Because there are a large number of BPO entries,
the overhead of loading a new value for each run can be a problem. To avoid
this, the BPO values are copied to VTVZ: if you write the updated VTVZ banks
back out, you don't need to access the DB for subsequent analysis of that data
set. Unfortunately, it is impossible to tell if the VTVZ bank is up-to-date
other than to load the latest value from the data base and compare. Once
you've loaded the DB, there's no point making the comparison: you might as well
use the value you loaded.

If you think the BPO values in your file are obsolete, the simplest procedure
is to re-write the file after updating VTVZ. Include the following in some
piece code somewhere in your program, to be called once per event.
	$$include 'C$INC:CTCAUX.INC'
		INTEGER SAVENA,STATUS
		SAVENA = CTCENA
		CTCENA = 5
		CALL CTEVIN(STATUS)
		CTCENA = SAVENA
This will load the BPO data base for each run; and for each event will update
VTVZ. It is tempting to use the above only for selected events, e.g. those
which don't have SVX beam positions. THIS WILL NOT WORK, and unless you
consider yourself a real expert, don't bother to try and make it work.

============================ VTVZ Bank Format =============================

VTVZ is a mixed type bank. The first four words are integers that give an
overview of the bank. The individual vertex information is grouped in blocks
of NWDV words.  The blocks of NWDV words are sequential with the 'best' vertex
in the first block. The order is such that all 'primary' vertices come before
any 'secondary' vertices. Within these two groupings, vertices with more
associated hits are first. The total number of vertices NVERT is given by
(NWORD-4)/NWDV. Currently NWDV is 4 or 5 depending on whether CTC t0
information has been added to the bank.

Bank             Data
Location         Type     Description                           bits
----------------------------------------------------------------------
INDDAT            I*4    Number of words in header plus the words in
                         the vertex blocks:  NWORD = (LVTVZ*NVTVZ+4)
INDDAT + 1        I*4    Num. of vertices classified as primary
INDDAT + 2        I*4    Num. of words per vertex:  LVTVZ
INDDAT + 3        I*4    Status of CTC data		[1]
			 0: No CTC data present
			 1: Bank expanded, but no beam position present
			 2: Beam position is from a  CTC measurement
			 3: Beam position is from an SVX measurement

INDDAT + 4        I*4    History/hits/segs Word Vertex 1
                           Number of hits                        0:11
                           Number of segments			12:21
INDDAT + 5        I*4    Classification word Vertex 1
INDDAT + 6        R*4    Z postion Vertex 1 (cm)
INDDAT + 7        R*4    Z Rms Vertex 1 (cm)
INDDAT + 8  .     I*4    CTC t0, in 0.01 nsec bins	[1,2]	 0:15
  .                 .             .                               .
  .                 .             .                               .
INDDAT+LVTVZ*n+4  I*4    History/hits/segs Vertex n+1
INDDAT+LVTVZ*n+5  I*4    Classification Word Vertex n+1
INDDAT+LVTVZ*n+6  R*4    Z postion Vertex n+1
INDDAT+LVTVZ*n+7  R*4    Z Rms Vertex n+1
INDDAT+LVTVZ*n+8  I*4    CTC t0 Vertex n+1		[1,2]
  .                 .             .
  .                 .             .
INDDAT+NWORD      I*4    CTC beam x position info	[1,3]
			 X position at Z=0, 1 micron bins	 0:15
			 dX/dz, 1 micron/100cm bins		16:31
INDDAT+NWORD+1    I*4    CTC beam y position info	[1,3]
			 Y position at Z=0, 1 micron bins	 0:15
			 dY/dz, 1 micron/100cm bins		16:31
----------------------------------------------------------------------
Notes

 1. If the "CTC status" word is zero, the t0 and beam position words are not
    present.

 2. The CTC t0 word, when present, is a signed I*2 integer stored in the first
    16 bits giving t0 in hundredths of a nanosecond. t0 for vertex N is easily
    extracted by
      $$include 'C$INC:VTCAUX.INC'
      $$include 'C$INC:TRKIBMD.INC'
		REAL t0
                TMPI4 = IW(IVTVZ + LVTVZ*(N-1) + 8 )
                t0 = .01 * TMPI2L
 3. Since the beam line fit is unpacked to CTCALB.INC by TREVIN, there is little
    need to unpack it directly. But if you wish, you can use a procedure
    similar to above:
      $$include 'C$INC:VTCAUX.INC'
      $$include 'C$TRK:TRKIBMD.INC'
                TMPI4 = IW(IVTVZ+IW(IVTVZ))
                X0 = 1.E-4 * TMPI2L
                dXdZ = 1.E-6 * TMPI2H
                TMPI4 = IW(IVTVZ+IW(IVTVZ)+1)
                Y0 = 1.E-4 * TMPI2L
                dYdZ = 1.E-6 * TMPI2H

========================== Vertex Classification ========================== 

The classification word is positive for a vertex that is classified as primary.
In general, the larger the absolute value of the classification word, the
better the quality of the vertex. Only vertices with at least 2 segments are
considered. Segments with |Z0|>150cm or estimated error >2cm are not used. The
number of hits must be greater than 24 unless it is only one vertex for which
there is no restriction. The forward and backward directions are defined as the
cones with |COTAN|>0.37.

  VERTEX CLASSIFICATION WORD:

    CLASS   Definition                  NSEGS       NHITS           ASYM
    -----------------------------------------------------------------------
     7      isolated vertex             =2      or  <=48

     8      low multiplicity vertex     2< <=5  and >48
                                    or  >2      and 48< <=72

     5      asymmetrical vertex         >5     and  72< <180    and >=0.7
            (beam-gas vertex)

    10      marginal vertex             >5     and  72< <180    and <0.7
                                    and ( (NHFORW<20 and FTSEGS<=3)
                                         or (NHBACK<20 and BTSEGS<=3) )

    11      so so beam-beam vertex      >5     and  72< <180    and <0.7
                                    and ( (NHFORW>=20 and FTSEGS>3)
                                         and (NHBACK>=20 and BTSEGS>3) )

    12      good beam-beam vertex                   >180

    -----------------------------------------------------------------------

    FTSEGS and BTSEGS (NHFORW and NHBACK) are numbers of segments (hits) in the
    forward and backward cone, respectively; ASYM is ABS(FTSEGS-BTSEGS)/NSEGS.

The determination of whether a vertex is primary is made with a series of
selection criteria. The criteria can be summarized as follows:

    1) The best vertex in an event is identified as a primary vertex regardless
       of the value of CLASS.

    2) If the vertex is classified as good beam-beam vertex (CLASS=12) or
       as beam-beam vertex (CLASS=11), it is identified as primary vertex.

    3) For the vertices in the categories of CLASS = 5,7,8 and 10, additional
       tests are made to select primary vertices. General requirements are:

         a) A minimum of 4 segments after subtracting duplicates is required.
         b) At least 3 segments in the forward/backward cones.
            (FTSGES+BTSEGS >=3)
         c) If a vertex is too close (<8.0 cm) to a bigger vertex and the size
            is small (NHITS <= 72), it also will not be identified as a primary
            vertex.

       Remaining vertices, depending on the number of associated segments, must
       satisfy the following requirements to be identified as primary:

            NSEGS  Test1    Asym-test
            ---------------------------
               4     x      asym < 0.4
               5     x           < 0.5
               6     x           < 0.55
               7                 < 0.60
               8                 < 0.65
               9                 < 0.7
            >=10
            ---------------------------

            Test Requirements or Definitions:

              o. Test1   : At least one segment in the forward cone
                           and one segment in the backward cone.

              o. Asym    : Asymmetry measure: (ABS(FTSEGS-BTSEGS)) / NSEGS.

    4) Then, if there are more than 2 primary vertices, an additional density
       test is required for the primary vertices except the first 2 best:

        a) If CLASS is 12, no test is required.

        b) If CLASS is 11, DENSITY ( = (NSEGS)/(width(cm) of the cluster))
           must be at least 2.0.

        c) If CLASS is <=10, DENSITY ( = (NSEGS+2)/(width(cm) of the cluster))
           must be at least 2.0.