jhplot
Class P1D

java.lang.Object
  extended by jhplot.DrawOptions
      extended by jhplot.P1D

public class P1D
extends DrawOptions

A container to hold data points with 1st and 2nd level errors. The first errors are usully statistical, the second error are systematical. P1D can be used for drawing, manipulation with data etc.


Constructor Summary
P1D(DataHolder dh, int i1, int i2)
          Create P1D data holder from multidimensional data holder.
P1D(DataHolder dh, java.lang.String title, int i1, int i2)
          Create P1D data holder from multidimensional data holder.
P1D(H1D histo)
          Create a P1D container from a histogram.
P1D(H1D histo, boolean binMean)
          Create a P1D container from a histogram.
P1D(H1D histo, boolean binMean, boolean fillXerrors)
          Create a P1D container from a histogram.
P1D(java.lang.String title)
          Construct an empty container with a title
P1D(java.lang.String title, H1D histo)
          Create a P1D container from a histogram.
P1D(java.lang.String title, H1D histo, boolean binMean)
          Create a P1D container from a histogram.
P1D(java.lang.String title, H1D histo, boolean binMean, boolean fillXerrors)
          Create a P1D container from a histogram
P1D(java.lang.String title, java.lang.String sfile)
          Construct a P1D from a file.
 
Method Summary
 void add(double x, double y)
          Adds values of a plot-point pair (X,Y).
 void add(double x, double y, double err)
          Adds the values of a plot-point pair (X,Y).
 void add(double x, double y, double upper, double lower)
          Add values of a plot-point pair (X,Y).
 void add(double x, double y, double left, double right, double upper, double lower)
          Adds the values of a plot-point pair (X,Y).
 void add(double x, double y, double left, double right, double upper, double lower, double left_sys, double right_sys, double upper_sys, double lower_sys)
          Adds the values of a plot-point pair (x,y).
 P1D addAndAverage(P1D[] p1darray)
          Return P1D array with weighted average of several measurements.
 void clear()
          Clear the container
 int dimention()
          Returns the dimention of this P1D holder.
 double[] getArrayX()
          Get array representing X-values
 double[] getArrayXleft()
          Get array representing X-left errors
 double[] getArrayXleftSys()
          Get array representing X-left 2nd level errors
 double[] getArrayXright()
          Get array representing X-right errors
 double[] getArrayXrightSys()
          Get array representing X-right 2nd level errors
 double[] getArrayY()
          Get array representing Y-values
 double[] getArrayYlower()
          Get array representing Y lower errors
 double[] getArrayYlowerSys()
          Get array representing Y lower 2nd level errors
 double[] getArrayYupper()
          Get array representing Y upper errors
 double[] getArrayYupperSys()
          Get array representing Y upper 2nd level errors
 P1D getCopy()
          get a copy of the current holder
 jplot.DataArray getDataArray()
          Return a DataArray container from JPlot
 jplot.LinePars getLinePars()
          get LinePars class which holds graphical attributes
 double getMax(int axis)
          Returns the maximum value in the range.
 double getMin(int axis)
          Returns the minimum value in the range.
 P1D getSys(P1D[] p1darray)
          Return P1D array which contains 2nd level errors (or systematical errors) evaluated from an array of P1D data holders.
 java.lang.String getTitle()
          Get a new title
 double getX(int i)
          Return a specific X-value.
 double getXleft(int i)
          Return a specific left error on X-value.
 double getXleftSys(int i)
          Return a specific left error on X-value (systematical error).
 double getXright(int i)
          Return a specific right error on X-value.
 double getXrightSys(int i)
          Return a specific right error on X-value (systematical error).
 double getY(int i)
          Return a specific Y-value.
 double getYlower(int i)
          Return a specific lower error on Y-value.
 double getYlowerSys(int i)
          Return a specific total lower error on Y-value.
 double getYupper(int i)
          Return a specific upper error on Y-value.
 double getYupperSys(int i)
          Return a specific systematical upper error on Y-value.
 double mean()
          Returm the mean value
 P1D merge(P1D a)
          Merge two P1D containers
 P1D move(java.lang.String what, java.lang.String how)
          Transform a P1D data holder to some function with error propagation (for both levels)
 P1D oper(double scale)
          Scale P1D container
 P1D oper(int scale)
          Scale P1D container by keeping the original title
 P1D oper(P1D a, java.lang.String what)
          Operations on P1D container: add, subtract, multiply, divide.
 P1D oper(P1D a, java.lang.String title, java.lang.String what)
          Operations on P1D conatiner: add, subtract, multiply, divide.
 P1D oper(P1D a, java.lang.String title, java.lang.String what, java.lang.String how, P1D corr)
          Operations on P1D container: add, subtract, multiply, divide.
 P1D oper(java.lang.String title, double scale)
          Scale P1D container
 P1D oper(java.lang.String title, int scale)
          Scale P1D container
 void print()
          Print a P1D container on the screen
 void set(int i, double x, double y)
          Sets the values of a plot-point pair (X,Y).
 void set(int i, double x, double y, double upper, double lower)
          Sets the values of a plot-point pair (x,y).
 void set(int i, double x, double y, double left, double right, double upper, double lower)
          Sets the values of a plot-point pair (x,y).
 void set(int i, double x, double y, double left, double right, double upper, double lower, double left_sys, double right_sys, double upper_sys, double lower_sys)
          Sets the values of a plot-point pair (x,y).
 void setDataArray(jplot.DataArray data)
          Set data in a form of DataArray
 void setLinePars(jplot.LinePars pnew)
          Sets LinePars class for graphical attributes
 void setTitle(java.lang.String title)
          Set a new title
 int size()
          Return the length of the data vector.
 void toFile(java.lang.String name)
          Write a P1D to an external file.
 void toFileAsLatex(java.lang.String name, java.text.DecimalFormat dx, java.text.DecimalFormat dy)
          Write a File in form of LaTeX table from values in the container P1D
 void toTable()
          Print the P1D container to a Table in a separate Frame.
 void toTable(boolean format)
          Print the P1D container to a Table in a separate Frame.
 
