next up previous contents
Next: Two-dimensional Cuts Up: Using Cuts Previous: Using Cuts

One-Dimensional Cuts

One-dimensional cuts reflect the simple criterion of a value being in a certain numerical range, e.g. ''is the current value of the variable x higher than 0.5 and lower than 0.8 ?''. This can of course be handled ''by hand'', e.g.

if ( x > 0.5 && x < 0.8)
   printf("Value is in range");

,but with the use of cuts the analysis becomes much more readable. Cut parameters (e.g. upper and lower limit in the previous example) are stored in files for archiving and later retrieval. Furthermore, PAW++ allows to change the cut limits graphically (well, with some effort...).

The creation of one-dimensional cuts is done with the call cut(name,initial);. name is used to identify the cut to the ''outside world'', i.e. PAW. Note, that due to restrictions in PAW's handling of cuts, the names must be numbers, although this is not required (and desired) from YODA. The second parameter is the default logical value that the cut should have, as long as no points for the cut are defined. You can choose either ''true'' (1) , meaning that the cut always holds (i.e. all values are inside the cut limits), or ''false'' (0), meaning the cut never holds (i.e. all values are outside the cut limits).

So a typical call to create a 1-dimensional cut would be:

proc init()
{
/* create the pulse height cut with id 30. default value is true (1) */
phcut = cut("30", 1); 
}

Upper and lower limit are not set yet for this cut. To use the cut in proc analyze(), use the inside(CUT,X) call. For instance, to reproduce the example above, you would write:

if (inside(phcut, x))
   printf("Value is in range");

To read cuts from a file, you can either choose the hoc-function readcuts(FILENAME) to read the cut parameters from file FILENAME, or you can read or save them them via the YODA cut pulldown menu.

To produce such a file, you (currently) have to ''cheat'' PAW++. Since inside PAW++, cuts have only a meaning in the context of ntuples (which will not be discussed here), you must pretend to define a cut for an ntuple. By default, cuts are 1-dimensional inside PAW++. Simply draw your histogram inside PAW++ and enter:

cut 30 g

Then, you can click inside the histogram with the left mouse button to define lower and upper limit (in x) of the cut. Finish the definition with the left mouse button. You can then draw a different histogram, start a new cut definition with cut IDENTIFIER g and so on. To use these cuts again inside YODA, they must have the same IDENTIFIER as the cut's name in the user task. This is the reason for using only numerical ''names'' for the cuts inside the user tasks.

After all cuts are defined, they can be written to file with the PAW command cut 0 w FILENAME, where 0 means ''all cuts'' and FILENAME is the name of the file where PAW should save the cut parameters. (Although it is an ugly format, it is plain ASCII, and you can edit it afterwards with an editor, if you want to).

This file can then be read into YODA either via the ''cut'' pull-down-menu or inside the user task (proc init() with the call readcuts(FILENAME); . By doing this, the setting of the cut parameters become effective immediately.


next up previous contents
Next: Two-dimensional Cuts Up: Using Cuts Previous: Using Cuts
Heiko Rohdjess
2001-07-19