This is hippo.h in view mode; [Download] [Up]
/*
* hippo.h - histogramming package in C.
* originally by jonas karlsson, at SLAC, August 1990
* much modified since by Gravina, Kunz, Pavel, Rensing
*
* Copyright (C) 1991 The Board of Trustees of The Leland Stanford
* Junior University. All Rights Reserved.
*
* $Id: hippo.h,v 5.0.2.1 1993/12/15 22:45:45 mfg Exp $
*/
#ifndef _HIPPO_H_ /* only include once */
#define _HIPPO_H_
#ifdef __cplusplus /* do not leave open across includes */
extern "C" { /* for C++ V2.0 */
#endif
#ifdef THINK_C
#define const
#define malloc(A) malloc((size_t)(A))
#define realloc(A,B) realloc((A),(size_t)(B))
#endif
/* for IBM AIX workstations */
#if defined(_IBMR2)
#ifndef _BSD
#define __NO__BSD__
#define _BSD 1
#endif
#ifndef _ALL_SOURCE
#define __NO__ALL__SOURCE__
#define _ALL_SOURCE
#endif
#include <sys/types.h>
#ifdef __NO__BSD__
#undef _BSD
#endif
#ifdef __NO__ALL__SOURCE__
#undef _ALL_SOURCE
#endif
#endif
#include <stdarg.h> /* needed for variable arguments */
#include <stdio.h> /* needed for FILE definition */
/*
* pick up the RPC header
*/
#ifdef sgi
#include <sys/types.h>
#include <sys/socket.h>
#endif
#ifdef VM
#include <rpc.h>
#else
#if defined(_IBMR2) || defined(VAXC)
#define malloc old_malloc
#endif
#ifdef THINK_C
#include "rpctypes.h"
#include "rpcxdr.h"
#else
#include <rpc/rpc.h>
#endif
#if defined(_IBMR2) || defined(VAXC)
#undef malloc
#endif
#endif
#if !defined(__STDC__) && !defined(sgi)
#define const
#endif
/*
* for VMS, add noshare to externals so hippo can be sharable library
*/
#ifdef VMS
#define GLOB_QUAL noshare
#else
#define GLOB_QUAL
#endif
#define HIPPO_H_RCSID "$Id: hippo.h,v 5.0.2.1 1993/12/15 22:45:45 mfg Exp $"
/*
* enum types for options
*/
/*
* graphtype - type of plot
* SCATTERPLOT - 2D scatter plot
* LEGOPLOT - 2D binned Lego plot
* COLORPLOT - 2D binned grayscale/colorscale plot
* If drawtype COLOR bit is set, tries to use color scale
* XYPLOT - Plot of y versus x
* STRIPCHART - Like XYPLOT, but ntuple is considered as circular buffer,
* start is tuple with smallest x value.
* HISTOGRAM - 1D binned histogram
* THREEDSCATTER - 3D scatter plot
*/
typedef enum { SCATTERPLOT, LEGOPLOT, COLORPLOT, XYPLOT,
STRIPCHART, HISTOGRAM, THREEDSCATTER } graphtype_t;
/*
* drawtype - drawing options
* BOX - for HISTOGRAM, draw the histogram box-type line
* POINT - draw points
* LINE - connect points with straight lines
* ERRBAR - plot error bars when appropriate
* COLOR - for COLORPLOT, try to use full color spectrum
*/
typedef enum {
NONE = 0, BOX = 1, POINT = 2, LINE = 4, ERRBAR = 8, COLOR = 16
} drawtype_t;
/*
* plot drivers
* NEXT - NeXT Display PostScript and NeXT library calls
* UNIXPLOT - device-independent UNIXPlot calls
* LPR - line printer; same as calling h_print
* XIVPLOT - Interviews X-windows calls
* MAC - Macintosh QuickDraw
* X11PLOT - basic X-windows (R4) driver
* PSPLOT - PostScript to file
* EPSPLOT - EPS to file (same as PSPLOT for now)
*/
typedef enum { NEXT, UNIXPLOT, LPR, XIVPLOT, MAC, X11PLOT,
PSPLOT, EPSPLOT } plotdrvr_t;
typedef enum { SOLID, DASH, DOT, DOTDASH, LS_INVISIBLE } linestyle_t;
typedef enum { TRI1, TRI2, TRI3, TRI4, SQUARE, SOLIDSQUARE, DIA1, DIA2,
CIRC1, CIRC2, TIMES, PLUS } plotsymbol_t;
typedef enum { XAXIS, YAXIS, ZAXIS, WEIGHT, XERROR, YERROR } binding_t;
/*
* plot locations - used for axis labels and ticks.
*/
typedef enum { PLOTLEFT=1, PLOTRIGHT=2, LEFTRIGHT=3,
PLOTTOP=4, PLOTBOTTOM=8, TOPBOTTOM=12 } plotloc_t;
/*
* structure definitions.
*/
#ifdef VM
#include "hshrtnm.h"
#endif
#include "hstruct.h"
/*-----------------------------------------------------------------------*/
/*
* Function Prototypes
*/
/*
* ----------- ntuple functions -----------------
*/
/*
* h_new - returns a new ntuple, with ndim dimensions.
* returns NULL on error.
*/
ntuple h_new(int ndim);
/*
* h_freeNt - frees all memory associated with the n-tuple.
* returns 0.
*/
int h_freeNt( ntuple nt );
/*
* h_clrNt - Clear all data points from the n-tuple,
* and reallocs memory for data to default size.
* returns -1 on error, 0 on success.
*/
int h_clrNt( ntuple nt );
/*
* h_fill - add one entry to the end of the ntuple data list.
* There must be ndim float parameters after the first parameter,
* where ndim is the ntuple's dimension.
*
* h_arrayFill - add an n-tuple, getting data from an array
*
* return -1 on error, 0 otherwise.
*/
int h_fill(ntuple nt, ...);
int h_arrayFill(ntuple nt, float *data );
/*
* h_setNtTitle - set title of ntuple data set.
* h_setNtLabel - set label on ntuple dimension dim.
* h_setAllNtLabels - set labels on all ntuple dimensions.
* There must be ndim strings in the call.
*
* return 0 if successful, -1 if failed.
*/
int h_setNtTitle( ntuple nt, const char *title );
int h_setNtLabel( ntuple nt, int dim, const char *label );
int h_setAllNtLabels( ntuple nt, ... );
/*
* h_getNtDim - return the dimension of the n-tuple.
*/
#define h_getNtDim(nt) ((const int) (nt)->ndim)
/*
* h_getNtTitle - return the title of the ntuple.
* h_getNtLabel - return the label associated with dimension dim of
* the ntuple. Returns NULL on error.
*/
#define h_getNtTitle(nt) ((const char *)(nt)->title)
const char *h_getNtLabel( ntuple nt, int dim );
/*
* h_getNtNdata - return number of ntuples in nt.
* returns -1 on error.
*/
#define h_getNtNdata(nt) ((const int) (nt)->ndata)
/*
* h_getNtAllData - return pointer to all the data in specified ntuple.
* Tuples are stored consecutively in the array, first all
* columns for the first row, then subsequent rows.
* Do NOT attempt to modify the data.
*/
#define h_getNtAllData(nt) ((const float **) (nt)->data)
/*
* h_getNtData - returns a particular row in the data.
* The first row is numbered 0.
* i_nt is the row of the ntuple wanted. f is the array in which
* to place the data, and fSize is the length of f. If f is
* NULL or too small, h_getNtData will malloc/realloc f to be
* the correct size. The current pointer to the data array
* is returned by the function (ie. if f is moved, its new
* location is returned).
* This data is a copy of the data in the ntuple and it is
* therefore the user's responsibility to free the memory
* when done.
* Returns NULL on error.
*/
float *h_getNtData( ntuple nt, int i_nt, float *f, int *fSize );
/*
* h_getNtColumn - get array data for a particular variable in ntuple.
* Use h_getNtNdata as number of points returned.
* Do NOT attempt to modify this data.
* Returns NULL on error.
*/
#define h_getNtColumn(nt,i) ((float *) (nt)->data[i])
/*
* h_getNtLow - returns array of lower limits of each column of the ntuple.
* ie. f = h_getNtLow( nt); then
* f[1] is the lowest value of the 2nd variable of the ntuple.
*
* h_getNtHigh - returns array of upper limits.
*
* Do NOT attempt to modify the data.
*/
#define h_getNtHigh(nt) ((const float *) (nt)->nhigh)
#define h_getNtLow(nt) ((const float *) (nt)->nlow)
/*
* h_replData - replace the specified row in the ntuple.
* i_nt, which is the index of the row to replace (starting from 0),
* must be within the existing range of data.
* There must be ndim floats after i_nt, where ndim is the dimension
* of the ntuple. After calling this routine, the low/high limits of
* the ntuple dimensions may be wrong. The flag extremeBad will be set.
*
* h_arrayReplData - replace specified tuple from a float array.
* Array must contain ndim floats.
*
* Return -1 on error, 0 otherwise.
*/
int h_arrayReplData( ntuple nt, int i_nt, float *data );
int h_replData( ntuple nt, int i_nt, ... );
/*
* h_getExtremeBad - get flag extremeBad from ntuple.
* extremeBad is set if the upper/lower limits may be wrong.
*/
#define h_getExtremeBad(nt) ((nt)->extremeBad)
/*
* h_findExtreme - find the minimum and maximum of each column of
* the ntuple. Clears the flag extremeBad.
*/
int h_findExtreme( ntuple nt );
/*
* h_addColumn - add a column to the ntuple.
* This routine creates a new column on the end of the ntuple. On
* successful completion, it returns the index of the new column;
* otherwise, it returns -1.
* It is the user's responsibility to fill the new column and give
* it a sensible label (there is a default label).
* The flag extremeBad is set to indicate the limits may be wrong.
*/
int h_addColumn( ntuple nt );
/*
* h_ntSize - the number of bytes needed to write out a given ntuple.
* Some slop is included.
*/
int h_ntSize( ntuple nt );
/*
* ---------- Display routines -------------------------------------
*/
/*
* h_newDisp - creates a new display of the type specified.
* Sets most fields of the display to reasonable defaults.
*
* Returns NULL on error.
*/
display h_newDisp(graphtype_t type);
/*
* h_copyDisp - create a new display and copy the old one into it.
*
* Returns NULL on error.
*/
display h_copyDisp(display olddisp);
/*
* h_freeDisp - free all memory accosiated with display.
* Returns 0.
*/
int h_freeDisp( display disp );
/*
* h_dispSize - calculate the number of bytes needed to
* write out a given display. Some slop is included.
*/
int h_dispSize( display disp );
/*
* h_setDispType - sets the plot type.
* Returns -1 on error.
*
* h_getDispType - fetch the current plot type.
*/
int h_setDispType( display disp, graphtype_t type);
#define h_getDispType(d) ((d)->graphtype)
/*
* h_setDrawType - set the what should be drawn for the data;
* eg. histogram bars, points...
*
* h_orDrawType - do a logical OR of draw bits; means the
* given options will be added to list of things
* to plot.
* Return -1 on error.
*
* h_getDrawType - fetch the current draw type.
*/
int h_setDrawType(display disp, drawtype_t type);
int h_orDrawType(display disp, drawtype_t type);
#define h_getDrawType(d) ((d)->drawtype)
/*
* h_bindNtuple - binds a ntuple to a display
* Returns -1 on error.
*
* h_getNtuple - fetch the currently bound ntuple.
*/
int h_bindNtuple(display disp, ntuple nt);
#define h_getNtuple(d) ((d)->tuple)
/*
* h_setNtByRef - set/clear flag to indicate ntuple is access
* "by reference". This means that when written out, a display with
* an ntuple "by reference" will NOT cause that ntuple to be
* written out as well. When read back in, it is the application's
* responsibility to re-establish the connection between the
* display and its ntuple.
* The third argument is a string which should indicate where the
* ntuple comes from, ie. which file. This is intended to help
* with portability.
*
* h_getNtByRef - fetch the "by reference" flag.
*
* h_getNtFile - get the filename for the ntuple if by reference
*/
int h_setNtByRef(display disp, int flag, const char *filename);
#define h_getNtByRef(d) ((d)->flags.ntByReference)
#define h_getNtFile(d) ((d)->ntFile)
/*
* h_bind - binds the ntuple column dataDim to the display quantity.
* The ntuple columns are numbered starting from 0.
* Returns -1 on error, 0 otherwise.
*
* h_getBinding - fetch the current binding in the display.
*/
int h_bind(display disp, binding_t q, int dataDim);
int h_getBinding( display disp, binding_t q );
/*
* h_bindMany - binds specified number (n) of plot variables to
* n-tuple variables. Variable arguments must come in pairs
* of binding_t q, int dataDim.
* Returns -1 on error, 0 otherwise.
*/
int h_bindMany(display disp, int n, ...);
/*
* h_setBinWidth - sets the width of bins along the specified axis.
* The axis' upper limit is adjusted to be consistent with the lower
* limit, the given bin width, and the number of bins.
* Returns -1 on error, 0 otherwise.
*
* h_getBinWidth - fetch the bin width for the specifed axis.
*/
int h_setBinWidth(display disp, binding_t axis, float width);
float h_getBinWidth( display disp, binding_t axis );
/*
* h_setBinNum - set the number of bins along the specified axis.
* Returns -1 on error, 0 otherwise.
*
* h_getBinNum - return number of bins along the axis.
* Return -1 on error.
*/
int h_setBinNum(display disp, binding_t axis, int n);
int h_getBinNum( display disp, binding_t axis );
/*
* h_setLogAxis - switch logarithmic axes (base 10) on or off.
* Log axis does not have any meaning for a binned axis.
*
* h_getLogAxis - fetch log axis flag for specified axis.
*/
int h_setLogAxis(display disp, binding_t axis, int onOff);
int h_getLogAxis(display disp, binding_t axis);
/*
* h_setAutoScale - turn on or off autoscaling for an axis.
*
* h_getAutoScale - fetch autoscale flag for an axis.
*
* h_autoScale - force autoscaling immediately for axes with flag set.
*/
int h_setAutoScale(display disp, binding_t axis, int onOff);
int h_getAutoScale(display disp, binding_t axis);
void h_autoScale( display );
/*
* h_setRange - set the lower and upper limit along an axis.
* Returns -1 on error, 0 otherwise.
*
* h_getRange - fetch the lower and upper limits along an axis.
* If the axis is autoscaled, this will be the numbers used
* once an h_plot (or h_bin for a binned axis) has been done.
*/
int h_setRange(display disp, binding_t axis, float low, float high);
int h_getRange(display disp, binding_t axis, float *low, float *high);
/*
* h_setTitle - sets the title of the display.
* Possible printf format-like strings which pick up quantities from
* the ntuple are:
* %t the ntuple's title
* %x the label for the ntuple column bound to the x-axis
* %y " " " y-axis
* %z " " " z-axis
* %w " " " weight
* %dx the width of bins along the x-axis
* %dy " " y-axis
*
* Returns -1 on error, 0 otherwise.
*
* h_getTitle - fetch the display's title.
*/
int h_setTitle(display disp, const char *title);
#define h_getTitle(d) ((const char *)(d)->title)
/*
* h_setAxisLabel - set the label for the specified axis.
* The format-like strings discussed for h_setTitle are valid.
* Returns -1 on error, 0 otherwise.
*
* h_getAxisLabel - return pointers to label for specified axis.
* Returns NULL on error.
*/
int h_setAxisLabel( display disp, binding_t axis, const char *label );
const char *h_getAxisLabel( display disp, binding_t axis );
/*
* h_expandLabel - Function to expand labels which include hippo
* "format" specifiers. The valid "format" symbols are:
* %t - title of the ntuple
* %x - label of ntuple column bound to x-axis
* %y - label of ntuple column bound to y-axis
* %z - label of ntuple column bound to z-axis
* %w - label of ntuple column bound to weight
* %ex - label of ntuple column bound to x error
* %ey - label of ntuple column bound to y error
* %dx - width of bins in x-axis direction
* %dy - width of bins in y-axis direction
*
* dest is destination string, src is source string, max is maximum number
* of characters in dest, and disp is the relevant display.
* Returns pointer to dest.
*/
char *h_expandLabel( char *dest, const char *src, int max, display disp );
/*
* h_setPlotSymbol - set the plot symbol used when plotting the
* data. Plot symbols can be one of those defined by plotsymbol_t
*
* h_getPlotSymbol - fetch the current plot symbol.
*/
#define h_setPlotSym(d,s) ((d)->plotSymbol = (s))
#define h_getPlotSym(d) ((d)->plotSymbol)
/*
* h_setSymSize - set the size of the plot symbol. Size is in points.
* (ie. 1/72 inch)
*
* h_getSymSize - fetch the current plot symbol size.
*/
#define h_setSymSize(d,s) ((d)->symbolSize = (s))
#define h_getSymSize(d) ((d)->symbolSize)
/*
* h_setLineStyle - set the line style used when connecting points.
* Line styles are defined by linestyle_t above.
*
* h_getLineStyle - fetch the current line style.
*/
#define h_setLineStyle(d,s) ((d)->lineStyle = (s))
#define h_getLineStyle(d) ((d)->lineStyle)
/*
*----------- Display actions ----------------------
*/
/*
* h_plot - Plots the ntuple using the current plot driver.
*
* The optional parameters are used by some plot drivers:
* eg. XPLOT passes the painter and canvas as optional parameters.
*/
int h_plot(display disp, ...);
/*
* h_setPlotDrvr - select device for plotting.
* Valid plot drivers are specified by the enum type plotdrvr_t.
* Optional parameters are used by:
* UNIXPLOT - optional parameter a C FILE pointer, to which
* output is sent (does not work at present).
*/
int h_setPlotDrvr( plotdrvr_t drvr, ... );
/*
* h_endPlotDrvr - do any cleanup needed before a driver is closed
*/
int h_endPlotDrvr( void );
/*
* h_endPage - end a page for a plot driver.
*/
int h_endPage( void );
/*
* h_print - Prints an ASCII representation of the histogram to stdout.
* h_fprint - h_print to given file.
*/
void h_fprint(display disp, FILE *file);
#define h_print(x) h_fprint(x,stdout)
/*
* h_bin - perform binning on the display, but don't plot.
* Returns -1 on error, 0 otherwise
*/
int h_bin(display disp);
/*
* h_cum - accumulate the bins of a display directly, not through an
* ntuple. The display must be a binned plot, ie. HISTOGRAM, COLORPLOT,
* or LEGOPLOT. For HISTOGRAM, there are two arguments: the "x" value
* and the weight. For COLORPLOT and LEGOPLOT, there are three arguments:
* x, y, and weight (in that order).
*
* h_cum automatically sets the bins to be fixed, and will not work if
* there is an ntuple bound to the display.
*/
int h_cum(display disp, double x, double yOrW, ... );
/*
* h_getBins - get a pointer to the array of bin values.
* h_getVariance - get a pointer to the array of bin variances (ie. error^2)
* h_getBinNum will give number of data points.
*
* Do NOT attempt to modify this data.
*/
#define h_getBins(d) ((const float *) (d)->bins.data)
#define h_getVariance(d) ((const float *) (d)->bins.variance)
#define h_getXMoments(d) ((const float *) (d)->bins.xAxis.moments)
#define h_getYMoments(d) ((const float *) (d)->bins.yAxis.moments)
/*
* h_getBinExtreme - get minimum and maximum bin value.
* return 0 if normal, -1 on error.
*/
int h_getBinExtreme( display disp, float *min, float *max );
/*
* h_getTotal - get the (weighted) sums of events inside/outside
* the plot. i is for x-axis, j for y-axis. 0 means below lower limit,
* 1 is inside plot's range, 2 is above range.
*/
#define h_getTotal(d,i,j) ((const float) (d)->bins.totals[i][j])
/*
* h_setDrawTitles - set/clear flag to plot the display title and labels
* during h_plot.
*
* h_getDrawTitles - fetch the flag indicating whether to draw titles.
*/
#define h_setDrawTitles(d,f) ((d)->flags.drawTitles = (f))
#define h_getDrawTitles(d) ((d)->flags.drawTitles)
/*
* h_setDrawAxes - set/clear flag to plot the display axes during h_plot
* (w/ ticks and scales).
*
* h_getDrawAxes - fetch the flag indicating whether to draw the axes.
*/
#define h_setDrawAxes(d,f) ((d)->flags.drawAxes = (f))
#define h_getDrawAxes(d) ((d)->flags.drawAxes)
/*
* h_setFixedBins - set/clear flag to indicate bins are fixed.
* This means that h_bin and h_plot will not preform any rebinning
* and the bin contents will be written on output.
*
* h_getFixedBins - fetch the flag indicating whether bins are fixed.
*/
#define h_setFixedBins(d,f) ((d)->bins.flags.fixed = (f))
#define h_getFixedBins(d) ((d)->bins.flags.fixed)
/*
*----------- auxiliary functions ------------------
*/
/*
* h_binVal - returns the value of the bin specified by the arguments
* There must be as many arguments as the dimensionality of the display.
* (1, 2, or 3).
* Returns -1 on error.
*/
float h_binVal(display disp, ...);
/*
* h_ptToBin - returns the bin number containing 'f' on the axis 'axis'.
* Returns -1 on error.
*/
int h_ptToBin(display disp, float f, binding_t axis);
/*
* h_setDrawRect - set the rectangle in which the plot is drawn.
* Units are points (1/72 inch).
*
* h_getDrawRect - get a copy of the rectangle which defines the
* location and size of the plot.
*
* Return -1 on error, 0 otherwise.
*/
int h_setDrawRect(display disp, rectangle *rect );
int h_getDrawRect(display disp, rectangle *rect );
/*
* h_setMarginRect - set the rectangle which defines the location of the
* axes. Units are points (1/72 inch). The margin rectangle is in
* the same co-ordinates as the draw rectangle.
*
* h_getMarginRect - get a copy of the rectangle which defines the
* location of the axes.
*
* Return -1 on error, 0 otherwise.
*/
int h_setMarginRect(display disp, rectangle *rect );
int h_getMarginRect(display disp, rectangle *rect );
/*
* h_wPtTogPt - convert a number in window co-ordinates (ie. same as
* draw rectangle) to graph co-ordinates (ie. same a axis scale).
*
* h_gPtTowPt - convert from graph to window co-ordinates.
*/
float h_wPtTogPt(display disp, float wPt, binding_t axis);
float h_gPtTowPt(display disp, float gPt, binding_t axis);
/*
* set the dirty flag in a display.
* The bins of a display are dirty if a quantity which affects the bins
* has been changed.
* Please, think 5 times before using this routine. It should not be used
* in hippo code (the display should know automatically if it is dirty).
* The only valid use is when a user cut is changed.
*/
#define h_setDirty(d) ((d)->bins.flags.dirty = 1)
/*
* functions dealing with axis frill location.
* "scale" refers to the number next to the tick marks.
*/
int h_setLabelLocation( display disp, binding_t axis, plotloc_t location );
int h_setTickLocation( display disp, binding_t axis, plotloc_t location );
int h_setScaleLocation( display disp, binding_t axis, plotloc_t location );
plotloc_t h_getLabelLocation( display disp, binding_t axis );
plotloc_t h_getTickLocation( display disp, binding_t axis );
plotloc_t h_getScaleLocation( display disp, binding_t axis );
int h_setScaleFontSize( display disp, binding_t axis, float fontSize );
float h_getScaleFontSize( display disp, binding_t axis );
int h_setTickLength( display disp, binding_t axis, float f );
float h_getTickLength( display disp, binding_t axis );
/*
* Set/get 3D plot angles and viewer distance. Angles are degrees.
*/
int h_set3DTheta(display disp, float angle);
float h_get3DTheta(display disp);
int h_set3DPhi(display disp, float angle);
float h_get3DPhi(display disp);
int h_set3DDist(display disp, float dist);
float h_get3DDist(display disp);
/*
* Set/clear 3D plot type
*/
int h_set3DCube(display disp, int flag);
int h_set3DWireFrame(display disp, int flag);
int h_set3DFill(display disp, int flag);
int h_set3DMesh(display disp, int flag);
/*
*----------- drawing functions ---------------
*/
/*
* h_shade - shade a region of the plot along the x-axis. The shaded region
* runs from the lower to the upper limits along the y-axis and
* from low to high along the x-axis, but does not go past the
* x-axis' limits.
*/
int h_shade(display disp, float low, float high);
/*
* --------------- IO functions ----------------------------------
*/
/*
* h_fileParse - create an ntuple from a text file.
* If oldnt is NULL, will create a new ntuple; else, will append
* data to the ntuple specified.
* If verbose is true, will print lots of messages.
* Returns the ntuple it created or modified.
*
*/
ntuple h_fileParse(FILE* ifile, ntuple oldnt, int verbose);
/*
* h_nt2text - write an ntuple as a text file (suitable for h_fileParse).
*/
int h_nt2text( FILE *outfile, ntuple nt );
/*
* h_writeStream, h_readStream - write/read list of displays and
* ntuple to a file stream. Both lists of displays and ntuples
* are NULL terminated.
*
* On read, pass in a pointer to pointer to a display or ntuple,
* and routine allocates space for list.
*
* eg. FILE *myfile;
* display *d_list;
* ntuple *nt_list;
* h_readStream( myfile, &d_list, &nt_list );
*
* On write, either list may be a NULL, meaning you don't care.
* The write routine adds any ntuples used by displays in the list,
* but which you didn't specify, to the list you do specify.
*
* eg. h_writeStream( myfile, d_list, NULL);
* writes out all the displays in d_list and all the ntuples
* that those displays refer to.
*
* Returns -1 on error, 0 otherwise.
*/
int h_writeStream(FILE *outfile, display dlist[], ntuple ntlist[] );
int h_readStream(FILE *infile, display **dlist, ntuple **ntlist );
/*
* h_write, h_read - write/read displays and ntuples from named file.
* See h_writeStream for more information.
*/
int h_write(const char *filenm, display dlist[], ntuple ntlist[] );
int h_read(const char *filenm, display **dlist, ntuple **ntlist );
/*
* h_writeMem, h_readMem - write/read displays and ntuples from
* provided memory buffer.
* len is length of buffer in bytes.
*
* See h_writeStream for more information.
*/
int h_writeMem(char *buf, int len, display dlist[], ntuple ntlist[] );
int h_readMem(char *buf, int len, display **dlist, ntuple **ntlist );
/*
* h_writeXDR, h_readXDR - write/read displays and ntuples from
* provided XDR stream. XDR stream should be opened
* with appropriate ENCODE/DECODE code.
*
* See h_writeStream for more information.
*/
int h_writeXDR(XDR *xdrs, display dlist[], ntuple ntlist[] );
int h_readXDR(XDR *xdrs, display **dlist, ntuple **ntlist );
/*
* h_isHippoFile - test whether file is a hippo binary data file.
*/
int h_isHippoFile( const char *filename );
/*
* ---------------- Cuts and Plot Functions --------------------
*/
/*
* h_funcReg - register a function in the "registry".
* The registry keeps track of function pointers and names
* so that they can be reconnected after save/restore of a file.
*/
#define h_funcReg(x) h_func_reg( #x, x )
int h_func_reg(const char *fn, void *func);
/*
* h_addCut - adds a hippo-supported cut to a display.
* Supported cuts are:
* "h_cut_le", "h_cut_lt", "h_cut_ge", "h_cut_gt",
* "h_cut_inside", "h_cut_in_incl", "h_cut_outside",
* and "h_cut_out_incl".
* The first 4 require 1 parameter, the other 4, 2 parameters.
* When there are 2 parameters, the first is the lesser.
*
* Returns pointer to cut structure, or NULL on error.
*/
func_id h_addCut( display disp, const char *cutfunc, int cut_dim,
double val1, ... );
/*
* h_changeCut - changes the cutting parameters. Requires the func_id
* returned by h_addCut. Requires the same number of parameters as
* h_addCut, depending on the type of cut.
*
* Returns -1 on error.
*/
int h_changeCut( display disp, func_id cut, double val1, ... );
/*
* h_addUserCut - adds a user-supported cut to a display.
* The user passes a function name, a pointer to a parameter block *
* (all doubles), and the size of the parameter block (number of *
* doubles). It is the responsibility of the user to maintain the *
* parameters; if they are changed, one should call h_forceReBin
* (not * necessary if display is not binned) on the display. hippo
* maintains * a pointer to the parameter block, so it should not be
* moved.
*
* Returns func_id or NULL on error.
*/
func_id h_addUserCut( display disp, const char *cutfunc,
double *param_blk, int nParam);
/*
* h_deleteCut removes a cut from a display. Requires func_id returned
* by h_addCut.
* Returns -1 on error.
*/
int h_deleteCut( display disp, func_id cut );
/*
* h_nextCut returns the next func_id used in a display.
* If thiscut equals NULL, it returns the first func_id.
*
* Returns NULL if there are no more cuts.
*/
func_id h_nextCut( display disp, func_id thiscut );
/*
* h_writeNtForDisp - Special function to write out the tuple which
* corresponds with what is being plotted by the display,
* ie. with the cuts applied.
* Returns 0 if successful, -1 if failure.
*/
int h_writeNtForDisp(char *filename, display disp);
/*
* h_addPlotFunc - add a function to be plotted to the display.
* Function is similar to h_addUserCut.
*/
func_id h_addPlotFunc(display disp, const char *plotfunc, double *paramBlk,
int nParam, linestyle_t ls );
/*
* h_nextPlotFunc - traverse the list of plot functions.
* Function is similar to h_nextCut.
*/
func_id h_nextPlotFunc( display disp, func_id thispfunc );
/*
* h_deletePlotFunc - remove a plot function from the list.
* Function is similar to h_deleteCut.
*/
int h_deletePlotFunc( display disp, func_id pfunc );
/*
* h_funcSum - compute the sum of all the functions attached to a
* particular display at a given x. Useful for fitting, etc.
*/
double h_funcSum( display dsp, double x );
/*
* h_setPlotFuncs, h_getPlotFuncs - set/get flag indicating desire to
* plot the individual functions in the list.
*/
#define h_setPlotFuncs(d,i) ((d)->flags.plotFuncs = i)
#define h_getPlotFuncs(d) ((d)->flags.plotFuncs)
/*
* h_setPlotFuncSum, h_getPlotFuncSum - set/get flag indicating desire to
* plot the sum of the functions in the list.
*/
#define h_setPlotFuncSum(d,i) ((d)->flags.plotFuncSum = i)
#define h_getPlotFuncSum(d) ((d)->flags.plotFuncSum)
/*
* h_setFSumLineStyle - set/get the line style used for plotting the sum
* of all the functions.
* Line styles are defined by linestyle_t above.
*/
#define h_setFSumLineStyle(d,s) ((d)->fSumLineStyle = (s))
#define h_getFSumLineStyle(d) ((d)->fSumLineStyle)
/*
* h_setPFuncLineStyle - set/get the line style used for plotting
* a particular function.
* Line styles are defined by linestyle_t above.
*/
#define h_setPFuncLineStyle(f,s) ((f)->lineStyle = (s))
#define h_getPFuncLineStyle(f) ((f)->lineStyle)
/*
* h_fillWithFitData - fill the given ntuple with data from the
* display which is appropriate for fitting. The cuts listed in the
* display are applied. For HISTOGRAMs, XYPLOTs, and STRIPCHARTs,
* all data with the x range is used. For SCATTERPLOTs, COLORPLOTs,
* and LEGOPLOTS, the x and y ranges are checked. For
* THREEDSCATTERs, x, y, and z ranges are checked. The data is
* returned in the ntuple columns in the order:
* x, xerror, y, yerror, [ z, zerror ]
* (the z data is only filled for THREEDSCATTER displays).
*
* Unbinned is a flag that, if true, means that the unbinned data
* is returned.
*
* The user has the responsibility of allocating a 4 column ntuple
* (6 columns for THREEDSCATTER) and is responsible for freeing the
* ntuple when it is not needed. h_fillWithFitData *will* clear the
* ntuple before putting data in.
*/
int h_fillWithFitData( display dsp, ntuple nt, int unbinned );
/*
* function to get xy and scatter plot xy moments, also correlation
*/
void h_getXYMoments (display disp, float *xmoments, float *ymoments, float *r);
#ifdef __cplusplus
} /* for C++ V2.0 */
#endif
#endif /* end of ifndef _HIPPO_H_ */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.