Methods inherited from class jhplot.DrawOptions
getBinWidth, getDrawOption, getDrawOptions, getLegend, getNameX, getNameY, getNameZ, getType, printDrawOptions, printDrawOptions, setBinWidth, setColor, setDrawLine, setDrawOption, setDrawSymbol, setErr, setErrAll, setErrColor, setErrColorX, setErrColorY, setErrFill, setErrFillColor, setErrFillColor, setErrSys, setErrSysFill, setErrSysFillColor, setErrSysFillColor, setErrSysX, setErrSysY, setErrX, setErrY, setFill, setFillColor, setFillColorTransparency, setGraphStyle, setLegend, setNameX, setNameY, setNameZ, setPenDash, setPenDash, setPenWidth, setPenWidthErr, setPenWidthErrSys, setStyle, setSymbol, setSymbolSize, setType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P1D

public P1D(java.lang.String title)
Construct an empty container with a title

Parameters:
title - New title

P1D

public P1D(DataHolder dh,
           java.lang.String title,
           int i1,
           int i2)
Create P1D data holder from multidimensional data holder. You should specify a slice which you want to export (X,Y) pair of P1D

Parameters:
dh - Input data container
title - New title
i1 - Index of the first column
i2 - Index of the second column

P1D

public P1D(DataHolder dh,
           int i1,
           int i2)
Create P1D data holder from multidimensional data holder. You should specify a slice which you want to export (X,Y) pair of P1D. The title is default

Parameters:
dh - Input data container
i1 - Index of the first column
i2 - Index of the second column

P1D

public P1D(java.lang.String title,
           java.lang.String sfile)
