This example generates just 2 histograms. One is a histogram of the data item labels in the data. This is a very useful visualization of the data sources (adcs and tdcs) being used. The other is a histogram of the number of data items in each event.


*trigger
128  
*oned
1   stat   16384    /* for VXI data change 16384 => 65536 */
2   mult   1024

*twod

*vars
*sort

#include < stdio.h >
#include < stdlib.h >


int events;

int init(void)
{
    events=0;
    return 0;
}

/*    This procedure is called once for each good event decoded   */
/*     mult contains the number of data items in the event  */
/*    The gid array contains the label (high 16 bits) part of the item word */
/*    The gdata array contains the data (low 16 bits) part of the item word */

int sortin(void)
{
    int i;
    int group, item;

    events++;

    if ( mult > 0 && mult < 1024 )
    {
        inc1d( MULT, mult );
    }

    for ( i = 0; i < mult; i++ )
    {
        group = gid[i] & 255;
        item = (gid[i] >> 8) & 63;       /* for VXI data change 63 => 255 to handle Q bits */

        inc1d( STAT, (group*64)+item);   /* for VXI data change 64 => 256 */
    }

    return 0;
}

int finish(void) 
{
    printf("\nSorted %d events\n", events);
    return 0;
}