Construct a P1D from a file. The file should contain 2, or 4, or 6, or 10 columns: 1) x,y: data without any errors 2) x,y, y(upper), y(lower) - data with 1st level errors on Y 3) x,y, x(left), x(right), y(upper), y(lower) - data with 1st level errors on X and Y 4) x,y, x(left), x(right), y(upper), y(lower), x(leftSys), x(rightSys), y(upperSys), y(lowerSys) - data with X and Y and 1st and 2nd level errors

Parameters:
title - Title of the container
sfile - File name with input

P1D

public P1D(java.lang.String title,
           H1D histo,
           boolean binMean,
           boolean fillXerrors)
Create a P1D container from a histogram

Parameters:
title - New title
histo - Imported histogram
binMean - If true, X values are put to the mean values in each bin. If false, X is just a center of the histogram bin
fillXerrors - If true, errors are set to X values (half of the bin width) If false, errors on X are set to zero

P1D

public P1D(H1D histo,
           boolean binMean,
           boolean fillXerrors)
Create a P1D container from a histogram. The title is set to the histogram title.

Parameters:
histo - Imported histogram
binMean - If true, X values are put to the mean values in each bin. If false, X is just a center of the histogram bin
fillXerrors - If true, errors are set to X values (half of the bin width) If false, errors on X are set to zero

P1D

public P1D(java.lang.String title,
           H1D histo,
           boolean binMean)
Create a P1D container from a histogram. The title is set to the histogram title. Show errors on X as bin width x 0.5

Parameters:
title - New title
histo - Imported histogram
binMean - If true, X values are put to the mean values in each bin. If false, X is just a center of the histogram bin

P1D

public P1D(H1D histo,
           boolean binMean)
Create a P1D container from a histogram. The title is set to the histogram title. Show errors on X as bin width x 0.5

Parameters:
histo - Imported histogram
binMean - If true, X values are put to the mean values in each bin. If false, X is just a center of the histogram bin

P1D

public P1D(H1D histo)
Create a P1D container from a histogram. The title is set to the histogram title. Show errors on X as bin width x 0.5. The X points are set to the mean values in each bin

Parameters:
histo - Imported histogram

P1D

public P1D(java.lang.String title,
           H1D histo)
Create a P1D container from a histogram. The title is set to the histogram title. Show errors on X as bin width x 0.5 The X points are set to mean values in each bin

Parameters:
title - New title
histo - Imported histogram
Method Detail

setTitle

public void setTitle(java.lang.String title)
Set a new title

Overrides:
setTitle in class DrawOptions
Parameters:
title - New Title

getTitle

public java.lang.String getTitle()
Get a new title

Overrides:
getTitle in class DrawOptions
Returns:
Title

getLinePars

public jplot.LinePars getLinePars()
get LinePars class which holds graphical attributes

Returns:
Graphic attributes

setLinePars

public void setLinePars(jplot.LinePars pnew)
Sets LinePars class for graphical attributes

Parameters:
pnew - Graphic attributes

toFileAsLatex

public void toFileAsLatex(java.lang.String name,
                          java.text.DecimalFormat dx,
                          java.text.DecimalFormat dy)
Write a File in form of LaTeX table from values in the container P1D

Parameters:
name - Name of the file
dx - Format of x values
dy - Format of y values

toFile

public void toFile(java.lang.String name)
Write a P1D to an external file. If errors on data points are not given, they are set to 0

Parameters:
name - File name with output

print

public void print()
Print a P1D container on the screen


merge

public P1D merge(P1D a)
Merge two P1D containers

Parameters:
a - Container to be added
Returns:
New P1D container

setDataArray

public void setDataArray(jplot.DataArray data)
Set data in a form of DataArray

Parameters:
data - input data

oper

public P1D oper(double scale)
Scale P1D container

Parameters:
scale - Scale factor
Returns:
New P1D container

oper

public P1D oper(int scale)
Scale P1D container by keeping the original title

Parameters:
scale - Scale factor
Returns:
New P1D container

oper

public P1D oper(java.lang.String title,
                int scale)
Scale P1D container

Parameters:
title - New title
scale - Scale factor
Returns:
New P1D container

oper

public P1D oper(java.lang.String title,
                double scale)
Scale P1D container

Parameters:
title - New title
scale - Scale factor
Returns:
New P1D container

oper

public P1D oper(P1D a,
                java.lang.String what)
Operations on P1D container: add, subtract, multiply, divide. Keep the same graphical attributes and the title as for the original container

Parameters:
a - Input P1D container
Returns:
Output P1D container

oper

public P1D oper(P1D a,
                java.lang.String title,
                java.lang.String what)
Operations on P1D conatiner: add, subtract, multiply, divide. Keep the same graphical attributes

Parameters:
a - Input P1D container for operation
title - New title
what - String representing the operation: "+" add a P1D container to the original; "-" subtract a P1D from the original; "*" multiply; "/" divide by P1D
Returns:
New P1D container

oper

public P1D oper(P1D a,
                java.lang.String title,
                java.lang.String what,
                java.lang.String how,
                P1D corr)
Operations on P1D container: add, subtract, multiply, divide. Keep the same graphical attributes. Correlated errors are taken into account via additional P1D data holder which keeps correlation coefficients. The size of this P1D holder should be equal to the original size of P1D.

Parameters:
a - Input P1D container for the operation
title - New title
what - String representing the operation: "+" add a P1D to the original; "-" subtract a P1D from the original "*"; multiply "/" divide
how - how the operation should be performed: "X" - for X values; "Y" - do it for Y values; XY - do for X and Y values. Normally, however, you should do this for the Y option.
corr - P1D container which keeps correlation coefficients for each point. In most general case, this container should be filled as: add(0,0,x1,x2,x3,x4,y1,y2,y3,y4), where x1 (left), x2(right), x3(leftSys), x4(rightSys) - coefficients on X y1 (up), y2(down), y3(upSys), x4(downSys) - coefficients on Y. For example, in a simplest case when Y has 1st level (symetrical statistical) errors and X does not have any, you need just define "corr" by filling it with: add(0,0,0,0,0,0,c,c,0,0), where c is a correlation coefficient. If "Y" values have both statistical and systematical errors, use the correlation P1D holder of the form add(0,0,0,0,0,0,c,c,c1,c2),
Returns:
Ouput P1D container

move

public P1D move(java.lang.String what,
                java.lang.String how)
Transform a P1D data holder to some function with error propagation (for both levels)

Parameters:
what - what operation should be performed: "inverse" - inverse to (1/a); "sqrt" - sqrt(a); "exp" - exp(a); "log" - log10(a); "cos" - cos(a) ;"sin" - sin(a); "tan" - tan(a); "acos" - acos(a); "asin" - asin(a); "atan" - atan(a); "cosh" - cosh(a); "sinh" - sinh(a); "tanh" - tanh(a); "square" - a**2
how - how the operation should be performed: "X" - for X values; "Y" - do it for Y values; XY - do for X and Y
Returns:
output P1D object

getDataArray

public jplot.DataArray getDataArray()
Return a DataArray container from JPlot

Returns:
Container of type DataArray

add

public void add(double x,
                double y)
Adds values of a plot-point pair (X,Y). All 1st and 2nd level errors on X and Y are assumed to be 0

Parameters:
x - X-value of the plot-point
y - Y-value of the plot-point

add

public void add(double x,
                double y,
                double err)
Adds the values of a plot-point pair (X,Y). It is assumed that Y-values have 1st level symmetrical errors (i.e. statistical errors). All other errors are set to 0 This point is added at the end of the array.

Parameters:
x - X-value of the plot-point
y - Y-value of the plot-point
err - an error on Y (assume symmetrical)

add

public void add(double x,
                double y,
                double upper,
                double lower)
Add values of a plot-point pair (X,Y). The points include upper and lower errors on Y. All other errors are set to 0. This point is added at the end of the array.

Parameters:
x - X-value of the plot-point
y - Y-value of the plot-point
upper - - upper error on Y
lower - - lower error on Y

add

public void add(double x,
                double y,
                double left,
                double right,
                double upper,
                double lower)
Adds the values of a plot-point pair (X,Y). It includes upper and lower errors on Y and left and right error on X. 2nd level errors are assumed to be 0 This point is added at the end of the array.

Parameters:
x - X-value of the plot-point
y - Y-value of the plot-point
left - - left error on X
right - - right error on X
upper - - upper error on Y
lower - - lower error on Y

add

public void add(double x,
                double y,
                double left,
                double right,
                double upper,
                double lower,
                double left_sys,
                double right_sys,
                double upper_sys,
                double lower_sys)
Adds the values of a plot-point pair (x,y). It includes upper and lower errors on X and Y, including 1st and 2nd level errors (i.e. statistical and systematical). This point is added at the end of the array.

Parameters:
x - x-value of the plot-point
y - y-value of the plot-point
left - - error on x (left)
right - - error on x (right)
upper - - error on y (upper)
lower - - error on y (lower)
left_sys - - error on x (left) - second level, used for systematics
right_sys - - error on x (right)
upper_sys - - error on y (upper)
lower_sys - - error on y (lower)

set

public void set(int i,
                double x,
                double y)
Sets the values of a plot-point pair (X,Y). All errors are assumed to be 0

Parameters:
i - index of the plot-point
x - x-value of the plot-point
y - y-value of the plot-point

set

public void set(int i,
                double x,
                double y,
                double upper,
                double lower)
Sets the values of a plot-point pair (x,y).

Parameters:
i - index of the plot-point
x - x-value of the plot-point
y - y-value of the plot-point
upper - upper error on y
lower - lower error on y

set

public void set(int i,
                double x,
                double y,
                double left,
                double right,
                double upper,
                double lower)
Sets the values of a plot-point pair (x,y).

Parameters:
i - index of the plot-point
x - x-value of the plot-point
y - y-value of the plot-point
left - - error on x (left)
right - - error on x (right)
upper - - error on y (upper)
lower - - error on y (lower)

set

public void set(int i,
                double x,
                double y,
                double left,
                double right,
                double upper,
                double lower,
                double left_sys,
                double right_sys,
                double upper_sys,
                double lower_sys)
Sets the values of a plot-point pair (x,y).

Parameters:
i - index of the plot-point
x - x-value of the plot-point
y - y-value of the plot-point
left - - error on x (left)
right - - error on x (right)
upper - - error on y (upper)
lower - - error on y (lower)
left_sys - - error on x (left) - second level, used for systematics
right_sys - - error on x (right)
upper_sys - - error on y (upper)
lower_sys - - error on y (lower)

size

public int size()
Return the length of the data vector.

Returns:
length of the PlotPoint vector

getArrayX

public double[] getArrayX()
Get array representing X-values

Returns:
array with X values

getCopy

public P1D getCopy()
get a copy of the current holder


getSys

public P1D getSys(P1D[] p1darray)
Return P1D array which contains 2nd level errors (or systematical errors) evaluated from an array of P1D data holders. This means that this method returns a P1D , but now it has systematical errors evaluated from the input array. All systematic variations are treated independently and thus are added in quadrature. Use this method for evaluation of systematical uncertainties. This function implies only for Y values.

Parameters:
p1darray - Input P1D arrays
Returns:
ouput P1D arrays with the same values and systematical errors, but systematical errors are evaluated from the input set of P1D objects

addAndAverage

public P1D addAndAverage(P1D[] p1darray)
Return P1D array with weighted average of several measurements. This is a standard weighted least-squares procedure to combine experimental data with errors. Measurements represented by input P1Ds are assumed to be uncorrelated. Errors in X positions are not affected during averaging. Only 1st and 2nd level errors on Y are used. It is also assumed that upper and lower 1st-level errors on Y have the same size. In case if the are not the same, I average them (and print error!)

Parameters:
p1darray - Input P1D arrays. They will be added to the original P1D
Returns:
ouput P1D arrays with the same values and systematical errors, but systematical errors are evaluated from the input set of P1D objects

getArrayXleft

public double[] getArrayXleft()
Get array representing X-left errors

Returns:
array with X left errors

getArrayXright

public double[] getArrayXright()
Get array representing X-right errors

Returns:
array with X right errors

getArrayXrightSys

public double[] getArrayXrightSys()
Get array representing X-right 2nd level errors

Returns:
array with X right 2nd level errors

getArrayXleftSys

public double[] getArrayXleftSys()
Get array representing X-left 2nd level errors

Returns:
array with X left 2nd level values

getArrayY

public double[] getArrayY()
Get array representing Y-values

Returns:
array with Y values

getX

public double getX(int i)
Return a specific X-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of x at index i

getXleft

public double getXleft(int i)
Return a specific left error on X-value. if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of x at index i

getXright

public double getXright(int i)
Return a specific right error on X-value. if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of x at index i

getXleftSys

public double getXleftSys(int i)
Return a specific left error on X-value (systematical error). if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of x at index i

getXrightSys

public double getXrightSys(int i)
Return a specific right error on X-value (systematical error). if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of x at index i

getY

public double getY(int i)
Return a specific Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of y at index i

getYupper

public double getYupper(int i)
Return a specific upper error on Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of y at index i

getYlower

public double getYlower(int i)
Return a specific lower error on Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of y at index i

getArrayYlower

public double[] getArrayYlower()
Get array representing Y lower errors

Returns:
array with Y lower error

getArrayYlowerSys

public double[] getArrayYlowerSys()
Get array representing Y lower 2nd level errors

Returns:
array with Y lower 2nd level error

getYupperSys

public double getYupperSys(int i)
Return a specific systematical upper error on Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of y at index i

getArrayYupper

public double[] getArrayYupper()
Get array representing Y upper errors

Returns:
array with Y upper error

dimention

public int dimention()
Returns the dimention of this P1D holder. The convention is: 2: only x and y 3: x,y and symmetrical stat error on y 4: only x, y, y(up), y(down) 6: only x, y, x(up), x(down) y(up), y(down) > the rest

Returns:
dimention of the P1D

getYlowerSys

public double getYlowerSys(int i)
Return a specific total lower error on Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.

Parameters:
i - index of the array
Returns:
the value of y at index i

getArrayYupperSys

public double[] getArrayYupperSys()
Get array representing Y upper 2nd level errors

Returns:
array with Y upper 2nd level error

getMax

public double getMax(int axis)
Returns the maximum value in the range. Careful, no error checking on the value of axis, which should be less than N_AXES, defined in GraphSettings.

Parameters:
axis - defines to which axis this function applies.
Returns:
the maximum value.

getMin

public double getMin(int axis)
Returns the minimum value in the range. Careful, no error checking on the value of axis, which should be less than N_AXES, defined in GraphSettings.

Parameters:
axis - defines to which axis this function applies.
Returns:
the minimum value.

mean

public double mean()
Returm the mean value

Returns:
Mean value

clear

public void clear()
Clear the container


toTable

public void toTable()
Print the P1D container to a Table in a separate Frame. The numbers are formatted to scientific format. One can sort and search the data in this table (but not modify)


toTable

public void toTable(boolean format)
Print the P1D container to a Table in a separate Frame. One can sort and search the data in this table (but not modify) #param format if false, numbers will not be formatted to scientific format ##.#####E00



jHepWork 1.1 (C) Chekanov